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

Loring Craymer lgcraymer at yahoo.com
Fri Jun 8 12:02:30 PDT 2007


There is a point in having all rules be final--it
allows javacc to optimize the code, and overriding a
parser rule is rarely a good idea since you would not
want to change the sequence recognition.  It is much
better to add the support in other ways--Jim Idle's
suggestion is worth pursuing.

--Loring

--- Terence Parr <parrt at cs.usfca.edu> wrote:

> 
> On Jun 8, 2007, at 2:38 AM, Johannes Luber wrote:
> 
> > Wincent Colaiuta wrote:
> >> El 8/6/2007, a las 10:22, Sven Efftinge escribió:
> >>
> >>> 2nd Question:
> >>> Is there a way to say Antlr not to add the final
> keyword?
> >>
> >> ANTLR's output is generated using StringTemplate.
> If you dare, you  
> >> could
> >> try tweaking the Java template to tailor the
> output as you desire,  
> >> then
> >> rebuilding ANTLR. I believe this is the template
> that you'd need  
> >> to modify:
> >>
> >>
>
<http://fisheye2.cenqua.com/browse/antlr/src/org/antlr/codegen/
> 
> >> templates/Java/Java.stg?r=3682>
> >>
> >>
> >> But I imagine it's a non-trivial task, and any
> change to the template
> >> could have unanticipated ripple effects, so is
> not to be taken  
> >> lightly...
> >
> > It isn't necessary to rebuild ANTLR. The
> StringTemplate files are
> > entirely independent (with the exception of the
> data model) from  
> > ANTLR.
> > I suppose that it is only necessary to find in
> Java.stg the template
> > which is responsible for the parser code and
> remove there the final
> > keyword. A simple search for final in Java.stg
> should show the  
> > suitable one.
> 
> Yep. Easy.  Just delete final in one place and rerun
> antlr. no need  
> to build. :)
> 
> All code in antlr is generated with templates.
> 
> Ter
> 
> 



       
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/


More information about the antlr-interest mailing list