Bug #11427
antlr3 build: braces.g vocab additions not reflected in PreprocTokenTypes.java
Status:
New
Priority:
Low
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:
0%
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:
History
#1 Updated by Hynek Cihlar 3 months ago
- Subject changed from antlr3 build: @braces.g@ vocab additions not reflected in @PreprocTokenTypes.java@ to antlr3 build: braces.g vocab additions not reflected in PreprocTokenTypes.java
#2 Updated by Hynek Cihlar 3 months ago
- Priority changed from Normal to Low
PreprocTokenTypes.java is generated by antlr3_text from text.g. The Preproc vocabulary it captures is also extended by antlr3_braces via exportVocab=Preproc, e.g. with the DIGITS token. Gradle does not model that cross-grammar dependency.
When antlr3_text is up-to-date but antlr3_braces runs, Preproc.txt gets the new tokens but PreprocTokenTypes.java is not regenerated. BracesParser.java then references symbols that no longer exist in PreprocTokenTypes.java, and the build fails:
BracesParser.java:196: error: cannot find symbol
else if (((LA(1)==STAR||LA(1)==AMPER||LA(1)==DIGITS) && ...
^
symbol: variable DIGITS
location: class BracesParser
40 errors
Reproduce¶
- Start from a tree where
text.gis newer thanPreprocTokenTypes.javabutbraces.gis not. ./gradlew clean jar.- Build fails with
cannot find symbolonDIGITS(or any other token defined only bybraces.g).
Workaround: touch src/com/goldencode/p2j/preproc/braces.g src/com/goldencode/p2j/preproc/text.g, run ./gradlew antlr3_text antlr3_braces, then re-run ./gradlew jar.
Fix¶
Two options in build.gradle:
- Declare
PreprocTokenTypes.javaandPreproc.txtas outputs of bothantlr3_textandantlr3_bracesso gradle invalidates correctly. - Re-run the
PreprocTokenTypes.javacode-gen step afterantlr3_bracescontributes its tokens, so the generated interface reflects the full vocabulary.
Option 1 is the cleanest structural fix.