[antlr-interest] Custom Tree Node, AST Enumeration or something else?

Johnson, Janeen JOHNSJA at intelsat.com
Fri Jan 12 13:35:50 PST 2007


Hi,

I have a fairly complicated parser whose purpose is to calculate and
return the results of arbitrary complex equations that may include
function calls to my Java code.  The parsing and evaluation via a tree
walker works fine.  

I have a second need to fetch a list of a specific token type in the
order they are found in this same arbitrary complex equation.  Is there
a way to write a rule or use an AST Enumeration or something else to get
all of the data of my special token type in the order they appear in the
input equation?  I'm not hanging on to the input equations and may not
need the list of special tokens every time.  I parse once and pass the
CommonASTs around to the various functions that evaluate and reevaluate
the equations as things change in my application.

If there is an example of this please point me to it.  The examples and
reading of others' problems on this list and its archive have gotten me
this far, but the multiple AST rules have usually been to start
evaluating something in another part of the tree, not fetch only a
specific type of token that may be anywhere in the tree (any number of
times).  A rule to do that would be helpful and a way to integrate it
into my existing equation parser would be great as well.

Oh, I'm parsing a line at a time so I can't read in the line twice to
parse it twice (that I know of, anyway) and "discovering" this special
token can be context dependent at times so if I can use my original
parser to find these tokens it would really help.

I'm using antlr-2.7.7.  Any suggestions or sample code locations would
be appreciated!

Janeen
Intelsat is the world's largest provider of fixed satellite services.  Real-time, constant communications with people anywhere in the world is closer, by far.  

For more information about Intelsat, visit www.intelsat.com. 

 

This email message is for the sole use of the intended recipients and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Intelsat, Ltd. and its subsidiaries.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070112/3fd1585a/attachment.html 


More information about the antlr-interest mailing list