[antlr-interest] Change type of current AST

Dimitrios Kolovos dskolovos at gmail.com
Fri Jun 6 13:17:48 PDT 2008


Hi Ter,

Unfortunately, that doesn't seem to work either.

additiveExpression
    :    multiplicativeExpression (('+'|'-')^ multiplicativeExpression 
{$additiveExpression.setType(Operator);})*
    ;

in the parser grammar produces

if ( state.backtracking==0 ) {
    $additiveExpression.setType(Operator);
}

in the parser class.

(I'm using 3.1b in case this makes a difference.)

Cheers,
Dimitrios

Terence Parr wrote:
> Use $ not #
> On Jun 6, 2008, at 6:27 AM, Dimitrios Kolovos wrote:
>
>> Hi,
>>
>> In ANTLR2 I was able to change the type of the current AST like this:
>>
>> additiveExpression
>>   :    multiplicativeExpression ((PLUS^|MINUS^) 
>> multiplicativeExpression {#additiveExpression.setType(OPERATOR);})*
>>   ;
>>
>> but I haven't been able to find how to do the same in v3. Any hints?
>>
>> Cheers,
>> Dimitrios
>
>


More information about the antlr-interest mailing list