Skip to main content

import_bnf

Function import_bnf 

Source
pub fn import_bnf(text: &str) -> Result<Grammar, GrammarImportError>
Expand description

Parses classic angle-bracket Backus-Naur Form text into the grammar IR.

Each line holds one <name> ::= alternatives production; a later production for the same name adds alternatives to it. Terminals are single- or double-quoted without escape sequences, and ; starts a line comment.

ยงErrors

Returns GrammarImportError when the BNF text cannot be parsed or when a non-terminal reference does not resolve to a rule.