# Using ANTLR Grammars¶

ANTLR is one of the best known parser genrators, and it has an important collection of grammars. The tatsu.g2e module can translate an ANTLR grammar to the syntax used by 竜 TatSu.

The resulting grammar won’t be immediately usable. It will have to be edited to make it abide to PEG semantics, and in general be adapted to the way things are done with 竜 TatSu.

To use g2e as a module, invoke one of its translation functions.

def translate(text=None, filename=None, name=None, encoding='utf-8', trace=False):


For example:

from tatsu import g2e

tatsu_grammar = translate(filename='mygrammar.g', name='My')
with open('my.ebnf') as f:
f.write(tatsu_grammar)


g2e can also be used from the command line:

\$ python -m tatsu.g2e mygrammar.g > my.ebnf