Ichor.BNF.Actions (Ichor v0.2.0)

Copy Markdown View Source

Turns a parsed classical BNF grammar_file into a real %{nonterminal_name_atom => Grammar.IR.expr()} map -- one Grammar.IR tree per rule, the same target category Ichor.ABNF.Actions and Regex.Actions both use.

Classical BNF has no single citable standard; this follows the ALGOL 60 Report's own convention for everything except terminal symbols -- the strictest reading of the Report leaves those unquoted, distinguished from nonterminals only by the reader already knowing the target language's keyword set. This grammar quotes terminals instead ('lit'/"lit"), matching how BNF is actually written in nearly every modern presentation of it -- a deliberate deviation from the Report's strictest reading, not an oversight.

Unlike ABNF (RFC 5234's rule names are explicitly case-insensitive), classical BNF has no such spec-level rule -- nonterminal names are kept exactly as written, not downcased.

Rules are separated by an explicit newline (@skip's own token only covers space/tab within one rule) -- sequence := element+'s own greedy repetition can't otherwise tell "one more element of this rule" apart from "the next rule's own opening nonterminal, on the next line," since both parse identically as an element.