Exemplo n.º 1
0
        public void ParseComplexNumbers01()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [(1i+2)/(1e2+.1i)]
        Expression  [(1i+2)/(1e2+.1i)]
            TokenOperator  [/ [6...7)]
                Group  [0...6)
                    TokenNode  [( [0...1)]
                    Expression  [1i+2]
                        TokenOperator  [+ [3...4)]
                            ComplexValue  [1i [1...3)]
                            TokenNode  [+ [3...4)]
                            NumericalValue  [2 [4...5)]
                    TokenNode  [) [5...6)]
                TokenNode  [/ [6...7)]
                Group  [7...16)
                    TokenNode  [( [7...8)]
                    Expression  [1e2+.1i]
                        ComplexValue  [1e2+.1i [8...15)]
                    TokenNode  [) [15...16)]
";

            ParserTest.VerifyParse(expected, "(1i+2)/(1e2+.1i)");
        }
Exemplo n.º 2
0
        public void ParseIfElseTest13()
        {
            string expected =
                @"GlobalScope  [Global]
    Scope  []
        TokenNode  [{ [0...1)]
        If  []
            TokenNode  [if [1...3)]
            TokenNode  [( [4...5)]
            Expression  [x > 1]
                TokenOperator  [> [7...8)]
                    Variable  [x]
                    TokenNode  [> [7...8)]
                    NumericalValue  [1 [9...10)]
            TokenNode  [) [10...11)]
            SimpleScope  [17...23)
                ExpressionStatement  [x <- 1]
                    Expression  [x <- 1]
                        TokenOperator  [<- [19...21)]
                            Variable  [x]
                            TokenNode  [<- [19...21)]
                            NumericalValue  [1 [22...23)]
            KeywordScopeStatement  []
                TokenNode  [else [25...29)]

CloseCurlyBraceExpected AfterToken [25...29)
";

            ParserTest.VerifyParse(expected, "{if (x > 1)\r\n    x <- 1\r\nelse\n");
        }
Exemplo n.º 3
0
        public void ParseWhileTest2()
        {
            string expected =
                @"GlobalScope  [Global]
    KeywordExpressionScopeStatement  []
        TokenNode  [while [0...5)]
        TokenNode  [( [5...6)]
        TokenNode  [) [12...13)]
        Scope  []
            TokenNode  [{ [14...15)]
            ExpressionStatement  [a <- a+1]
                Expression  [a <- a+1]
                    TokenOperator  [<- [18...20)]
                        Variable  [a]
                        TokenNode  [<- [18...20)]
                        TokenOperator  [+ [22...23)]
                            Variable  [a]
                            TokenNode  [+ [22...23)]
                            NumericalValue  [1 [23...24)]
            TokenNode  [} [25...26)]

RightOperandExpected Token [12...13)
";

            ParserTest.VerifyParse(expected, "while(a+b > ) { a <- a+1 }");
        }
Exemplo n.º 4
0
        public void ParseIfElseTest01()
        {
            string expected =
                @"GlobalScope  [Global]
    If  []
        TokenNode  [if [0...2)]
        TokenNode  [( [2...3)]
        Expression  [x < y]
            TokenOperator  [< [5...6)]
                Variable  [x]
                TokenNode  [< [5...6)]
                Variable  [y]
        TokenNode  [) [8...9)]
        SimpleScope  [10...18)
            ExpressionStatement  [x <- x+1]
                Expression  [x <- x+1]
                    TokenOperator  [<- [12...14)]
                        Variable  [x]
                        TokenNode  [<- [12...14)]
                        TokenOperator  [+ [16...17)]
                            Variable  [x]
                            TokenNode  [+ [16...17)]
                            NumericalValue  [1 [17...18)]
";

            ParserTest.VerifyParse(expected, "if(x < y) x <- x+1");
        }
Exemplo n.º 5
0
        public void ParseIfElseTest10()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x <- if(x < y) 1]
        Expression  [x <- if(x < y) 1]
            TokenOperator  [<- [2...4)]
                Variable  [x]
                TokenNode  [<- [2...4)]
                InlineIf  []
                    TokenNode  [if [5...7)]
                    TokenNode  [( [7...8)]
                    Expression  [x < y]
                        TokenOperator  [< [10...11)]
                            Variable  [x]
                            TokenNode  [< [10...11)]
                            Variable  [y]
                    TokenNode  [) [13...14)]
                    SimpleScope  [15...16)
                        ExpressionStatement  [1]
                            Expression  [1]
                                NumericalValue  [1 [15...16)]
    ExpressionStatement  [2]
        Expression  [2]
            NumericalValue  [2 [24...25)]

