[antlr-interest] Algorithm for walking an AST tree??

jw9315 jw9315 at bris.ac.uk
Sun May 4 14:59:57 PDT 2003


Hi,
Could someone help me out with the algorithm for walking an AST tree?
Here's what I have so far...

void visit(AST tree)
{
  tree = tree.getFirstChild();
  if(treeHasChildren)
  {
    visit(tree);
  }
  else if treeHasSiblings // No Children
  {
    tree = tree.getNextSibling;
    visit(tree);
  }
}

does anyone have the algorithm or the code for doing this correctly? 
I feel I should be iterating through the children of each node?
Thanks,
Jon


 

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




More information about the antlr-interest mailing list