instaparse icon indicating copy to clipboard operation
instaparse copied to clipboard

Support for the ABNF #rule

Open ulsa opened this issue 11 years ago • 2 comments

There seems to be no support for the #rule, as specified in RFC 2616, section 2.1. Is it in the works?

For now I guess I could just make the conversion from, say:

1#element

to:

( *LWS element *( *LWS "," *LWS element ))

ulsa avatar May 10 '14 14:05 ulsa

The standard for ABNF is defined here: http://tools.ietf.org/html/rfc5234 and I don't find any reference to this #rule construct. I think it may be a construct invented for the purpose of the particular specification you referred to. According to the standard,

"In the early days of the Arpanet, each specification contained its own definition of ABNF."

So perhaps that is what is going on here, and RFC 2616 defined the # notation for its own convenience. I've personally never seen it before. Do you have any idea how common/uncommon that particular notation is?

In general, I would say that the thrust of the ABNF syntax is to stay as true to the official specification as possible, but since the # character doesn't really interfere with the existing implementation, it would be feasible to add support for it. I would welcome more input about how useful/desirable that would be.

Engelberg avatar May 10 '14 16:05 Engelberg

The #rule was, I think, originally defined in rfc822 (the email RFC) from 1982. A new RFC for email, rfc2822, was created in 2001, where the ABNF spec was moved to rfc2234 and the #rule was taken out. However, I've also seen the #rule in this HTTP/1.1 draft from Feb 2014 that is supposed to (?) obsolete rfc2616. That was the reason for my question. The rumour of the death of the #rule may be premature.

As for how common its use is, I don't know about other specs, but it seems to be very common in grammars for HTTP header fields. Many headers in rfc2616 use it. I counted 28 places there.

ulsa avatar May 11 '14 13:05 ulsa