[antlr-interest] Re: Calc example LPAREN/RPAREN

Terence Parr parrt at jguru.com
Tue Dec 25 12:07:37 PST 2001


On Monday, December 24, 2001, at 09:28  PM, kemmerzehl wrote:
> Ignore previous message, after some sleep i conquered it. I must say
> it was alot easier than i thought. my parser now looks like this:
>
> class CalcParser extends Parser;
> options {
>     buildAST = true;   // uses CommonAST by default
> }
> formula: expr SEMI!
>     ;
> expr:   mexpr (PLUS^ mexpr)*
>     ;
> mexpr
>     :   atom (STAR^ atom)*
>     ;
> atom:   (INT|pexpr)
>     ;
> pexpr: LPAREN! expr RPAREN!
>     ;
>
> ..simple!

yup.

> Although, i am still a little confused as to why the LPAREN and
> RPAREN tokens were there in the first place, but that is beside the
> point.

I probably just left over some cut-n-paste stuff from another lexer.

>
> Sorry to be a bother and thanks Terence this is really quite cool!

Glad it is of use to you!

Terence
--
Chief Scientist & Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org


 

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



More information about the antlr-interest mailing list