[antlr-interest] Re: A way to access individual expressions s tore d in ELIST?

Tiller, Michael (M.M.) mtiller at ford.com
Thu May 1 08:10:39 PDT 2003


I see some potential confusion developing here.  Perhaps Mr. Stone understands the full implications of the solution provided but just in case he hasn't, I'll provide a bit of elaboration.

The original suggestion was as follows:

elist
  : #( ELIST (e:expression
                 {
                   /*do something with expression in this action*/
                 }
      )* )
  ;

There are two important features in this solution.  The first, and most obvious, is that the expression now has a label "e" that it can be referenced by.  The second is that there is now an action associated with the parsing of *EACH* expression.  In other words, the actions contained between the {}'s will be executed as each "e" is parsed (same name, new expression).

This is what Monty was getting at, i.e. if you want to operate on the list of all expressions that are matched you need to put them in your own list and then process them at the end of the rule (after all the "e"'s have been parsed).  If you just want to know which one you are operating on at any given time, you would use a counter and increment each time through the {}'s.

I apologize if this is being pedantic, but I just wanted to make sure Mr. Stone understood the issue completely.

--
Mike

> -----Original Message-----
> From: mzukowski at yci.com [mailto:mzukowski at yci.com]
> Sent: Thursday, May 01, 2003 11:03 AM
> To: antlr-interest at yahoogroups.com
> Subject: RE: [antlr-interest] Re: A way to access individual 
> expressions
> s tore d in ELIST?
> 
> 
> Keep a counter, or put them in your own list if you want to 
> access them from
> a list.
> 
> Monty
> 
> -----Original Message-----
> From: rustydstone [mailto:rustydstone at yahoo.com]
> Sent: Wednesday, April 30, 2003 6:35 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Re: A way to access individual expressions
> store d in ELIST?
> 
> 
> --- In antlr-interest at yahoogroups.com, mzukowski at y... wrote:
> > put a label on them:
> > 
> > elist
> >        : #( ELIST (e:expression {/*do something with 
> expression in this
> > action*/})* )
> >        ;
> 
> Thanks, but how do I refer to the 1st, 2nd, etc expressions 
> in the elist?
> 
> 
> 
> 
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
> 

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list