Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }