[antlr-interest] backtrack=false and AST generation
Giampaolo Tomassoni
Giampaolo at Tomassoni.biz
Sun Apr 18 03:39:23 PDT 2010
Hello everybody,
I'm facing a problem for which it seems I can't find a reply in the site
docs and faqs.
I would like to parse text based on a very simple grammar (arithmetic
expressions with some boolean enhancement). Every example in the site seems
to adopt a non-LLR notation, while I would instead prefer to use
backtrack=false.
In example, I have stuff like this:
protected
expression
: (e=conditionalOrExpression -> $e) c=conditionalExpression
;
protected
conditionalExpression
: QMARK t=expression COMMA f=expression -> ???
|
;
Where conditionalExpression should possibly substitute the AST element
produced by "expression" with something like
-> ^(ITE [TheActualASTRoot] $t $f)
in case the first case is matched.
The fact is that I can't find in the site docs how to replace the top of a
parent rule, if at all possible.
Am I completely headed toward the wrong direction?
Giampaolo
More information about the antlr-interest
mailing list