Command line options


java org.antlr.Tool [args] file.g [file2.g file3.g ...]



-o outputDir

specify output directory where all output is generated; search for token vocabularies in here also

-fo outputDir

same as -o but force even files with relative paths to dir


generate file dependencies; don't actually run antlr

-lib dir

specify location of token files and important grammars


print out a report about the grammar(s) processed


print out the grammar without actions


generate a parser with trace output - if the default output is not enough, you can override the traceIn and traceOut methods


generate a parser that emits debugging events


generate a parser that computes profiling information


generate an NFA for each rule


generate a DFA for each decision point

-message-format name

specify output style for messages


display extended option list

There are a bunch of less often used "extended" options as well.

Extended option



print the grammar AST


print DFA as text


do not test EBNF block exit branches


collapse incident edges into DFA states


dump lots of info during NFA conversion


run the analysis in 2 threads


do not merge stop states


generate DFA states in DOT with NFA configs


print a message for each NFA before converting


put tags at start/stop of all templates in output

-Xm m

max number of rule invocations during conversion

-Xmaxdfaedges m

max "comfortable" number of edges for single DFA state

-Xconversiontimeout t

set NFA conversion timeout for each decision

-Xmaxinlinedfastates m

max DFA states before table used rather than inlining


for nondeterminisms, list NFA states for each path