File: antlr4.1

package info (click to toggle)
antlr4 4.9.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,328 kB
  • sloc: java: 45,008; javascript: 1,121; xml: 1,077; python: 73; cs: 71; sh: 29; makefile: 9
file content (177 lines) | stat: -rw-r--r-- 6,176 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
.\"                                      Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH ANTLR 1
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH "NAME"
ANTLR \- ANother Tool for Language Recognition, version 4
.SH "SYNOPSIS"
.B antlr4
[\fIoptions\fR] \fIfile.g4\fR [ \fIfile2.g4\fR \fIfile3.g4\fR ...]
.br
.SH "DESCRIPTION"
ANTLR (ANother Tool for Language Recognition) is a parser generator
for reading, processing, executing, or translating structured text
or binary files. It's widely used to build languages, tools, and
frameworks. From a grammar, ANTLR generates a parser that can build
and walk parse trees.

.SH "OPTIONS"

.TP
\fB\-o\fR \fIoutdir\fR
Specify output directory where all output is generated.

ANTLR generates output files in the current directory by default. This option
specifies the output directory where ANTLR should generate parsers, listeners,
visitors, and tokens files.

.TP
\fB\-lib\fR \fIdir\fR
Specify location of grammars, tokens files.

When looking for tokens files and imported grammars, ANTLR normally looks in
the current directory. This option specifies which directory to look in instead.
It is only used for resolving grammar references for the import statement and
the tokenVocab option. The path to the primary grammar must always be fully
specified.

.TP
\fB\-atn\fR
Generate rule augmented transition network diagrams.

This option generates DOT graph files that represent the internal ATN (augmented
transition network) data structures that ANTLR uses to represent grammars. The
files come out as Grammar.rule .dot. If the grammar is a combined grammar, the
lexer rules are named Grammar Lexer.rule .dot.

.TP
\fB\-encoding\fR \fIencodingname\fR
Specify grammar file encoding; e.g., euc-jp.

By default ANTLR loads grammar files using the UTF-8 encoding, which is a very
common character file encoding that degenerates to ASCII for characters that fit
in one byte. If that grammar file is not the default encoding for your locale,
you need this option so that ANTLR can properly interpret grammar files. This
does not affect the input to the generated parsers, just the encoding of the
grammars themselves.

.TP
\fB\-message\-format\fR \fIformat\fR
Specify output style for messages in antlr, gnu, vs2005.

ANTLR generates warning and error messages using templates
from directory tool/resources/org/antlr/v4/tool/templates/messages/formats.
By default, ANTLR uses the antlr.stg (StringTemplate group) file. You can change
this to 'gnu' or 'vs2005' to have ANTLR generate messages appropriate for Emacs
or Visual Studio. To make your own called X, create resource
org/antlr/v4/tool/templates/messages/formats/X and place it in the CLASSPATH.

.TP
\fB\-long-messages\fR
Show exception details when available for errors and warnings.

.TP
\fB\-listener\fR
Generate parse tree listener (default).

.TP
\fB\-no\-listener\fR
Don't generate parse tree listener.

.TP
\fB\-visitor\fR
Generate parse tree visitor.

ANTLR can generate both parse tree listeners and visitors; this option and
\fB\-listener\fR aren’t mutually exclusive.

.TP
\fB\-no\-visitor\fR
Don't generate parse tree visitor (default).

.TP
\fB\-package\fR \fIpackagename\fR
Specify a package/namespace for the generated code.

Use this option to specify a package or namespace for ANTLR-generated files.
Alternatively, you can add a @header {...} action but that ties the grammar
to a specific language. If you use this option and @header, make sure that
the header action does not contain a package specification otherwise the
generated code will have two of them.

.TP
\fB\-depend\fR
Generate file dependencies.

Instead of generating a parser and/or lexer, generate a list of file
dependencies, one per line. The output shows what each grammar depends on and
what it generates. This is useful for build tools that need to know ANTLR
grammar dependencies.

If you use \fB\-lib\fR libdir with \fB-depend\fR and grammar option
tokenVocab=A, then the dependencies include the library path as well.

 -Xforce-atn         use the ATN simulator for all predictions
 -Xlog               dump lots of logging info to antlr-timestamp.log

.TP
\fB\-D<option>=<value>\fR
Set or override a grammar-level option.

This option is useful for generating parsers in different languages without
altering the grammar itself (with \fB\--Dlanguage=CSharp\fR for example).

.TP
\fB\-Werror\fR
Treat warnings as errors.

As part of a large build, ANTLR warning messages could go unnoticed. Turn on
this option to have warnings treated as errors, causing the ANTLR tool to report
failure back to the invoking commandline shell.

.TP
\fB\-XdbgST\fR
Launch StringTemplate visualizer on generated code.

For those building a code generation target, this option brings up a window
showing the generated code and the templates used to generate that code.
It invokes the StringTemplate inspector window.

.TP
\fB\-XdbgSTWait\fR
Wait for STViz to close before continuing.

.TP
\fB\-Xforce\-atn\fR
Use the ATN simulator for all predictions.

ANTLR normally builds traditional “switch on token type” decisions where
possible (one token of lookahead is sufficient to distinguish between all
alternatives in a decision). To force even these simple decisions into
the adaptive LL(*) mechanism, use this option.

.TP
\fB\-Xlog\fR
Dump lots of logging info to antlr-timestamp.log.

This option creates a log file containing lots of information messages from
ANTLR as it processes your grammar. If you would like to see how ANTLR
translates your left-recursive rules, turn on this option and look in the
resulting log file.

.SH "SEE ALSO"
.BR http://www.antlr4.org
.br