module languages.antlr_grammar_use

Short summary

module pyensae.languages.antlr_grammar_use

Use grammar This module requires antlr4-python3-runtime.

source on GitHub

Functions

function

truncated documentation

get_parser_lexer

Returns two classes, a parser and a lexer from antlr4.

get_tree_graph

Returns a graph with networkx.

get_tree_string

Returns a string which shows the parsed tree.

parse_code

Parses a code and returns a tree.

Documentation

Use grammar This module requires antlr4-python3-runtime.

source on GitHub

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

source on GitHub

pyensae.languages.antlr_grammar_use.get_tree_graph(tree, parser, format=<class 'pyensae.languages.tree_graph_listener.TreeGraphListener'>)

Returns a graph with networkx.

Parameters:
Returns:

string

source on GitHub

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:
Returns:

string

source on GitHub

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

source on GitHub