Beispiel #1
0
 public void TestForNodeWithColon()
 {
     string t = "#{:for i in array[1 : 10]:}";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     ForNode f = new ForNode(tokens[0]);
 }
Beispiel #2
0
 public void TestForNodeLackInKeyword()
 {
     string t = "#{for i array[1, 2, 3]}";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     ForNode f = new ForNode(tokens[0]);
 }
Beispiel #3
0
 public void TestIfNodeNoExpr()
 {
     string t = "#{if }#{end}";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     IfNode i = new IfNode(tokens[0]);
 }
Beispiel #4
0
 public void TestEscape()
 {
     LexicalParser p = new LexicalParser();
     p.SetParseContent("##{content}");
     var l = p.Parse();
     Assert.AreEqual(TokenType.Text, l[0].TokenType);
     Assert.AreEqual(1, l.Count);
 }
Beispiel #5
0
 public void TestEndColon()
 {
     LexicalParser p = new LexicalParser();
     p.SetParseContent("#{//Comment Line.:}");
     var l = p.Parse();
     Assert.AreEqual(TokenType.Remark, l[0].TokenType);
     Assert.AreEqual(1, l.Count);
 }
Beispiel #6
0
 public void TestForNodeInvalidVarName()
 {
     string t = "#{for $ in array[1, 2, 3]}";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     ForNode f = new ForNode(tokens[0]);
 }
Beispiel #7
0
 public void TestBeginColon()
 {
     LexicalParser p = new LexicalParser();
     p.SetParseContent("#{:include \"head.tpl\"}");
     var l = p.Parse();
     Assert.AreEqual(TokenType.Include, l[0].TokenType);
     Assert.AreEqual(1, l.Count);
 }
Beispiel #8
0
        public void TestLetNodeNoExpr()
        {
            string        t  = "#{let c=   }";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var     tokens = lp.Parse();
            LetNode l      = new LetNode(tokens[0]);
        }
Beispiel #9
0
        public void TestForNodeInvalidVarName()
        {
            string        t  = "#{for $ in array[1, 2, 3]}";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var     tokens = lp.Parse();
            ForNode f      = new ForNode(tokens[0]);
        }
Beispiel #10
0
        public void TestForNodeLackInKeyword()
        {
            string        t  = "#{for i array[1, 2, 3]}";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var     tokens = lp.Parse();
            ForNode f      = new ForNode(tokens[0]);
        }
Beispiel #11
0
        public void TestIfNodeNoExpr()
        {
            string        t  = "#{if }#{end}";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var    tokens = lp.Parse();
            IfNode i      = new IfNode(tokens[0]);
        }
Beispiel #12
0
 public void TestIfNode()
 {
     string t = "#{if a}#{end}";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     IfNode i = new IfNode(tokens[0]);
     Assert.AreEqual("a", i.Expr);
 }
Beispiel #13
0
        public void TestLetNodeNoEqualOperator()
        {
            string        t  = "#{let c   tuple[x:3, y:5]}";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var     tokens = lp.Parse();
            LetNode l      = new LetNode(tokens[0]);
        }
Beispiel #14
0
        public void TestForNodeWithColon()
        {
            string        t  = "#{:for i in array[1 : 10]:}";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var     tokens = lp.Parse();
            ForNode f      = new ForNode(tokens[0]);
        }
Beispiel #15
0
 public void TestCombine()
 {
     LexicalParser p = new LexicalParser();
     p.SetParseContent("#{if c>0}positive#{end}");
     var l = p.Parse();
     Assert.AreEqual(TokenType.If, l[0].TokenType);
     Assert.AreEqual(TokenType.Text, l[1].TokenType);
     Assert.AreEqual(TokenType.End, l[2].TokenType);
     Assert.AreEqual(3, l.Count);
 }
Beispiel #16
0
 public void TestForNode()
 {
     string t = "#{ for i  in array[3  :8]}#{i }#{end}";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     ForNode f = new ForNode(tokens[0]);
     Assert.AreEqual("i", f.Var);
     Assert.AreEqual("array[3  :8]", f.Enumerable);
 }
Beispiel #17
0
        public void TestBeginColon()
        {
            LexicalParser p = new LexicalParser();

            p.SetParseContent("#{:include \"head.tpl\"}");
            var l = p.Parse();

            Assert.AreEqual(TokenType.Include, l[0].TokenType);
            Assert.AreEqual(1, l.Count);
        }
