backus_naur_form_parser
Uses backus naur forms to parse and compile strings.
Example
The BackusNaurForm struct represents a backus naur form. To create one, the macro is recommended. A rule consists of up to 3 things:
- A priority. Rules with higher priority get applied first. (denoted by "priority number] =>")
- The rule. This is a raw string literal (r#"string comes here"#) so it can contain strings. The form is just like bnf: r#" ::= "terminal string" "terminal string2" | "abc" <non_terminal | ..."#
- OPTIONAL: A function that compiles this token if its at the uppermost level in the AST. More info in the code documentation at backus_naur_form_parser_and_compiler::backus_naur_form::BackusNaurForm::compile_string. This is a closure that takes a token and the backus naur form as arguments and returns a String. (denoted by a => |token, bnf| {})
The below code is a example that doubles the digits of a equation and replaces the with ""
let bnf = backus_naur_form!;
assert_eq!;