[antlr-interest] Rewrite Problem; Rule terminates without exception.

Michael Ernst chiptv at web.de
Sun Mar 16 05:57:46 PDT 2008


Hi,

I could solve the problem by using syntactic prdicates, but there is still a
problem. When I rewrite the tree and referencing the label twice, I get no
tree duplicate attached to the tree. I thought I could duplicate nodes and
trees by referencing them more than one time in a rewrite rule (Chapter 7;
Duplicating Nodes and Trees (sample: dump : INT -> INT INT ;)).

Regards
Michael

-----Ursprüngliche Nachricht-----
Von: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] Im Auftrag von Michael Ernst
Gesendet: Freitag, 14. März 2008 20:47
An: antlr-interest at antlr.org
Betreff: [antlr-interest] Rewrite Problem; Rule terminates without
exception.

Hi,

I want to rewrite  =, +=, -= *= and /= into a better parseable tree. The
following rule terminates without any Exception, but I don’t know why. Any
ideas?


expression
            : 
            //orExpression (assignmentOperator^ expression)? // works fine,
but that’s not the desired result.
            a=orExpression
            (
              (ASSIGNMENT expression) -> ^(ASSIGNMENT $a expression)
            | (ADDITION_ASSIGNMENT expression) -> ^(ASSIGNMENT $a ^(PLUS $a
expression))
            | (MINUS_ASSIGNMENT expression) -> ^(ASSIGNMENT $a ^(MINUS $a
expression))
            | (MULTIPLY_ASSIGNMENT expression) -> ^(ASSIGNMENT $a ^(MULTIPLY
$a expression))
            | (DIVIDE_ASSIGNMENT expression) -> ^(ASSIGNMENT $a ^(DIVIDE $a
expression))
            | 
            ) // terminates without exception
            ;
            
assignmentOperator
            :           ASSIGNMENT // =
            |           ADDITION_ASSIGNMENT // +=
            |           MINUS_ASSIGNMENT // -=
            |           MULTIPLY_ASSIGNMENT // *=
            |           DIVIDE_ASSIGNMENT // /=
            ;

Thanks in advance!

Regards
Michael

______________________________________________________
Bis 50 MB Dateianhänge? Kein Problem!
http://freemail.web.de/club/landingpage.htm/?mc=025556



More information about the antlr-interest mailing list