module mokadi.mokadi_parser

Short summary

module botadi.mokadi.mokadi_parser

Parse with Mokadi’sgrammar.

source on GitHub

Functions

function

truncated documentation

get_tree_string

returns a string which shows the parsed tree

parse_mokadi

Parse a sentance with mokadi language.

print_level_order

Displays a tree for the parsed text.

run_parse

Parses the script and intercept standard output and error.

Documentation

Parse with Mokadi’sgrammar.

source on GitHub

botadi.mokadi.mokadi_parser.get_tree_string(MokadiGrammarListener, tree, parser, script=None)

returns a string which shows the parsed tree

Parameters
  • MokadiGrammarListener – listener to use

  • tree – from parse_code()

  • parser – the parser used to build the tree

  • format – None or a class ParseTreeListener

Returns

string or C# code in Scope script (scope instructions are replace by blank lines)

source on GitHub

botadi.mokadi.mokadi_parser.parse_mokadi(content, MokadiGrammarParser, MokadiGrammarLexer)

Parse a sentance with mokadi language.

Parameters
  • MokadiGrammarParser – parser for a specific language

  • MokadiGrammarLexer – lexer for a specific language

  • content – string

Returns

instance of MokadiGrammarParser

source on GitHub

botadi.mokadi.mokadi_parser.print_level_order(node, indent=0)

Displays a tree for the parsed text.

Parameters

node – output of parser.parse()

Returns

string (see below)

Example of results:

MOKADIbruitdetoilette - <Parse>
   MOKADI - <Mokadi>
      MOKADI - <TerminalNodeImpl>
   bruit - <Expression_stmt>
      bruit - <Expression>
         bruit - <Anything_stmt>
            bruit - <Word_name_ext>
               bruit - <Word_name>
                  bruit - <TerminalNodeImpl>
   de - <ErrorNodeImpl>
   toilette - <ErrorNodeImpl>

source on GitHub

botadi.mokadi.mokadi_parser.run_parse(parser)

Parses the script and intercept standard output and error.

Parameters

parser – parser, output of parse_scope()

Returns

stdout, stderr, tree

Unfortunately, it is not multithreaded. It should be done in another way than by replacing sys.stdout and sys.stderr.

source on GitHub