[antlr-interest] failed predicate problem

Michael Bedward michael.bedward at gmail.com
Mon Mar 16 17:30:40 PDT 2009


Hi Annie,

> using-> before {  } ?

Oops, you're quite right.  The arrow should be before the predicate,
not after (although that page in the book is about writing output with
string templates.  For rewriting ASTs you're better off looking at the
wiki pages, for example...

http://www.antlr.org/wiki/display/ANTLR3/Tree+construction
(look for the heading Tree Construction During Tree Parsing)

In your grammar...

callExpression
 : ^(CALL_EXPRESSION memberExpression indexSuffix
*propertyReferenceSuffix* argumentSuffix*)
 ->{$memberExpression.text.equals("Math.abs")}?
mathabs(x={$argumentSuffix.text})
;

what are the asterisks for ?

Michael


More information about the antlr-interest mailing list