Loading ...
Sorry, an error occurred while loading the content.

14619simple treewalker newbie questions

Expand Messages
  • John MccLain
    Dec 17, 2004
    • 0 Attachment
      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@...
      (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."