Example #1
0
    public bool testDefaultCreate()
    {
        factory = new ASTFactory();
        AST t = factory.create();

        return(checkNode(t, typeof(CommonAST), Token.INVALID_TYPE));
    }
Example #2
0
	public bool testSpecificHomoCreate() {
		factory = new ASTFactory();
		factory.setASTNodeType("MyAST");
		AST t = factory.create();
		factory.setASTNodeType("antlr.CommonAST"); // put it back
		return checkNode(t, typeof(MyAST), Token.INVALID_TYPE);
	}
Example #3
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();
     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);
     }
 }
Example #4
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);
        }
    }
 private void initializeFactory()
 {
     if (astFactory == null)
     {
         astFactory = new ASTFactory();
     }
     initializeASTFactory(astFactory);
 }
Example #6
0
    public bool testSpecificHomoCreate()
    {
        factory = new ASTFactory();
        factory.setASTNodeType("MyAST");
        AST t = factory.create();

        factory.setASTNodeType("antlr.CommonAST");         // put it back
        return(checkNode(t, typeof(MyAST), Token.INVALID_TYPE));
    }
Example #7
0
	public bool testNodeDup() {
		factory = new ASTFactory();
		factory.setMaxNodeType(49);
		AST t = factory.create();
		bool a = t.Equals(factory.dup(t));
		bool b = !t.Equals(null);
		AST u = factory.create(49,"","ASTType49");
		bool c = checkNode(factory.dup(u),typeof(ASTType49), 49);
		bool d = u.Equals(factory.dup(u));
		return a&&b&&c&&d;
	}
Example #8
0
	public bool testDynamicHeteroCreate() {
		factory = new ASTFactory();
		factory.setMaxNodeType(55);
		factory.setTokenTypeASTNodeType(49,"ASTType49");
		AST t = factory.create(49);
		bool a = checkNode(t, typeof(ASTType49), 49);
		AST u = factory.create(55);
		bool b = checkNode(u, typeof(CommonAST), 55);
		AST v = factory.create(49,"","MyAST");
		bool c = checkNode(v, typeof(MyAST), 49);
		return a&&b&&c;
	}
Example #9
0
    public bool testNodeDup()
    {
        factory = new ASTFactory();
        factory.setMaxNodeType(49);
        AST  t = factory.create();
        bool a = t.Equals(factory.dup(t));
        bool b = !t.Equals(null);
        AST  u = factory.create(49, "", "ASTType49");
        bool c = checkNode(factory.dup(u), typeof(ASTType49), 49);
        bool d = u.Equals(factory.dup(u));

        return(a && b && c && d);
    }
Example #10
0
    public bool testDynamicHeteroCreate()
    {
        factory = new ASTFactory();
        factory.setMaxNodeType(55);
        factory.setTokenTypeASTNodeType(49, "ASTType49");
        AST  t = factory.create(49);
        bool a = checkNode(t, typeof(ASTType49), 49);
        AST  u = factory.create(55);
        bool b = checkNode(u, typeof(CommonAST), 55);
        AST  v = factory.create(49, "", "MyAST");
        bool c = checkNode(v, typeof(MyAST), 49);

        return(a && b && c);
    }
Example #11
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;
	}
Example #12
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);
    }
Example #13
0
 public TestASTFactory()
 {
     factory = new ASTFactory();
     factory.setMaxNodeType(56);
 }
Example #14
0
 /// <summary>
 /// Specify an object with support code (shared by Parser and TreeParser.
 /// Normally, the programmer does not play with this, using
 /// <see cref="setASTNodeClass"/> instead.
 /// </summary>
 /// <param name="f"></param>
 public virtual void  setASTFactory(ASTFactory f)
 {
     astFactory = f;
 }
Example #15
0
		/*Specify an object with support code (shared by
		*  Parser and TreeParser.  Normally, the programmer
		*  does not play with this, using setASTNodeType instead.
		*/
		public virtual void  setASTFactory(ASTFactory f)
		{
			astFactory = f;
		}
 public bool testDefaultCreate()
 {
     factory = new ASTFactory();
     AST t = factory.create();
     return checkNode(t, typeof(CommonAST), Token.INVALID_TYPE);
 }
 public TestASTFactory()
 {
     factory = new ASTFactory();
     factory.setMaxNodeType(56);
 }
 static public void initializeASTFactory(ASTFactory factory)
 {
     factory.setMaxNodeType(38);
 }
Example #19
0
	private void initializeFactory()
	{
		if (astFactory == null)
		{
			astFactory = new ASTFactory();
		}
		initializeASTFactory( astFactory );
	}
Example #20
0
	static public void initializeASTFactory( ASTFactory factory )
	{
		factory.setMaxNodeType(11);
	}