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]); }
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]); }
public void TestIfNodeNoExpr() { string t = "#{if }#{end}"; LexicalParser lp = new LexicalParser(); lp.SetParseContent(t); var tokens = lp.Parse(); IfNode i = new IfNode(tokens[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); }
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); }
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]); }
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); }
public void TestLetNodeNoExpr() { string t = "#{let c= }"; LexicalParser lp = new LexicalParser(); lp.SetParseContent(t); var tokens = lp.Parse(); LetNode l = new LetNode(tokens[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); }
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]); }
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); }
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); }
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); }
public void TestRemoveNextSpace() { 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("\ti>5\r\n", text.TokenValue); }
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); }
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); }