Пример #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
		/*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
		public virtual void  setNextSibling(AST n)
		{
			right = (BaseAST) n;
		}
Пример #9
0
		public virtual void  setFirstChild(AST c)
		{
			down = (BaseAST) c;
		}
Пример #10
0
		/*Remove all children */
		public virtual void  removeChildren()
		{
			down = null;
		}