Пример #1
0
        public void SimpleTest5()
        {
            string        expr = ExpressionsForTest.Expr5;
            LexicalParser lp   = new LexicalParser();

            lp.SetParseContent(expr);
            List <Token <TokenType> > tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();

            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is OperatorNode);
        }
Пример #2
0
        public void SimpleTest1()
        {
            string expr = ExpressionsForTest.Expr1;
            LexicalParser lp = new LexicalParser();
            lp.SetParseContent(expr);
            List<Token<TokenType>> tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();
            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is MethodNode);
            MethodNode mNode = ast.Root as MethodNode;
            Assert.IsTrue(mNode.Variable is SimpleNode);
        }
Пример #3
0
        public void SimpleTest11()
        {
            string expr = ExpressionsForTest.Expr11;
            LexicalParser lp = new LexicalParser();
            lp.SetParseContent(expr);
            List<Token<TokenType>> tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();
            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is OperatorNode);
            OperatorNode opNode = ast.Root as OperatorNode;
            Assert.IsTrue(opNode.Lhs is UnaryNode);
            Assert.IsTrue(opNode.Rhs is SimpleNode);
        }
Пример #4
0
        public void TernaryTest1()
        {
            string        expr = "a?(b?c:d):e";
            LexicalParser lp   = new LexicalParser();

            lp.SetParseContent(expr);
            List <Token <TokenType> > tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();

            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            TernaryNode tNode = ast.Root as TernaryNode;

            Assert.IsTrue(tNode.TrueValue is TernaryNode);
        }
Пример #5
0
        public void SimpleTest1()
        {
            string        expr = ExpressionsForTest.Expr1;
            LexicalParser lp   = new LexicalParser();

            lp.SetParseContent(expr);
            List <Token <TokenType> > tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();

            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is MethodNode);
            MethodNode mNode = ast.Root as MethodNode;

            Assert.IsTrue(mNode.Variable is SimpleNode);
        }
Пример #6
0
        public void SimpleTest3()
        {
            string        expr = ExpressionsForTest.Expr3;
            LexicalParser lp   = new LexicalParser();

            lp.SetParseContent(expr);
            List <Token <TokenType> > tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();

            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is IndexerNode);
            IndexerNode iNode = ast.Root as IndexerNode;

            Assert.IsTrue(iNode.Variable is SimpleNode);
            Assert.IsTrue((iNode.Args as ParamListNode).Values.Count == 1);
        }
Пример #7
0
        public void SimpleTest13()
        {
            string        expr = ExpressionsForTest.Expr13;
            LexicalParser lp   = new LexicalParser();

            lp.SetParseContent(expr);
            List <Token <TokenType> > tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();

            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is PropertyNode);
            PropertyNode pNode = ast.Root as PropertyNode;

            pNode = pNode.Variable as PropertyNode;
            Assert.IsTrue(pNode.Variable is IndexerNode);
        }
Пример #8
0
        public void SimpleTest11()
        {
            string        expr = ExpressionsForTest.Expr11;
            LexicalParser lp   = new LexicalParser();

            lp.SetParseContent(expr);
            List <Token <TokenType> > tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();

            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is OperatorNode);
            OperatorNode opNode = ast.Root as OperatorNode;

            Assert.IsTrue(opNode.Lhs is UnaryNode);
            Assert.IsTrue(opNode.Rhs is SimpleNode);
        }
Пример #9
0
        public void SimpleTest6()
        {
            string        expr = ExpressionsForTest.Expr6;
            LexicalParser lp   = new LexicalParser();

            lp.SetParseContent(expr);
            List <Token <TokenType> > tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();

            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is MethodNode);
            MethodNode    mNode  = ast.Root as MethodNode;
            ParamListNode plNode = mNode.Args as ParamListNode;

            Assert.IsTrue(plNode.Values.Count == 2);
        }
Пример #10
0
        public void SimpleTest8()
        {
            string        expr = ExpressionsForTest.Expr8;
            LexicalParser lp   = new LexicalParser();

            lp.SetParseContent(expr);
            List <Token <TokenType> > tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();

            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is TernaryNode);
            TernaryNode tNode = ast.Root as TernaryNode;

            Assert.IsTrue(tNode.Condition is OperatorNode);
            Assert.IsTrue(tNode.TrueValue is IndexerNode);
            Assert.IsTrue(tNode.FalseValue is SimpleNode);
        }
Пример #11
0
        public void SimpleTest13()
        {
            string expr = ExpressionsForTest.Expr13;
            LexicalParser lp = new LexicalParser();
            lp.SetParseContent(expr);
            List<Token<TokenType>> tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();
            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is PropertyNode);
            PropertyNode pNode = ast.Root as PropertyNode;
            pNode = pNode.Variable as PropertyNode;
            Assert.IsTrue(pNode.Variable is IndexerNode);
        }
Пример #12
0
        public void TernaryTest1()
        {
            string expr = "a?(b?c:d):e";
            LexicalParser lp = new LexicalParser();
            lp.SetParseContent(expr);
            List<Token<TokenType>> tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();
            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            TernaryNode tNode = ast.Root as TernaryNode;
            Assert.IsTrue(tNode.TrueValue is TernaryNode);
        }
Пример #13
0
        public void SimpleTest8()
        {
            string expr = ExpressionsForTest.Expr8;
            LexicalParser lp = new LexicalParser();
            lp.SetParseContent(expr);
            List<Token<TokenType>> tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();
            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is TernaryNode);
            TernaryNode tNode = ast.Root as TernaryNode;
            Assert.IsTrue(tNode.Condition is OperatorNode);
            Assert.IsTrue(tNode.TrueValue is IndexerNode);
            Assert.IsTrue(tNode.FalseValue is SimpleNode);
        }
Пример #14
0
        public void SimpleTest6()
        {
            string expr = ExpressionsForTest.Expr6;
            LexicalParser lp = new LexicalParser();
            lp.SetParseContent(expr);
            List<Token<TokenType>> tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();
            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is MethodNode);
            MethodNode mNode = ast.Root as MethodNode;
            ParamListNode plNode = mNode.Args as ParamListNode;
            Assert.IsTrue(plNode.Values.Count == 2);
        }
Пример #15
0
        public void SimpleTest5()
        {
            string expr = ExpressionsForTest.Expr5;
            LexicalParser lp = new LexicalParser();
            lp.SetParseContent(expr);
            List<Token<TokenType>> tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();
            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is OperatorNode);
        }
Пример #16
0
        public void SimpleTest3()
        {
            string expr = ExpressionsForTest.Expr3;
            LexicalParser lp = new LexicalParser();
            lp.SetParseContent(expr);
            List<Token<TokenType>> tokens = lp.Parse();

            SymanticParser sp = new SymanticParser();
            sp.SetParseContent(tokens);
            ExpressionLanguageAST ast = sp.Parse();

            Assert.IsTrue(ast.Root is IndexerNode);
            IndexerNode iNode = ast.Root as IndexerNode;
            Assert.IsTrue(iNode.Variable is SimpleNode);
            Assert.IsTrue((iNode.Args as ParamListNode).Values.Count == 1);
        }