示例#1
0
    public static void  doTreeAction(string f, AST t, string[] tokenNames)
    {
        if (t == null)
        {
            return;
        }
        if (showTree)
        {
            BaseAST.setVerboseStringConversion(true, tokenNames);
            ASTFactory factory = new ASTFactory();
            AST        r       = factory.create(0, "AST ROOT");
            r.setFirstChild(t);
            ASTFrame frame = new ASTFrame("Java AST", r);
            frame.ShowDialog();
            //frame.Visible = true;
            // System.out.println(t.toStringList());
        }
        JavaTreeParser tparse = new JavaTreeParser();

        JavaRecognizer.initializeASTFactory(tparse.getASTFactory());
        try
        {
            tparse.compilationUnit(t);
            // System.out.println("successful walk of result AST for "+f);
        }
        catch (RecognitionException e)
        {
            Console.Error.WriteLine(e.Message);
            Console.Error.WriteLine(e.StackTrace);
        }
    }
示例#2
0
        /// <summary>
        /// Get number of children of this node; if leaf, returns 0
        /// </summary>
        /// <returns>Number of children</returns>
        public int getNumberOfChildren()
        {
            BaseAST t = this.down;
            int     n = 0;

            if (t != null)
            {
                n = 1;
                while (t.right != null)
                {
                    t = t.right;
                    n++;
                }
            }
            return(n);
        }
示例#3
0
文件: BaseAST.cs 项目: 0xb1dd1e/boo
		/*Add a node to the end of the child list for this node */
		public virtual void  addChild(AST node)
		{
			if (node == null)
				return ;
			BaseAST t = this.down;
			if (t != null)
			{
				while (t.right != null)
				{
					t = t.right;
				}
				t.right = (BaseAST) node;
			}
			else
			{
				this.down = (BaseAST) node;
			}
		}
示例#4
0
        /*Add a node to the end of the child list for this node */
        public virtual void addChild(AST node)
        {
            if (node == null)
            {
                return;
            }
            BaseAST t = this.down;

            if (t != null)
            {
                while (t.right != null)
                {
                    t = t.right;
                }
                t.right = (BaseAST)node;
            }
            else
            {
                this.down = (BaseAST)node;
            }
        }
示例#5
0
 public virtual void setNextSibling(AST n)
 {
     right = (BaseAST)n;
 }
示例#6
0
 public virtual void setFirstChild(AST c)
 {
     down = (BaseAST)c;
 }
示例#7
0
 /*Remove all children */
 public virtual void removeChildren()
 {
     down = null;
 }
示例#8
0
文件: BaseAST.cs 项目: 0xb1dd1e/boo
		public virtual void  setNextSibling(AST n)
		{
			right = (BaseAST) n;
		}
示例#9
0
文件: BaseAST.cs 项目: 0xb1dd1e/boo
		public virtual void  setFirstChild(AST c)
		{
			down = (BaseAST) c;
		}
示例#10
0
文件: BaseAST.cs 项目: 0xb1dd1e/boo
		/*Remove all children */
		public virtual void  removeChildren()
		{
			down = null;
		}