[antlr-interest] Problem with AST rewrite

Emond Papegaaij e.papegaaij at student.utwente.nl
Sat Aug 5 02:38:22 PDT 2006


Hello,

The attached grammar produces incorrect code (v3b3), which gives the following 
compile error:
  TPLLogic.java:203: cannot find symbol
  symbol  : variable list_SEMI
  location: class TPLLogic
                      list_SEMI.add(SEMI6);
                      ^

It seems to be caused by the usage of ';' in the first rule, while the second 
rule uses 'SEMI'. Is it allowed to mix these two in a single grammar?

Best regards,
Emond Papegaaij
-------------- next part --------------
grammar TPLLogic;

options { output = AST; }
tokens { IFACE_METHOD; }

nodeDecl: ( '{' body '}' | ';' );

body
	: 'iface' (SEMI | '{' METHOD_BODY_ACTION '}')
		-> ^(IFACE_METHOD METHOD_BODY_ACTION?)
	;

SEMI: ';' ;
METHOD_BODY_ACTION: 'body';
WS: ( ' ' | '\t' | '\f' | '\r' | '\n')+ { channel=99; } ;


More information about the antlr-interest mailing list