ANTLR expressions rewrite intermediate tree
        Posted  
        
            by user313856
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user313856
        
        
        
        Published on 2010-04-11T10:47:36Z
        Indexed on 
            2010/04/11
            10:53 UTC
        
        
        Read the original article
        Hit count: 272
        
For expressions like 3+4 I would like to use the value 7 in an intermediate representation tree.
I cannot work out how to get the returns value into a rewrite rule.
expression returns [int v]: etc.
How do I get expression.v into WR? At the moment I get (+ 3 4), I want (7)
|^( WRITE c=expression) -> ^(WRINT ^(INTC ^($c))
the next step is to emit 7 in an assembler.
© Stack Overflow or respective owner