module languages.antlr_grammar_build

Short summary

module pyensae.languages.antlr_grammar_build

Helpers to build grammars This module requires antlr4. and antlr4-python3-runtime.

source on GitHub

Functions

function

truncated documentation

_is_syntax_is_missing

Downloads the grammar for a specific language if the files is missing.

build_grammar

Compiles the grammar for a specific file.

Documentation

Helpers to build grammars This module requires antlr4. and antlr4-python3-runtime.

source on GitHub

pyensae.languages.antlr_grammar_build._is_syntax_is_missing(language)[source]

Downloads the grammar for a specific language if the files is missing.

Parameters

language – language: python, sqlite, …

Returns

grammar file

source on GitHub

pyensae.languages.antlr_grammar_build.build_grammar(g4, version='4.7.1', fLOG=<function noLOG>)[source]

Compiles the grammar for a specific file.

Parameters
  • g4 – grammar format antlr4

  • version – version of antlr4 to use, 4.7

  • fLOG – logging function

Returns

list of files

The compilation must be done with antlr4. It generates a lexer and a parser which can be imported in Python. The options for the command line are described at: antlr4 options.

Builds a Antlr4 grammar

See grammars-v4

build_grammar("R.g4")

source on GitHub