示例#1
0
文件: ASTPair.cs 项目: alexed1/dtrack
		/*Copy an ASTPair.  Don't call it clone() because we want type-safety */
		public ASTPair copy()
		{
			ASTPair tmp = new ASTPair();
			tmp.root = root;
			tmp.child = child;
			return tmp;
		}
示例#2
0
 /// <summary>
 /// Make an AST the root of current AST.
 /// </summary>
 /// <param name="currentAST"></param>
 /// <param name="root"></param>
 public virtual void makeASTRoot(ref ASTPair currentAST, AST root)
 {
     if (root != null)
     {
         // Add the current root as a child of new root
         root.addChild(currentAST.root);
         // The new current child is the last sibling of the old root
         currentAST.child = currentAST.root;
         currentAST.advanceChildToEnd();
         // Set the new root
         currentAST.root = root;
     }
 }
示例#3
0
 /// <summary>
 /// Add a child to the current AST
 /// </summary>
 /// <param name="currentAST">The AST to add a child to</param>
 /// <param name="child">The child AST to be added</param>
 public virtual void addASTChild(ref ASTPair currentAST, AST child)
 {
     if (child != null)
     {
         if (currentAST.root == null)
         {
             // Make new child the current root
             currentAST.root = child;
         }
         else
         {
             if (currentAST.child == null)
             {
                 // Add new child to current root
                 currentAST.root.setFirstChild(child);
             }
             else
             {
                 currentAST.child.setNextSibling(child);
             }
         }
         // Make new child the current child
         currentAST.child = child;
         currentAST.advanceChildToEnd();
     }
 }