[antlr-interest] Bug in generated java - @before

Joseph Gentle josephg at cse.unsw.edu.au
Mon Oct 22 07:00:52 PDT 2007


There seems to be a bug in the code generator for java.

Short version:  @before code is ignored and not placed in the  
generated code.

Long version:

I want to do this:

@options { backtrack=true; }
blah	:
{ int some_var; }
stuff* { op(some_var); };

This won't work because the generated code puts 'int some_var;' into  
an isolated if(backtrack==0) {} block.

This should work:

@options { backtrack=true; }
blah
@before { int some_var; }
: stuff* { op(some_var); };

.. but the 'int some_var;' code does not appear at all in the  
generated code.

Any ideas?

-Joseph


More information about the antlr-interest mailing list