[antlr-interest] Is my brain crooked?

Terence Parr parrt at cs.usfca.edu
Sun Jun 17 00:30:19 PDT 2007


On Jun 17, 2007, at 8:41 AM, Diehl, Matthew J wrote:

> I think I saw something like this in the book, but what you could try
> (if reordering your original grammar and using predicates doesn't work
> (times_expr times_op)=>), is:  (oh yeah, page 188 of the book)
>
> math_expr
>  : (times_expr -> times_expr)
>    (
>     times_op me2=math_expr -> ^(BIN_EXPR times_op $math_expr $me2)
>    )?
>  ;

or

math_expr : times_expr (times_op^ math_expr)* ;

except BIN_EXPR must be injected into the times_op.  Can do with an  
action.

Ter



More information about the antlr-interest mailing list