[antlr-interest] Changing the order of execution of tree pattern matching rules
Loring Craymer
lgcraymer at yahoo.com
Wed Aug 1 04:11:51 PDT 2012
Look at CommonTreeNodeStream.java. You can't use ANTLR to do bottom up parsing (i. e.: LR instead of LL), but you can use the TreeNodeStream serialization ( repetitively calling LT(1) then consume()).
--Loring
>________________________________
> From: Andrew Mains <andrew.mains at oracle.com>
>To: antlr-interest at antlr.org
>Sent: Tuesday, July 31, 2012 11:59 AM
>Subject: [antlr-interest] Changing the order of execution of tree pattern matching rules
>
>Hi all,
>
>I am currently working on preprocessing an AST in order to compute some
>properties about the code and make my code generation easier. To do
>this, I'm using a tree grammar with pattern matching (filter = true).
>
>My question is this: I want to set a flag on each node of the tree in a
>bottomup manner, and then use the information from this flag in a
>topdown walk of the tree. Unfortunately for me, ANTLR does only one
>depth first walk of the tree, (sensibly) executing the topdown actions
>first, since they are performed in the preorder position. Since my
>topdown action is dependent on my bottomup action, this order doesn't
>work for me.
>
>Is there any convenient method of telling ANTLR to perform multiple DF
>walks of the tree so I can perform my bottomup action in the first walk
>and my topdown action in the second?
>
>If possible, I'd prefer to avoid splitting my grammar into two, as this
>is less convenient, but I'll do so if necessary. I am, of course, open
>to different ways of looking at the problem--this was just what made the
>most sense to me initially (and what I would do if I were walking the
>tree "by hand")
>
>Let me know if anything is unclear--I'm happy to provide more
>details/actual code if it will help.
>
>Thanks for the help!
>
>Andrew
>
>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