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

Jim Idle jimi at temporal-wave.com
Mon Oct 22 09:59:43 PDT 2007


Try
@init


There is also an @declarations for the C target, where you cannot initialize
and declare a variable at the same time.

Jim



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Joseph Gentle
> Sent: Monday, October 22, 2007 7:01 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Bug in generated java - @before
> 
> 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
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date:
> 10/21/2007 3:09 PM
> 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 10/21/2007
3:09 PM
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071022/5b120b22/attachment.html 


More information about the antlr-interest mailing list