[antlr-interest] Reduce.g generates broken java with antlr-3.4-complete.jar (but not antlr-3.3-complete.jar)
Toby Nance
toby.nance at gmail.com
Tue Apr 10 11:47:04 PDT 2012
The file walking/patterns/Reduce.g (downloadable for the book "Language
Implementation Patterns" by Terence Parr) produces invalid java code when
using antlr-3.4-complete.jar.
I'm not sure of the rights I have to redistribute the code here, so here's
the code reduced to what still causes the error.
//*********************** start of Reduce.g****
tree grammar Reduce;****
options {****
tokenVocab=VecMath; // use tokens from VecMath.g****
ASTLabelType=CommonTree; // we're using CommonTree nodes****
output=AST; // build new ASTs from input AST****
filter=true; // tree pattern matching mode****
backtrack=true; // allow backtracking if it's needed****
}****
** **
bottomup : multBy2 ;****
** **
multBy2****
: ^('*' x=INT {$x.int==2}? y=.) -> ^(SHIFT["<<"] $y INT["1"])****
| ^('*' a=. b=INT {$b.int==2}?) -> ^(SHIFT["<<"] $a INT["1"])****
;****
** **
//*********************** end of Reduce.g
**
** **
**Using antlr-3.4, this generates the invalid java code:
**
//*** GENERATED WITH 3.4****
** **
public final void synpred1_Reduce_fragment() throws
RecognitionException {****
CommonTree =null;****
CommonTree =null;****
** **
** **
Using antlr-3.3, this generates:
//*** GENERATED WITH 3.3****
** **
public final void synpred1_Reduce_fragment() throws
RecognitionException { ****
CommonTree x=null;****
CommonTree y=null;
More information about the antlr-interest
mailing list