[antlr-interest] Skip subtree in tree grammar
Jan H. van der Ven
jhvdven at xs4all.nl
Wed May 19 05:19:20 PDT 2010
Hello list,
Did someone solve this? I have a similar problem with a grammar I took
from this list (Eval.g and Simple.g). It concerns the .
ifElse
scope {
bool 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
)
);
On nested statements this fails to throw away the 'false' part of the tree.
How can I fix that?
Kind regards,
Jan
On 7-5-2009 20:38, Martijn Reuvers wrote:
> Hello!
>
> I tried it, but neither works. :/ I ran it against a snapshot of 3.1.4
> runtime that I built with mave (3.1.3 has the same errors btw):
>
> The skip option says when run:
> * Wildcard invalid as root; wildcard can itself be a tree.
>
> As for the | * option it still has a similar error as before:
> * node from after line 22:12 no viable alternative at input 'DOWN'.
>
> This is what I have for the |*
> --------------
> bool_function_content[Boolean value]
> scope {
> Boolean t;
> }
> @init {
> $bool_function_content::t = $value;
> }
> : {$bool_function_content::t != null&&
> $bool_function_content::t.booleanValue() }? => function_content*
> | .*
> ;
>
> Any thoughts?
>
> Martijn
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>
More information about the antlr-interest
mailing list