Beispiel #18
0
        public void TestEscape()
        {
            LexicalParser p = new LexicalParser();

            p.SetParseContent("##{content}");
            var l = p.Parse();

            Assert.AreEqual(TokenType.Text, l[0].TokenType);
            Assert.AreEqual(1, l.Count);
        }
Beispiel #19
0
        public void TestEndColon()
        {
            LexicalParser p = new LexicalParser();

            p.SetParseContent("#{//Comment Line.:}");
            var l = p.Parse();

            Assert.AreEqual(TokenType.Remark, l[0].TokenType);
            Assert.AreEqual(1, l.Count);
        }
Beispiel #20
0
        public void TestSimple()
        {
            LexicalParser p = new LexicalParser();

            p.SetParseContent("#{let a=3}");
            var l = p.Parse();

            Assert.AreEqual(TokenType.Let, l[0].TokenType);
            Assert.AreEqual(1, l.Count);
        }
Beispiel #21
0
        public void TestRemovePrevSpace()
        {
            LexicalParser p = new LexicalParser();
            p.SetParseContent("#{if i>5}  \r\n\ti>5\r\n#{:end}");
            var l = p.Parse();
            Assert.AreEqual(TokenType.Text, l[1].TokenType);
            Assert.AreEqual(3, l.Count);

            var text = l[1];
            Assert.AreEqual("  \r\n\ti>5", text.TokenValue);
        }
Beispiel #22
0
        public void TestIfNode()
        {
            string        t  = "#{if a}#{end}";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var    tokens = lp.Parse();
            IfNode i      = new IfNode(tokens[0]);

            Assert.AreEqual("a", i.Expr);
        }
Beispiel #23
0
        public void TestCombine()
        {
            LexicalParser p = new LexicalParser();

            p.SetParseContent("#{if c>0}positive#{end}");
            var l = p.Parse();

            Assert.AreEqual(TokenType.If, l[0].TokenType);
            Assert.AreEqual(TokenType.Text, l[1].TokenType);
            Assert.AreEqual(TokenType.End, l[2].TokenType);
            Assert.AreEqual(3, l.Count);
        }
Beispiel #24
0
        public void TestLetNode()
        {
            string        t  = "#{let c = tuple[x:3, y:5]}";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var     tokens = lp.Parse();
            LetNode l      = new LetNode(tokens[0]);

            Assert.AreEqual("c", l.VarName);
            Assert.AreEqual("tuple[x:3, y:5]", l.Expression);
        }
Beispiel #25
0
        public void TestForNode()
        {
            string        t  = "#{ for i  in array[3  :8]}#{i }#{end}";
            LexicalParser lp = new LexicalParser();

            lp.SetParseContent(t);
            var     tokens = lp.Parse();
            ForNode f      = new ForNode(tokens[0]);

            Assert.AreEqual("i", f.Var);
            Assert.AreEqual("array[3  :8]", f.Enumerable);
        }
Beispiel #26
0
        public void TestRemovePrevSpace()
        {
            LexicalParser p = new LexicalParser();

            p.SetParseContent("#{if i>5}  \r\n\ti>5\r\n#{:end}");
            var l = p.Parse();

            Assert.AreEqual(TokenType.Text, l[1].TokenType);
            Assert.AreEqual(3, l.Count);

            var text = l[1];

            Assert.AreEqual("  \r\n\ti>5", text.TokenValue);
        }
Beispiel #27
0
 public void TestSimple()
 {
     LexicalParser p = new LexicalParser();
     p.SetParseContent("#{let a=3}");
     var l = p.Parse();
     Assert.AreEqual(TokenType.Let, l[0].TokenType);
     Assert.AreEqual(1, l.Count);
 }
Beispiel #28
0
 public void TestLetNodeNoExpr()
 {
     string t = "#{let c=   }";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     LetNode l = new LetNode(tokens[0]);
 }
Beispiel #29
0
 public void TestLetNode()
 {
     string t = "#{let c = tuple[x:3, y:5]}";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     LetNode l = new LetNode(tokens[0]);
     Assert.AreEqual("c", l.VarName);
     Assert.AreEqual("tuple[x:3, y:5]", l.Expression);
 }
Beispiel #30
0
 public void TestLetNodeNoEqualOperator()
 {
     string t = "#{let c   tuple[x:3, y:5]}";
     LexicalParser lp = new LexicalParser();
     lp.SetParseContent(t);
     var tokens = lp.Parse();
     LetNode l = new LetNode(tokens[0]);
 }