Subject: ambiguities in grammar with CFWS and the obs- stuff?

From: Sam Roberts <[email-masked]>
Date: Sun, 6 Feb 2000 19:04:00 -0500 (est)

I'm debugging my date-time parser, and I've found what appears
to me to be a conflict between the date-time rule, and the obs-year
rule.

date-time = ... date FWS time ...

The FWS is obviously non-optional, but date, in the obs- variation
can end with obs-year, and ops-year includes the trailing CFWS.

obs-year = ... 2*DIGIT [CFWS]

My parser is globbing all the FWS with the trailing CFWS of the obs-year.

A similar thing happens with the:

 obs-day obs-month obs-year

sequence, the CFWS becomes part of obs-day, leaving none of the
mandatory CFWS left for the obs-month.

In a slightly different fashion, a time such as:

20(comment):12

is failing:

time-of-day = hour ":" minute
hour = 2DIGIT / obs-hour
obs-hour = [CFWS] 2DIGIT [CFWS]

"20" matches the first form of the hour rule, no need to resort to
obs-hour, but "(comment):" doesn't match ":". Something like:

time-of-day = hour ":" minute [":" second] / obs-time-of-day
obs-time-of-day = hour [CFWS] ":" [CFWS] minute [CFWS] [":" [CFWS] second]

would match more naturally.

I don't know if this is really a problem, but my code was a literal
representation of the ABNF until I ran into these, now I'm having to
rewrite the ABNF. To me it seems like an ambiguity in the grammer, I
need to decide if:

top = left b c
left = a [b]

associates the b with the left or the right. This happens a bunch with
trailing [CFWS] in the obsolete forms followed by mandatory FWS.

Also problematic is:

top = left ":" right
left = a / else
else = (a space)

For input:

a space : ...

The a is matched right away. This happens with:

Fri(the 13th),

where "Fri" matches right away, no need to resort to the obs-dayofweek
that would've matched the comment, but we need the comment matched.

Any comments anyone? With my Rfc822 parser I just put statments before
and after looking for or getting a token that would attempt to match
as much whitespace or comments as I could. I'd rather that the grammer
completely specified where CFWS can appear, like DRUMS does, but unless
there's an interpretation of the ABNF that is less problematic for me
perhaps I'll go back to my Rfc822 parser for reading messages, and make a
simpler drums parser (minus all the obs- forms) that I use only to
verify compliance.

Sam

--
Sam Roberts, sroberts at uniserve dot com, www.emyr.net/Sam