Project

General

Profile

Bug #11427

antlr3 build: braces.g vocab additions not reflected in PreprocTokenTypes.java

Added by Hynek Cihlar 3 months ago. Updated 3 months ago.

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

  1. Start from a tree where text.g is newer than PreprocTokenTypes.java but braces.g is not.
  2. ./gradlew clean jar.
  3. Build fails with cannot find symbol on DIGITS (or any other token defined only by braces.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:

  1. Declare PreprocTokenTypes.java and Preproc.txt as outputs of both antlr3_text and antlr3_braces so gradle invalidates correctly.
  2. Re-run the PreprocTokenTypes.java code-gen step after antlr3_braces contributes its tokens, so the generated interface reflects the full vocabulary.

Option 1 is the cleanest structural fix.

#3 Updated by Greg Shah 3 months ago

Also: We use ANTLR 2.7.4 so the antlr3_ names are misleading.

Also available in: Atom PDF