getAST() public method

public getAST ( ) : ProgrammingLanguageNr1.AST
return ProgrammingLanguageNr1.AST
Beispiel #1
0
        private AST Parse(List <Token> tokens)
        {
            Parser parser = new Parser(tokens, m_compileTimeErrorHandler);

            parser.process();
            AST ast = parser.getAST();

            return(ast);
        }
        public void BasicEvaluation()
        {
            Tokenizer tokenizer = new Tokenizer(s_errorHandler, true);
            List<Token> tokens = tokenizer.process(File.OpenText("code9.txt"));

            Parser parser = new Parser(tokens, s_errorHandler);
            parser.process();

            AST root = parser.getAST();
            AST expressionTree = root.getChild(0).getChild(0);

            ExpressionEvaluator e1 = new ExpressionEvaluator(expressionTree);
            Assert.AreEqual(26, e1.getValue());
        }
        public void BasicEvaluation()
        {
            Tokenizer    tokenizer = new Tokenizer(s_errorHandler, true);
            List <Token> tokens    = tokenizer.process(File.OpenText("code9.txt"));

            Parser parser = new Parser(tokens, s_errorHandler);

            parser.process();

            AST root           = parser.getAST();
            AST expressionTree = root.getChild(0).getChild(0);

            ExpressionEvaluator e1 = new ExpressionEvaluator(expressionTree);

            Assert.AreEqual(26, e1.getValue());
        }
        public void HandleNegativeNumbers()
        {
            Tokenizer    tokenizer = new Tokenizer(s_errorHandler, true);
            List <Token> tokens    = tokenizer.process(File.OpenText("code10.txt"));

            Parser parser = new Parser(tokens, s_errorHandler);

            parser.process();

            AST root           = parser.getAST();
            AST expressionTree = root.getChild(0).getChild(0);

            ExpressionEvaluator e = new ExpressionEvaluator(expressionTree);

            Assert.AreEqual(-5, e.getValue());
        }
Beispiel #5
0
 private AST Parse(List<Token> tokens)
 {
     Parser parser = new Parser(tokens, m_compileTimeErrorHandler);
     parser.process();
     AST ast = parser.getAST();
     return ast;
 }
        public void HandleNegativeNumbers()
        {
            Tokenizer tokenizer = new Tokenizer(s_errorHandler, true);
            List<Token> tokens = tokenizer.process(File.OpenText("code10.txt"));

            Parser parser = new Parser(tokens, s_errorHandler);
            parser.process();

            AST root = parser.getAST();
            AST expressionTree = root.getChild(0).getChild(0);

            ExpressionEvaluator e = new ExpressionEvaluator(expressionTree);
            Assert.AreEqual(-5, e.getValue());
        }