Hi,

It is possible to rewrite something based on a predicate but not always?
What I want to do is the following (pseudo code)

^(TOMATCH)
        -> ^(RESULT1)   if TOMATCH.Text = 1
        -> ^(RESULT2)   if TOMATCH.Text = 2
        LEAVE IT UNCHANGED otherwise

The closest thing I could archive is the following code, which works in the
sense that the output-AST is correct. But this solution has the flaw that
ANTLR apparently thinks something has changed and reruns the rule (and
because nothing changed so far it match again) and so ACTION would be called
two times!

command_single_argument
        : ^(COMMAND c=CONTROL_WORD ^(BLOCK b=.)) {ACTION}
                -> {$c.Text == @"\begin"}? ^(ENVIRONMENT_BEGIN $b)
                -> {$c.Text == @"\end"}? ^(ENVIRONMENT_END $b)
                -> ^(COMMAND $c ^(BLOCK $b))
        ;

Is there a better solution?

Thanks!


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to