UnexpectedToken Token [19...23)
";

            ParserTest.VerifyParse(expected, "x <- if(x < y) 1 \n else 2");
        }
Exemplo n.º 6
0
        public void Indexer03()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x(a)[1]]
        Expression  [x(a)[1]]
            Indexer  [0...7)
                FunctionCall  [0...4)
                    Variable  [x]
                    TokenNode  [( [1...2)]
                    ArgumentList  [2...3)
                        ExpressionArgument  [2...3)
                            Expression  [a]
                                Variable  [a]
                    TokenNode  [) [3...4)]
                TokenNode  [[ [4...5)]
                ArgumentList  [5...6)
                    ExpressionArgument  [5...6)
                        Expression  [1]
                            NumericalValue  [1 [5...6)]
                TokenNode  [] [6...7)]
";

            ParserTest.VerifyParse(expected, "x(a)[1]");
        }
Exemplo n.º 7
0
        public void ParseExpressions01()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [a <-(grepl('^check', install) || R_check_use_install_log)]
        Expression  [a <-(grepl('^check', install) || R_check_use_install_log)]
            TokenOperator  [<- [2...4)]
                Variable  [a]
                TokenNode  [<- [2...4)]
                Group  [4...57)
                    TokenNode  [( [4...5)]
                    Expression  [grepl('^check', install) || R_check_use_install_log]
                        TokenOperator  [|| [30...32)]
                            FunctionCall  [5...29)
                                Variable  [grepl]
                                TokenNode  [( [10...11)]
                                ArgumentList  [11...28)
                                    ExpressionArgument  [11...20)
                                        Expression  ['^check']
                                            StringValue  ['^check' [11...19)]
                                        TokenNode  [, [19...20)]
                                    ExpressionArgument  [21...28)
                                        Expression  [install]
                                            Variable  [install]
                                TokenNode  [) [28...29)]
                            TokenNode  [|| [30...32)]
                            Variable  [R_check_use_install_log]
                    TokenNode  [) [56...57)]
";

            ParserTest.VerifyParse(expected, @"a <-(grepl('^check', install) || R_check_use_install_log)");
        }
Exemplo n.º 8
0
        public void ParseFunctionDefinitionTest02()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x <- function(a) return(1)]
        Expression  [x <- function(a) return(1)]
            TokenOperator  [<- [2...4)]
                Variable  [x]
                TokenNode  [<- [2...4)]
                FunctionDefinition  [5...26)
                    TokenNode  [function [5...13)]
                    TokenNode  [( [13...14)]
                    ArgumentList  [14...15)
                        ExpressionArgument  [14...15)
                            Expression  [a]
                                Variable  [a]
                    TokenNode  [) [15...16)]
                    SimpleScope  [17...26)
                        ExpressionStatement  [return(1)]
                            Expression  [return(1)]
                                FunctionCall  [17...26)
                                    Variable  [return]
                                    TokenNode  [( [23...24)]
                                    ArgumentList  [24...25)
                                        ExpressionArgument  [24...25)
                                            Expression  [1]
                                                NumericalValue  [1 [24...25)]
                                    TokenNode  [) [25...26)]
";

            ParserTest.VerifyParse(expected, "x <- function(a) return(1)");
        }
