[antlr-interest] Simple Tree Rewrite help

Tim Williams williamstw at gmail.com
Mon Aug 10 17:10:40 PDT 2009


Thanks Jim,
 I actually get an error "cannot write to read only attribute:
$t.type" if I use your solution.

--tim

On Wed, Jul 29, 2009 at 1:07 PM, Jim Idle<jimi at temporal-wave.com> wrote:
> Just change the type of the token and don't use rewrites. It is simpler that
> way (assuming you add comments! ;)
>
>
> (t=OR_TOK^ { $t.type = OR; } ...
>
>
> Jim
>
> On Jul 29, 2009, at 5:25 AM, Tim Williams <williamstw at gmail.com> wrote:
>
>> I'm trying to get a tree rewrite version of something like this:
>>
>> query:  LPAREN! expr (OR_TOK^ expr)+ RPAREN!;
>>
>> This seems to do what I want, but I need a tree rewrite version so
>> that I can send something other than OR_TOK as the root, namely an
>> normalized "OR" token.  I've tried:
>>
>> -> ^(OR expr expr)+;
>>
>> with no luck.
>>
>> Any help appreciated,
>>
>> Thanks,
>> --tim
>>
>> 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