Antlr - antlr4.(bat|sh)

> Antlr (ANother Tool for Language Recognition)

1 - About

antlr4.(bat|sh) is the command line script of Antlr.

Advertising

3 - Installation

4 - Syntax (Options)

antlr
ANTLR Parser Generator  Version 4.8
 -o ___              specify output directory where all output is generated
 -lib ___            specify location of grammars, tokens files
 -atn                generate rule augmented transition network diagrams
 -encoding ___       specify grammar file encoding; e.g., euc-jp
 -message-format ___ specify output style for messages in antlr, gnu, vs2005
 -long-messages      show exception details when available for errors and warnings
 -listener           generate parse tree listener (default)
 -no-listener        don't generate parse tree listener
 -visitor            generate parse tree visitor
 -no-visitor         don't generate parse tree visitor (default)
 -package ___        specify a package/namespace for the generated code
 -depend             generate file dependencies
 -D<option>=value    set/override a grammar-level option
 -Werror             treat warnings as errors
 -XdbgST             launch StringTemplate visualizer on generated code
 -XdbgSTWait         wait for STViz to close before continuing
 -Xforce-atn         use the ATN simulator for all predictions
 -Xlog               dump lots of logging info to antlr-timestamp.log
 -Xexact-output-dir  all output goes into -o dir regardless of paths/package

Doc

where D… is a grammar options. Example for the language:

antlr4 -Dlanguage=Java T.g4 # default
antlr4 -Dlanguage=C T.g4
antlr4 -Dlanguage=Python2 T.g4

5 - Example

antlr4 ^
    -o %ProjectRoot%\gen ^ 
    -listener ^
    -visitor ^
    -lib %ProjectRoot%/src/main/antlr4/com/group/package/lexer ^ # output dir
    %ProjectRoot%src/main/antlr4/grammar.g4

where:

Advertising