[antlr-interest] Tree Walking

zgarber zgarber at yahoo.com
Tue Jan 13 07:08:21 PST 2004


Hi,

I have been using ANTLR for parsing purposes. And now I also need to 
build some expression language that will have simple operators, basic 
types and conditional statements as well as functions.

Since I'm going to use variables in my language, I want to 
use ANTLR in two steps: 
First parsing input and creating AST Tree at load time.
Second walking this tree later in runtime interpreting
the tree with actual variable data multiple times.

My idea was to evaluate conditional expressions and based on that
calculate statements.

It appeares that Actions defined for Tree Walker are executed
anyway (when matching those nodes in a tree). I can deal with
it by evaluating the result of condition passing it as argument to 
statement. However it seems to me that I'll match all nodes in 
subtree even if its actions shouldn't be executed.
Has anybody have an idea what is the performance overhead of matching
tree nodes without executing the actions?

I've also tried to use transformation and Walk Parser generated tree 
twice: first calculating conditions and generating subtree and 
secondly executing actions for that subtree. However buildAST option 
when defined for Walker causes application crash when creating the 
tree. The same thing happens in cpp\transform example.

Has anybody had a similar problem? I'm using antlr-2.7.2 (libcpp) and 
it worked perfectly when parsing things.

I'll appreciate any approach idea for my problem and specific hints 
how to generate second AST.

Regards,
Z.G.



 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list