bnf icon indicating copy to clipboard operation
bnf copied to clipboard

RFC ABNF parsing

Open Carlyle-Foster opened this issue 1 year ago • 1 comments

i want to implement support for parsing the kind's of ABNF's used in RFC's like RFC 822: Standard for ARPA Internet Text Messages and RFC 9112: HTTP/1.1. RFC 5234: ABNF shoould be a big help here, but older RFC's don't strictly follow it and newer ones often use extensions.

the obvious (to me) first step is adding support for ; comments, followed by support for bare non-terminals and = withou :: like in CRLF = CR LF

i'm not sure how this should be reflected in the API, we've still got to support .parse() but it should probably(?) be marked deprecated on account of BNF not being standardized enough for it to make sense, maybe Grammar::parse_from(source, spec) could work? i like the idea of having a single function dispatching on an enum, having separate functions for BNF and EBNF could be misleading because the BNF versions by themselves might appear complete

Carlyle-Foster avatar Jan 01 '25 20:01 Carlyle-Foster

i've made a lot of progress on this in a branch, got () and [] and / down, but i'm starting to reconsider the approach of having different formats when they seem cross-compatible, what if we just made the parser more permissive instead so u could use | or /, ::= or =, etc.

Carlyle-Foster avatar Jan 08 '25 04:01 Carlyle-Foster