Exemplo n.º 9
0
        public void ParseFunctionDefinitionTest03()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x <- function(a b, c d, e) { }]
        Expression  [x <- function(a b, c d, e) { }]
            TokenOperator  [<- [2...4)]
                Variable  [x]
                TokenNode  [<- [2...4)]
                FunctionDefinition  [5...30)
                    TokenNode  [function [5...13)]
                    TokenNode  [( [13...14)]
                    ArgumentList  [14...25)
                        ErrorArgument  [14...18)
                            TokenNode  [a [14...15)]
                            TokenNode  [b [16...17)]
                            TokenNode  [, [17...18)]
                        ErrorArgument  [19...23)
                            TokenNode  [c [19...20)]
                            TokenNode  [d [21...22)]
                            TokenNode  [, [22...23)]
                        ExpressionArgument  [24...25)
                            Expression  [e]
                                Variable  [e]
                    TokenNode  [) [25...26)]
                    Scope  []
                        TokenNode  [{ [27...28)]
                        TokenNode  [} [29...30)]

OperatorExpected Token [16...17)
OperatorExpected Token [21...22)
";

            ParserTest.VerifyParse(expected, "x <- function(a b, c d, e) { }");
        }
Exemplo n.º 10
0
        public void ParseFunctionDefinitionTest05()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x <- function(a, b) a + b]
        Expression  [x <- function(a, b) a + b]
            TokenOperator  [<- [2...4)]
                Variable  [x]
                TokenNode  [<- [2...4)]
                FunctionDefinition  [5...25)
                    TokenNode  [function [5...13)]
                    TokenNode  [( [13...14)]
                    ArgumentList  [14...18)
                        ExpressionArgument  [14...16)
                            Expression  [a]
                                Variable  [a]
                            TokenNode  [, [15...16)]
                        ExpressionArgument  [17...18)
                            Expression  [b]
                                Variable  [b]
                    TokenNode  [) [18...19)]
                    SimpleScope  [20...25)
                        ExpressionStatement  [a + b]
                            Expression  [a + b]
                                TokenOperator  [+ [22...23)]
                                    Variable  [a]
                                    TokenNode  [+ [22...23)]
                                    Variable  [b]
";

            ParserTest.VerifyParse(expected, "x <- function(a, b) a + b");
        }
Exemplo n.º 11
0
        public void ParseFunctionDefinitionTest06()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x <- function(a) -a]
        Expression  [x <- function(a) -a]
            TokenOperator  [<- [2...4)]
                Variable  [x]
                TokenNode  [<- [2...4)]
                FunctionDefinition  [5...19)
                    TokenNode  [function [5...13)]
                    TokenNode  [( [13...14)]
                    ArgumentList  [14...15)
                        ExpressionArgument  [14...15)
                            Expression  [a]
                                Variable  [a]
                    TokenNode  [) [15...16)]
                    SimpleScope  [17...19)
                        ExpressionStatement  [-a]
                            Expression  [-a]
                                TokenOperator  [- [17...18)]
                                    TokenNode  [- [17...18)]
                                    Variable  [a]
";

            ParserTest.VerifyParse(expected, "x <- function(a) -a");
        }
Exemplo n.º 12
0
        public void ParseFunctionDefinitionTest04()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x <- function(a b) { }]
        Expression  [x <- function(a b) { }]
            TokenOperator  [<- [2...4)]
                Variable  [x]
                TokenNode  [<- [2...4)]
                FunctionDefinition  [5...22)
                    TokenNode  [function [5...13)]
                    TokenNode  [( [13...14)]
                    ArgumentList  [14...17)
                        ErrorArgument  [14...17)
                            TokenNode  [a [14...15)]
                            TokenNode  [b [16...17)]
                    TokenNode  [) [17...18)]
                    Scope  []
                        TokenNode  [{ [19...20)]
                        TokenNode  [} [21...22)]

OperatorExpected Token [16...17)
";

            ParserTest.VerifyParse(expected, "x <- function(a b) { }");
        }
