[antlr-interest] How to get rid of useless nodes in AST?
Jim Idle
jimi at temporal-wave.com
Fri Nov 16 05:47:43 PST 2012
Oh. I see. The auto construction operators are fine for these cases I think.
Jim
On Nov 16, 2012, at 21:20, "Juancarlo Añez" <apalala at gmail.com> wrote:
> Sorry, fired early.
>
> subtract : modulo ('-' modulo)* -> ^(SUBTRACT modulo (modulo)* ) ;
>
>
> subtract
> :
> modulo
> ( modul
> ( '-' modulo)+ -> ^(SUBTRACT modulo+) // you don't need the
> parenthesis or the asterisk
> |
> () -> modulo
> )
> ;
>
> Cheeers,
>
> -- JA
>
> On Fri, Nov 16, 2012 at 8:47 AM, Juancarlo Añez <apalala at gmail.com> wrote:
>
>> Jarrod,
>>
>> Jim is right, but he doesn't make much of an explanation:
>>
>> subtract : modulo ('-' modulo)* -> ^(SUBTRACT modulo (modulo)* ) ;
>>
>>
>> To get rid of the unneeded tokens you can write something like:
>>
>> subtract
>> :
>>
>>
>>
>>
>> On Thu, Nov 15, 2012 at 11:56 PM, Jarrod Roberson <jarrod at vertigrated.com>wrote:
>>
>>> I asked this question on stackoverflow.com, it has many details and
>>> graphics depicting what I am trying to do.
>>>
>>>
>>> http://stackoverflow.com/questions/13409927/how-to-get-rid-of-useless-nodes-from-this-ast-tree
>>>
>>> Can anyone help me get rid of these intermediate nodes?
>>>
>>> --
>>> Jarrod Roberson
>>>
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe:
>>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>>
>>
>> --
>> Juancarlo *Añez*
>
>
>
> --
> Juancarlo *Añez*
>
> 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