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

Loring Craymer lgcraymer at yahoo.com
Thu Jul 19 10:22:08 PDT 2007


That would be a good idea--the distinction goes way
back (PCCTS, IIRC), which might explain any missing
documentation.

--Loring

--- Jim Idle <jimi at temporal-wave.com> wrote:

> 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
> 



      ____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



More information about the antlr-interest mailing list