alogos._grammar.parsing
¶
Submodules¶
Functions¶
|
Read grammar from text in BNF notation. |
|
Read grammar from text in EBNF notation. |
|
Write grammar as text in BNF notation. |
|
Write grammar as text in EBNF notation. |
|
Parse a string with Lark and construct a derivation tree of this package. |
Detailed object descriptions¶
- alogos._grammar.parsing.read_bnf(grammar, bnf_text, verbose, *symbols)[source]¶
Read grammar from text in BNF notation.
- alogos._grammar.parsing.read_ebnf(grammar, ebnf_text, verbose, *symbols)[source]¶
Read grammar from text in EBNF notation.
References
Conversion of EBNF to BNF notation
https://stackoverflow.com/questions/2466484/converting-ebnf-to-bnf
https://stackoverflow.com/questions/2842809/lexers-vs-parsers useful notes in “EBNF really doesn’t add much to the power of grammars.”
https://condor.depaul.edu/ichu/csc447/notes/wk3/BNF.pdf useful notes in summary on last page
https://stackoverflow.com/questions/20175248/ebnf-is-this-an-ll1-grammar
- alogos._grammar.parsing.write_bnf(grammar, rules_on_separate_lines, *symbols)[source]¶
Write grammar as text in BNF notation.
- alogos._grammar.parsing.write_ebnf(grammar, rules_on_separate_lines, *symbols)[source]¶
Write grammar as text in EBNF notation.
- alogos._grammar.parsing.parse_string(grammar, string, parser, get_multiple_trees, max_num_trees=None)[source]¶
Parse a string with Lark and construct a derivation tree of this package.
The derivation tree is built with the data structure defined in this package, not with the parse tree object provided by Lark. The reason is that the derivation tree is subsequently used for various tasks such as different traversals, extracting strings or derivations and visualization. Therefore it desirable to have it decoupled from the parser library and that it comes with methods for the mentioned tasks.
References