Appendix: Legacy Mapping¶
CongoCC descends from JavaCC (by way of JavaCC 21) but does not accept legacy JavaCC syntax — the old constructs were removed rather than carried forward. This appendix maps the legacy features to their CongoCC replacements, for readers coming from JavaCC or JJTree and for converting older grammars.
Tools¶
Legacy tool |
CongoCC |
|---|---|
JJTree |
No separate preprocessor — tree building is built in and on by default (Tree Building). |
JJDoc |
No direct equivalent. |
Syntax changes¶
Legacy JavaCC |
CongoCC |
|---|---|
|
Top-level |
|
Removed; add code with |
|
|
|
|
|
|
|
|
|
Removed; use an ordinary production, or |
|
|
JJTree |
The built-in |
Token productions (<NAME : regex>) are largely unchanged, though character
classes and complex patterns must be enclosed in < … > (Lexical Specification).
Settings removed or changed¶
Many JavaCC options were removed because the behavior is now unconditional, or replaced by a different mechanism.
Legacy option |
Replacement |
|---|---|
|
|
|
|
|
|
|
|
|
|
Now always on (option removed): UNICODE_INPUT, KEEP_LINE_COL,
ERROR_REPORTING, SANITY_CHECK.
Removed outright: STATIC, the global LOOKAHEAD,
CHOICE_AMBIGUITY_CHECK, OTHER_AMBIGUITY_CHECK, FORCE_LA_CHECK,
BUILD_PARSER, BUILD_LEXER, DEBUG_PARSER, DEBUG_LEXER,
CACHE_TOKENS, USER_DEFINED_TOKEN_MANAGER, USER_CHAR_STREAM, and
GRAMMAR_ENCODING (input is assumed to be UTF-8). JDK_TARGET is accepted
but has no effect (Settings Reference).
Converting a legacy grammar¶
CongoCC does not itself convert legacy grammars. The path is:
Run the syntax converter included with recent JavaCC 21 builds to modernize the old grammar’s syntax:
$ java -jar javacc-full.jar convert OldGrammar.jj
Build the converted grammar with CongoCC, and apply the manual fix-ups that conversion does not handle — chiefly import statements and the points below.
Things to expect when moving to CongoCC:
Tree building always generates two packages, one for the parser and one for the nodes; code cannot be generated into the default (unnamed) package.
The
XXXConstantsinterface no longer exists — token types are theTokenTypeenum (Generated API).The base node class lives in the node package.
A grammar that relied on JavaCC’s old lookahead quirks may need
LEGACY_GLITCHY_LOOKAHEAD = true;to reproduce the original behavior.
A task-oriented walkthrough is in Migrating from JavaCC / JavaCC21.