[antlr-interest] How to get rid of useless nodes in AST?

Jim Idle jimi at temporal-wave.com
Thu Nov 15 20:33:32 PST 2012


Well, you are putting them in there yourself - just don't!

Creating node tokes like MULTIPLY does not make sense. Remove the
'literals' and create:

MULTIPLY: '*';

Then:

multiply: unary (MULTIPLY^ unary)* ;

and so on. The redundant tokens are only there because you are putting
them there.

Doctor, doctor - I broke my arm in three places. Don't go to those places
again. :)

Jim




-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jarrod Roberson
Sent: Friday, November 16, 2012 12:26 PM
To: Antlr Interest
Subject: [antlr-interest] How to get rid of useless nodes in AST?

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-node
s-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


More information about the antlr-interest mailing list