Exemplo n.º 13
0
        public void ParseFunctionDefinitionTest01()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x <- function(a) { return(1) }]
        Expression  [x <- function(a) { return(1) }]
            TokenOperator  [<- [2...4)]
                Variable  [x]
                TokenNode  [<- [2...4)]
                FunctionDefinition  [5...30)
                    TokenNode  [function [5...13)]
                    TokenNode  [( [13...14)]
                    ArgumentList  [14...15)
                        ExpressionArgument  [14...15)
                            Expression  [a]
                                Variable  [a]
                    TokenNode  [) [15...16)]
                    Scope  []
                        TokenNode  [{ [17...18)]
                        ExpressionStatement  [return(1)]
                            Expression  [return(1)]
                                FunctionCall  [19...28)
                                    Variable  [return]
                                    TokenNode  [( [25...26)]
                                    ArgumentList  [26...27)
                                        ExpressionArgument  [26...27)
                                            Expression  [1]
                                                NumericalValue  [1 [26...27)]
                                    TokenNode  [) [27...28)]
                        TokenNode  [} [29...30)]
";

            ParserTest.VerifyParse(expected, "x <- function(a) { return(1) }");
        }
Exemplo n.º 14
0
        private TiplocDelete ParseDeleteRecord()
        {
            var newRecord = @"TDLNDRBES                                                                       
";

            return(ParserTest.ParseRecords(newRecord)[0] as TiplocDelete);
        }
Exemplo n.º 15
0
        public void Indexer17()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x[[1]][[2]]]
        Expression  [x[[1]][[2]]]
            Indexer  [0...11)
                Indexer  [0...6)
                    Variable  [x]
                    TokenNode  [[[ [1...3)]
                    ArgumentList  [3...4)
                        ExpressionArgument  [3...4)
                            Expression  [1]
                                NumericalValue  [1 [3...4)]
                    TokenNode  []] [4...6)]
                TokenNode  [[[ [6...8)]
                ArgumentList  [8...9)
                    ExpressionArgument  [8...9)
                        Expression  [2]
                            NumericalValue  [2 [8...9)]
                TokenNode  []] [9...11)]
";

            ParserTest.VerifyParse(expected, "x[[1]][[2]]");
        }
Exemplo n.º 16
0
        public void ParseScopeTest01()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x <- as.matrix(x)]
        Expression  [x <- as.matrix(x)]
            TokenOperator  [<- [2...4)]
                Variable  [x]
                TokenNode  [<- [2...4)]
                FunctionCall  [5...17)
                    Variable  [as.matrix]
                    TokenNode  [( [14...15)]
                    ArgumentList  [15...16)
                        ExpressionArgument  [15...16)
                            Expression  [x]
                                Variable  [x]
                    TokenNode  [) [16...17)]
    ExpressionStatement  [y <- as.matrix(y)]
        Expression  [y <- as.matrix(y)]
            TokenOperator  [<- [22...24)]
                Variable  [y]
                TokenNode  [<- [22...24)]
                FunctionCall  [25...37)
                    Variable  [as.matrix]
                    TokenNode  [( [34...35)]
                    ArgumentList  [35...36)
                        ExpressionArgument  [35...36)
                            Expression  [y]
                                Variable  [y]
                    TokenNode  [) [36...37)]
";

            ParserTest.VerifyParse(expected, "x <- as.matrix(x) \n y <- as.matrix(y)");
        }
Exemplo n.º 17
0
        public void Indexer18()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x[-1][+1]]
        Expression  [x[-1][+1]]
            Indexer  [0...9)
                Indexer  [0...5)
                    Variable  [x]
                    TokenNode  [[ [1...2)]
                    ArgumentList  [2...4)
                        ExpressionArgument  [2...4)
                            Expression  [-1]
                                NumericalValue  [-1 [2...4)]
                    TokenNode  [] [4...5)]
                TokenNode  [[ [5...6)]
                ArgumentList  [6...8)
                    ExpressionArgument  [6...8)
                        Expression  [+1]
                            NumericalValue  [+1 [6...8)]
                TokenNode  [] [8...9)]
";

            ParserTest.VerifyParse(expected, "x[-1][+1]");
        }
