Esempio n. 1
0
 /// <summary>
 /// Make an AST the root of current AST.
 /// </summary>
 /// <param name="currentAST"></param>
 /// <param name="root"></param>
 public virtual void  makeASTRoot(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;
     }
 }
Esempio n. 2
0
    public bool testHeteroTreeDup()
    {
        factory = new ASTFactory();
        factory.setMaxNodeType(49);
        // create a tree and try to dup:
        // ( [type 1] [type 2] ( [type 49] [type 3 #2] ) [type 3] )
        AST x   = factory.create(1, "[type 1]", "MyAST");     // will be root
        AST y   = factory.create(2, "[type 2]", "MyAST");
        AST z   = factory.create(3, "[type 3]", "MyAST");
        AST sub = factory.create(49, "[type 49]", "ASTType49");

        sub.addChild(factory.create(3, "[type 3 #2]", "MyAST"));
        AST t     = factory.make(new AST[] { x, y, sub, z });
        AST dup_t = factory.dupList(t);
        // check structure
        bool a = dup_t.EqualsList(t);
        // check types
        bool b = equalsNodeTypesList(t, dup_t);

        return(a && b);
    }
Esempio n. 3
0
 /// <summary>
 /// Make an AST the root of current AST.
 /// </summary>
 /// <param name="currentAST"></param>
 /// <param name="root"></param>
 public virtual void makeASTRoot(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;
     }
 }