[antlr-interest] Tree grammar conditionally run subrule
fridi
fridi70 at gmx.de
Mon Mar 1 14:49:12 PST 2010
Hi all,
I tried to skip a rule in an if-then-else construct using gated symantic
predicates.
ifElse
scope {
boolean expResult;
} :
^(
IFTHEN b = expression { $ifElse::expResult = b; }
(
{$ifElse::expResult == true}?=> actionSequence
| . // if expResult == false, no action required but eat the token
)
)
|
^(
IFTHENELSE b = expression { $ifElse::expResult = b; }
(
{$ifElse::expResult == true}? actionSequence
. // if expResult == true, call the 'then' action and 'eat'
the else action
| . actionSequence // if expResult == false, 'eat' the 'then'
action and call the else action
)
);
leeds to
Eval.g: node from after line 1:21 no viable alternative at input 'DOWN
This works well until the subrule itself is a tree (i.e. nested
if-then-else). So it seems, that the '.' does not match the whole subtree?
Thanks for any hint, fridi
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Eval.g
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20100301/0f26e2fc/attachment.pl
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Simple.g
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20100301/0f26e2fc/attachment-0001.pl
More information about the antlr-interest
mailing list