Re: ABNF definition of NPT temporal fragment times

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 UTC