[antlr-interest] Iteration and token comparison?

Martijn Reuvers martijn.reuvers at gmail.com
Mon Feb 27 13:10:53 PST 2012


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