index
 1  /************************************************************
 2  * file: SyntaxTree.h
 3  * date: 2006-04-12
 4  * author: ideawu
 5  * describe: none; SyntaxTree
 6  *************************************************************/
 7
 8  #include "common.h"
 9  #include "SyntaxTreeNode.h"
10
11  class SyntaxTree{
12  private:
13      SyntaxTreeNode *root;
14      void display(SyntaxTreeNode *n, int tabcount, FILE *fo=stdout);
15
16  public:
17      SyntaxTree(TokenType t, int val=0);
18      // set root node with n.
19      SyntaxTree(SyntaxTreeNode *n);
20      SyntaxTree(SyntaxTree *tree);
21      SyntaxTree();   // with root.type = ERROR
22      ~SyntaxTree();
23
24      void display(FILE *fo=stdout);
25
26      void setRootNode();
27      void setRootNode(TokenType t, int val=0);
28      // set root node with n.
29      void setRootNode(SyntaxTreeNode *n);
30
31      void addLeft(TokenType t, int val=0);
32      // add the subtree n to this tree's left
33      void addLeft(SyntaxTree *n);
34
35      void addRight(TokenType t, int val=0);
36      // add the subtree n to this tree's right
37      void addRight(SyntaxTree *n);
38
39      void addChild3(TokenType t, int val=0);
40      // add the subtree n to this tree's child3
41      void addChild3(SyntaxTree *n);
42
43      SyntaxTreeNode* getRootNode();
44
45      SyntaxTree* getLeft();
46      SyntaxTree* getRight();
47      SyntaxTree* getChild3();
48
49  };
50
51
52