[antlr-interest] Can't see the wood (@init and @after)

Jim Idle jimi at temporal-wave.com
Thu Jul 19 10:11:20 PDT 2007


I did wonder about that. Someone convinced me that the @init code wasn't
being protected and I blindly believed them and 'fixed' it in my current
source. Perhaps I should unfix this.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Loring Craymer
> Sent: Thursday, July 19, 2007 10:06 AM
> To: Paul Keir; antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Can't see the wood (@init and @after)
> 
> This is a design feature:  most actions are not
> executed in guessing mode, but init actions are
> executed to establish semantic context.  That way,
> semantic predicates can be made to work even when
> guessing.  Likewise, it may be necessary to reset
> semantic context on exiting a rule.  Ter probably has
> this clearly documented somewhere--someone else can
> cite the references.
> 
> --Loring
> 
> 
> --- Paul Keir <paul at paulkeir.com> wrote:
> 
> > Hi Susan,
> >
> > I tried it again just to be sure, and got the same
> > result. If in the C.g
> > file of the C project from the java ANTLR examples,
> > I augment line 354's
> > 'expression' rule with two println calls, i.e.
> >
> > expression
> >
> > @init { System.out.println("a"); }
> >     : { System.out.println(" b"); }
> > assignment_expression (','
> > assignment_expression)*
> >     ;
> >
> > And then build and run the generated parser on the
> > 'input' data, I find
> > that I get a lot more letter 'a's output than letter
> > 'b's. I don't
> > understand why that is, but at least I have this
> > example to hopefully
> > learn from.
> >
> > It's interesting that you can't repeat this. Perhaps
> > someone else can,
> > or help me to an understanding.
> >
> > Cheers,
> > Paul
> >
> >
> 
> 
> 
> 
>
_______________________________________________________________________
> _____________
> Get the Yahoo! toolbar and be alerted to new email wherever you're
> surfing.
> http://new.toolbar.yahoo.com/toolbar/features/mail/index.php


More information about the antlr-interest mailing list