Exemplo n.º 18
0
        public void ParseInlineIfElseTest01()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [a <- b + if(x > 1) 1 else 2]
        Expression  [a <- b + if(x > 1) 1 else 2]
            TokenOperator  [<- [2...4)]
                Variable  [a]
                TokenNode  [<- [2...4)]
                TokenOperator  [+ [7...8)]
                    Variable  [b]
                    TokenNode  [+ [7...8)]
                    InlineIf  []
                        TokenNode  [if [9...11)]
                        TokenNode  [( [11...12)]
                        Expression  [x > 1]
                            TokenOperator  [> [14...15)]
                                Variable  [x]
                                TokenNode  [> [14...15)]
                                NumericalValue  [1 [16...17)]
                        TokenNode  [) [17...18)]
                        SimpleScope  [19...20)
                            ExpressionStatement  [1]
                                Expression  [1]
                                    NumericalValue  [1 [19...20)]
                        KeywordScopeStatement  []
                            TokenNode  [else [21...25)]
                            SimpleScope  [26...27)
                                ExpressionStatement  [2]
                                    Expression  [2]
                                        NumericalValue  [2 [26...27)]
";

            ParserTest.VerifyParse(expected, "a <- b + if(x > 1) 1 else 2");
        }
Exemplo n.º 19
0
        public void Indexer04()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x[[a+(b*c)]]]
        Expression  [x[[a+(b*c)]]]
            Indexer  [0...12)
                Variable  [x]
                TokenNode  [[[ [1...3)]
                ArgumentList  [3...10)
                    ExpressionArgument  [3...10)
                        Expression  [a+(b*c)]
                            TokenOperator  [+ [4...5)]
                                Variable  [a]
                                TokenNode  [+ [4...5)]
                                Group  [5...10)
                                    TokenNode  [( [5...6)]
                                    Expression  [b*c]
                                        TokenOperator  [* [7...8)]
                                            Variable  [b]
                                            TokenNode  [* [7...8)]
                                            Variable  [c]
                                    TokenNode  [) [9...10)]
                TokenNode  []] [10...12)]
";

            ParserTest.VerifyParse(expected, "x[[a+(b*c)]]");
        }
Exemplo n.º 20
0
        public void ParseSimpleExpressions09()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [((c+1)/2.0)]
        Expression  [((c+1)/2.0)]
            Group  [0...11)
                TokenNode  [( [0...1)]
                Expression  [(c+1)/2.0]
                    TokenOperator  [/ [6...7)]
                        Group  [1...6)
                            TokenNode  [( [1...2)]
                            Expression  [c+1]
                                TokenOperator  [+ [3...4)]
                                    Variable  [c]
                                    TokenNode  [+ [3...4)]
                                    NumericalValue  [1 [4...5)]
                            TokenNode  [) [5...6)]
                        TokenNode  [/ [6...7)]
                        NumericalValue  [2.0 [7...10)]
                TokenNode  [) [10...11)]
";

            ParserTest.VerifyParse(expected, "((c+1)/2.0)");
        }
Exemplo n.º 21
0
        public void ParseExpressionSequence01()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [a <- 1*b]
        Expression  [a <- 1*b]
            TokenOperator  [<- [2...4)]
                Variable  [a]
                TokenNode  [<- [2...4)]
                TokenOperator  [* [6...7)]
                    NumericalValue  [1 [5...6)]
                    TokenNode  [* [6...7)]
                    Variable  [b]
    ExpressionStatement  [(c+1)]
        Expression  [(c+1)]
            Group  [12...17)
                TokenNode  [( [12...13)]
                Expression  [c+1]
                    TokenOperator  [+ [14...15)]
                        Variable  [c]
                        TokenNode  [+ [14...15)]
                        NumericalValue  [1 [15...16)]
                TokenNode  [) [16...17)]
";

            string content =
                @"a <- 1*b
  (c+1)";

            ParserTest.VerifyParse(expected, content);
        }
