[antlr-interest] Iteration and token comparison?

Martijn Reuvers martijn.reuvers at gmail.com
Sun Mar 4 21:54:23 PST 2012


For actions: http://www.antlr.org/wiki/display/ANTLR3/Special+symbols+in+actions
 generally they are between { } like the example given before.

I am not sure what you mean with min() and max()? If they are parser
rules you probably do actions in these rules (depending on what you
need).

Martijn

On Sat, Mar 3, 2012 at 12:02 AM, Jones, Keith <kpj1 at wustl.edu> wrote:
> Thanks Martijn.
>
> 1) I've decided to go with doing it in the actions portion, but the problem is I don't really know the syntax. I haven't had much luck finding anything about it online, though.
>
> 2) But min() and max() are parser rules, wouldn't their code all under parser actions?
>
> -Keith
> ________________________________________
> From: Martijn Reuvers [martijn.reuvers at gmail.com]
> Sent: Monday, February 27, 2012 3:10 PM
> To: Jones, Keith
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Iteration and token comparison?
>
> Hello Keith,
>
> It can do a lot (write custom languages, code generation, interpreters
> etc). Go to antlr.org and read the wiki, read the get started etc.. to
> get an idea, or buy one of the books suggested there (I'd personally
> recommend the 'Language Implementation Patterns' book).
>
> 1) You can do that for example within 'actions' or do it when
> evaluating an AST, both approaches have benefits/drawbacks, again see
> wiki for these 2 terms
> 2) No, you usually do that later either in the parser's actions or
> again when evaluating the ast where you apply such logic.
>
> Regards,
> Martijn
>
>
>
> On Mon, Feb 27, 2012 at 6:23 AM, Jones, Keith <kpj1 at wustl.edu> wrote:
>> Hello,
>>
>> I'm new to ANTLR and I'm still trying to get a feel for exactly what it can do. There's two things I need to do with it, but I'm not sure how and I haven't been able to find information online about them...
>>
>> 1) Suppose I have a grammar rule COLUMN, and another rule MAX that has the format "COLUMN COLUMN+", i.e. it takes a series of two or more COLUMNs. How would I iterate over the columns of MAX and extract properties from each?
>>
>> 2) I have a grammar rule for NAMEs, each consisting of a series of LETTERs ('a' . . . 'z'). Is there any way to compare values of LETTERs in the NAMEs to do things such as sort items alphabetically?
>>
>> Thanks!
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


More information about the antlr-interest mailing list