module languages.antlr_grammar_use
¶
Short summary¶
module pyensae.languages.antlr_grammar_use
Use grammar This module requires antlr4-python3-runtime.
Functions¶
function |
truncated documentation |
---|---|
Returns two classes, a parser and a lexer from antlr4. |
|
Returns a graph with networkx. |
|
Returns a string which shows the parsed tree. |
|
Parses a code and returns a tree. |
Documentation¶
Use grammar This module requires antlr4-python3-runtime.
- pyensae.languages.antlr_grammar_use.get_parser_lexer(language)¶
Returns two classes, a parser and a lexer from antlr4.
- Parameters:
language – to analyse
- Returns:
Parser, Lexer
- pyensae.languages.antlr_grammar_use.get_tree_graph(tree, parser, format=<class 'pyensae.languages.tree_graph_listener.TreeGraphListener'>)¶
Returns a graph with networkx.
- Parameters:
tree – from
parse_code
parser – the parser used to build the tree, output of
parse_code
format – None or a class ParseTreeListener
- Returns:
string
- pyensae.languages.antlr_grammar_use.get_tree_string(tree, parser, format=<class 'pyensae.languages.tree_string_listener.TreeStringListener'>)¶
Returns a string which shows the parsed tree.
- Parameters:
tree – from
parse_code
parser – the parser used to build the tree, output of
parse_code
format –
None or a class ParseTreeListener
- Returns:
string
- pyensae.languages.antlr_grammar_use.parse_code(code, class_parser, class_lexer)¶
Parses a code and returns a tree.
- Parameters:
code – code to parse
class_parser – parser
class_lexer – lexer
- Returns:
parsed code