Exemplo n.º 22
0
        public void Indexer05()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x[1](c)]
        Expression  [x[1](c)]
            FunctionCall  [0...7)
                Indexer  [0...4)
                    Variable  [x]
                    TokenNode  [[ [1...2)]
                    ArgumentList  [2...3)
                        ExpressionArgument  [2...3)
                            Expression  [1]
                                NumericalValue  [1 [2...3)]
                    TokenNode  [] [3...4)]
                TokenNode  [( [4...5)]
                ArgumentList  [5...6)
                    ExpressionArgument  [5...6)
                        Expression  [c]
                            Variable  [c]
                TokenNode  [) [6...7)]
";

            ParserTest.VerifyParse(expected, "x[1](c)");
        }
Exemplo n.º 23
0
        public void ParseIfElseTest09()
        {
            string expected =
                @"GlobalScope  [Global]
    If  []
        TokenNode  [if [0...2)]
        TokenNode  [( [2...3)]
        Expression  [x < y]
            TokenOperator  [< [5...6)]
                Variable  [x]
                TokenNode  [< [5...6)]
                Variable  [y]
        TokenNode  [) [8...9)]
        SimpleScope  [10...11)
            ExpressionStatement  [1]
                Expression  [1]
                    NumericalValue  [1 [10...11)]
    ExpressionStatement  [2]
        Expression  [2]
            NumericalValue  [2 [19...20)]

UnexpectedToken Token [14...18)
";

            ParserTest.VerifyParse(expected, "if(x < y) 1 \n else 2");
        }
Exemplo n.º 24
0
        public void Indexer12()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [(a())[x]]
        Expression  [(a())[x]]
            Indexer  [0...8)
                Group  [0...5)
                    TokenNode  [( [0...1)]
                    Expression  [a()]
                        FunctionCall  [1...4)
                            Variable  [a]
                            TokenNode  [( [2...3)]
                            TokenNode  [) [3...4)]
                    TokenNode  [) [4...5)]
                TokenNode  [[ [5...6)]
                ArgumentList  [6...7)
                    ExpressionArgument  [6...7)
                        Expression  [x]
                            Variable  [x]
                TokenNode  [] [7...8)]
";

            ParserTest.VerifyParse(expected, "(a())[x]");
        }
Exemplo n.º 25
0
        public void ParseIfElseTest02()
        {
            string expected =
                @"GlobalScope  [Global]
    If  []
        TokenNode  [if [0...2)]
        TokenNode  [( [2...3)]
        Expression  [x < y]
            TokenOperator  [< [5...6)]
                Variable  [x]
                TokenNode  [< [5...6)]
                Variable  [y]
        TokenNode  [) [8...9)]
        Scope  []
            TokenNode  [{ [10...11)]
            ExpressionStatement  [x <- x+1]
                Expression  [x <- x+1]
                    TokenOperator  [<- [14...16)]
                        Variable  [x]
                        TokenNode  [<- [14...16)]
                        TokenOperator  [+ [18...19)]
                            Variable  [x]
                            TokenNode  [+ [18...19)]
                            NumericalValue  [1 [19...20)]
            TokenNode  [} [21...22)]
";

            ParserTest.VerifyParse(expected, "if(x < y) { x <- x+1 }");
        }
Exemplo n.º 26
0
        public void Indexer14()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x[[1]](c)]
        Expression  [x[[1]](c)]
            FunctionCall  [0...9)
                Indexer  [0...6)
                    Variable  [x]
                    TokenNode  [[[ [1...3)]
                    ArgumentList  [3...4)
                        ExpressionArgument  [3...4)
                            Expression  [1]
                                NumericalValue  [1 [3...4)]
                    TokenNode  []] [4...6)]
                TokenNode  [( [6...7)]
                ArgumentList  [7...8)
                    ExpressionArgument  [7...8)
                        Expression  [c]
                            Variable  [c]
                TokenNode  [) [8...9)]
";

            ParserTest.VerifyParse(expected, "x[[1]](c)");
        }
