[antlr-interest] Storing ambiguity in the tree

Maassen, H.A.M. H.A.M.Maassen at student.tue.nl
Wed Nov 24 02:38:27 PST 2004


Hello,
 
I am following Micheal's suggestion of fixing the ambiguities in my language by doing a treewalk-pass after storing type-information in the first parse-pass.
 
What I'd like to do, though, is store code that can be interpreted in multiple ways by making a subtree for each possible interpretation. My treewalker can then simply select the appropriate one instead of having to do (potentially complicated) reformattings on the tree.
 
Example:
 
Code
  MyIdentifier(2) - 2 > 5
 
can become:
 
PROCEDURECALL
  PROC NAME
    MyIdentifier
  PARAMS
    2
CHECK
  >
    -2
    5
 
or:
 
PROCEDURECALL
  NAME
    MyIdentifier
CHECK
  >
    -
      2
      2
    5
 
or:
 
CHECK
  >
    -
      FUNCTIONCALL
        NAME
          MyIdentifier
        PARAMS
          2
      2
    5
 
...all depending on the type of MyIdentifier (I hope these trees came through in readable form).
 
It seems a lot easier to detect these possibilities during parsing (which was what I was doing before I ran into the problem of variables being defined later in the text than where they are used) than to figure out and rewrite these trees afterwards.
 
Any suggestions?
 
Thank you, Harald Maassen


 
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