[antlr-interest] simple treewalker newbie questions

John MccLain jmcclain at tcshealthcare.com
Fri Dec 17 09:00:54 PST 2004


Howdy,
I have finally figured out the grammar for a simple language I was given to
translate into java.
I have the lexer and parser, I am setting the function calls and operators
to be roots in the AST,
but I have a few questions:
1) (It would be best to use a description to understand the question) let's
say I had a
expression of the form 1 + f(2,3,4). Given that the + and the f would be
ASTnode roots -i.e., in the parser grammar
 I specified them as caret(^) tokens - If I apply an action to the 'f' node
that executed the function f(2,3,4), would the next step be to replace the
'f' node with the return value of the function so that the equation could
continue to be executed? If so, then how - I am assuming a tree of the form
                    --+--
                    |    |
                    1    f
                         |
                         2-3-4
I will be parsing expressions of the form f(p) where p could be a simple
expression or complex expression containing nested functions
2) each ASTNode has a value, a type, and a list. My question is about the
type (ttype); Does it represent standard java StreamTokenizer types,
standard atomic types,  or does it represent the types you specify in your
lexer or parser??

3) Are there any good treewalker tutorials out there?





John McClain
Senior Software Engineer
TCS Healthcare
jmcclain at tcshealthcare.com
(530)886-1700x235
"Before you criticize someone, walk a mile in their shoes.
That way, you'll be a mile from them, and you'll have their shoes."



 
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