Esempio n. 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);
        }
    }
Esempio n. 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);
        }
Esempio 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;
			}
		}
Esempio n. 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;
            }
        }
Esempio n. 5
0
 public virtual void setNextSibling(AST n)
 {
     right = (BaseAST)n;
 }
Esempio n. 6
0
 public virtual void setFirstChild(AST c)
 {
     down = (BaseAST)c;
 }
Esempio n. 7
0
 /*Remove all children */
 public virtual void removeChildren()
 {
     down = null;
 }
Esempio n. 8
0
		public virtual void  setNextSibling(AST n)
		{
			right = (BaseAST) n;
		}
Esempio n. 9
0
		public virtual void  setFirstChild(AST c)
		{
			down = (BaseAST) c;
		}
Esempio n. 10
0
		/*Remove all children */
		public virtual void  removeChildren()
		{
			down = null;
		}