W3C home > Mailing lists > Public > public-media-fragment@w3.org > July 2011

Re: ABNF definition of NPT temporal fragment times

From: Jack Jansen <Jack.Jansen@cwi.nl>
Date: Wed, 6 Jul 2011 11:01:11 +0200
Cc: Media Fragment <public-media-fragment@w3.org>
Message-Id: <3497BCD2-9B2C-47BD-9C13-BDAD60148F27@cwi.nl>
To: Chris Double <chris.double@double.co.nz>

On 6 jul 2011, at 08:17, Chris Double wrote:

> Parts of the definition of NPT temporal fragments in the spec looks like:
> 
> npttimedef    = [ deftimeformat ":"] ( npttime  [ "," npttime ] ) / (
> "," npttime )
> npt-sec       =  1*DIGIT [ "." *DIGIT ]
> npt-mmss      =  npt-mm ":" npt-ss [ "." *DIGIT]
> npttime       = npt-sec / npt-mmss / npt-hhmmss
> 
> Because the 'npt-sec' clause is the first item in the alternates
> amongst 'npttime', given a temporal fragment of '#t=20:10', I see that
> 'npt-sec' will successfully match, but 'npttimedef' will fail since a
> ':' instead of a ',' follows the first number. Is it expected that
> this will then backtrack to retry the 'npt-mmss' clause? I'm
> unfamiliar with how ABNF definitions in these specs tend to work and
> whether backtracking is the norm. If not, then 'npt-mmss' would never
> match? Should the alternate clauses be re-ordered to work around this
> or is this level of detail not usually worried about in these types of
> specs since the intent is obvious?


Chris,
the ABNF grammar is purely used for specification here. If you would take this grammar and turn it straight into an implementation you would indeed have to do backtracking.

Programming languages (at least: programming languages invented in the seventies:-) often have their grammar specified as an LR grammar, which can be parsed relatively simply from left to right, but at the expense of grammar readability. For something as simple as media fragments its better to have the grammar be readable, as using a parser generator or somesuch is overkill.
--
Jack Jansen, <Jack.Jansen@cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma Goldman
Received on Wednesday, 6 July 2011 09:01:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 21 September 2011 12:13:43 GMT