Exemplo n.º 27
0
        public void ParseWhileTest1()
        {
            string expected =
                @"GlobalScope  [Global]
    KeywordExpressionScopeStatement  []
        TokenNode  [while [0...5)]
        TokenNode  [( [5...6)]
        Expression  [a+b > c+d]
            TokenOperator  [> [10...11)]
                TokenOperator  [+ [7...8)]
                    Variable  [a]
                    TokenNode  [+ [7...8)]
                    Variable  [b]
                TokenNode  [> [10...11)]
                TokenOperator  [+ [13...14)]
                    Variable  [c]
                    TokenNode  [+ [13...14)]
                    Variable  [d]
        TokenNode  [) [15...16)]
        Scope  []
            TokenNode  [{ [17...18)]
            ExpressionStatement  [a <- a+1]
                Expression  [a <- a+1]
                    TokenOperator  [<- [21...23)]
                        Variable  [a]
                        TokenNode  [<- [21...23)]
                        TokenOperator  [+ [25...26)]
                            Variable  [a]
                            TokenNode  [+ [25...26)]
                            NumericalValue  [1 [26...27)]
            TokenNode  [} [28...29)]
";

            ParserTest.VerifyParse(expected, "while(a+b > c+d) { a <- a+1 }");
        }
Exemplo n.º 28
0
        public void Indexer16()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x[1][2]]
        Expression  [x[1][2]]
            Indexer  [0...7)
                Indexer  [0...4)
                    Variable  [x]
                    TokenNode  [[ [1...2)]
                    ArgumentList  [2...3)
                        ExpressionArgument  [2...3)
                            Expression  [1]
                                NumericalValue  [1 [2...3)]
                    TokenNode  [] [3...4)]
                TokenNode  [[ [4...5)]
                ArgumentList  [5...6)
                    ExpressionArgument  [5...6)
                        Expression  [2]
                            NumericalValue  [2 [5...6)]
                TokenNode  [] [6...7)]
";

            ParserTest.VerifyParse(expected, "x[1][2]");
        }
Exemplo n.º 29
0
        public void ParseBuiltInsTest04()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [x[require] <- y[library]]
        Expression  [x[require] <- y[library]]
            TokenOperator  [<- [11...13)]
                Indexer  [0...10)
                    Variable  [x]
                    TokenNode  [[ [1...2)]
                    ArgumentList  [2...9)
                        ExpressionArgument  [2...9)
                            Expression  [require]
                                Variable  [require]
                    TokenNode  [] [9...10)]
                TokenNode  [<- [11...13)]
                Indexer  [14...24)
                    Variable  [y]
                    TokenNode  [[ [15...16)]
                    ArgumentList  [16...23)
                        ExpressionArgument  [16...23)
                            Expression  [library]
                                Variable  [library]
                    TokenNode  [] [23...24)]
";

            ParserTest.VerifyParse(expected, "x[require] <- y[library]");
        }
Exemplo n.º 30
0
        public void ParseDataTableAssignment()
        {
            string expected =
                @"GlobalScope  [Global]
    ExpressionStatement  [dt[, b := letters[1:3]]]
        Expression  [dt[, b := letters[1:3]]]
            Indexer  [0...23)
                Variable  [dt]
                TokenNode  [[ [2...3)]
                ArgumentList  [3...22)
                    MissingArgument  [{Missing}]
                        TokenNode  [, [3...4)]
                    ExpressionArgument  [5...22)
                        Expression  [b := letters[1:3]]
                            TokenOperator  [:= [7...9)]
                                Variable  [b]
                                TokenNode  [:= [7...9)]
                                Indexer  [10...22)
                                    Variable  [letters]
                                    TokenNode  [[ [17...18)]
                                    ArgumentList  [18...21)
                                        ExpressionArgument  [18...21)
                                            Expression  [1:3]
                                                TokenOperator  [: [19...20)]
                                                    NumericalValue  [1 [18...19)]
                                                    TokenNode  [: [19...20)]
                                                    NumericalValue  [3 [20...21)]
                                    TokenNode  [] [21...22)]
                TokenNode  [] [22...23)]
";

            ParserTest.VerifyParse(expected, "dt[, b := letters[1:3]]");
        }