Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document -split-parser cmd-line option #4771

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions doc/tool-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ANTLR Parser Generator Version 4.7.1
-no-visitor don't generate parse tree visitor (default)
-package ___ specify a package/namespace for the generated code
-depend generate file dependencies
-split-parser generate separate files for parser serialized DFA and context classes
-no-split-parser generate parser serialized DFA and context classes locally (default)
-D<option>=value set/override a grammar-level option
-Werror treat warnings as errors
-XdbgST launch StringTemplate visualizer on generated code
Expand Down Expand Up @@ -125,6 +127,32 @@ TBaseListener.java : T.g

If you use -lib libdir with -depend and grammar option tokenVocab=A, then the dependencies include the library path as well: T.g: libdir/A.tokens. The output is also sensitive to the -o outdir option: outdir/TParser.java : T.g.

## `-split-parser`

This is a Java-only option. By default, ANTLR serializes the ATN within the generated Parser class, and parse tree RuleContexts as static child classes of the generated Parser class. This works well in all situations, but with very large and/or complex grammars, this may lead to generated parsers holding more than 64k lines, which is te maximum a JVM debugger can support. This option tells ANTLR to generate the serialized ATN and the RuleContext classes in dedicated files, thus drastically reducing the size of the generated parser source code.

```bash
$ antlr4 -split-parser T.g
TLexer.java
TParser.java
TParserAST.java
TParserContexts.java
TListener.java
TBaseListener.java
```

## `-no-split-parser`

Tell ANTLR not to place the serialized ATN and the RuleContext classes within the generated parser; this is the default.

```bash
$ antlr4 -no-split-parser T.g
TLexer.java
TParser.java
TListener.java
TBaseListener.java
```

## `-D<option>=value`

Use this option to override or set a grammar-level option in the specified grammar or grammars. This option is useful for generating parsers in different languages without altering the grammar itself. (I expect to have other targets in the near future.)
Expand Down
Loading