[antlr-interest] [v3] parser rules are final

Jim Idle jimi at temporal-wave.com
Fri Jun 8 07:56:14 PDT 2007


Sven,

 

If you really want  to do this, then you can change the code gen
template trivially as you just need to remove the final keyword from the
java.stg code generation template for rule() then either rebuild the jar
or make sure that the template is seen first. The rules were made final
because this makes the generated java code faster.

 

However, perhaps this is better done with a custom AST node, where you
can add probably add this to the constructor?

 

Jim

 

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Sven Efftinge
Sent: Friday, June 08, 2007 1:23 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] [v3] parser rules are final

 

Hi,

 

I just updated to the latest version of V3 (have used a beta before)

Unfortunately I found that the generated parser rules are flagged as
final now.

 

I have a subclass which overwrites each rule and adds Location
information to my custom AST elements. Something like this:

 

public final Expression listLiteral() throws RecognitionException {

   updateLocation(listLiteral());

}

 

public <T extends AstElement> T updateLocation(T ele) {

      //doing stuff with input.LT(1) and input.LT(-1)

      return T;

}

 

1st question:

Is there a better way to do that generically? (without thirdparty AOP
stuff)

 

2nd Question:

Is there a way to say Antlr not to add the final keyword?

 

thanks,

Sven





 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070608/62bdac84/attachment.html 


More information about the antlr-interest mailing list