예제 #1
0
 public void ParseWithNoMatch()
 {
     TokenRule rule = new TokenRule("TestName");
     rule.Pattern = new Regex(@"\d+");
     SyntaxTree[] result = rule.Parse("123abc", 3);
     Assert.IsNotNull(result);
     Assert.AreEqual(0, result.Length);
 }
예제 #2
0
 public void ParseWithShorterMatch()
 {
     TokenRule rule = new TokenRule("TestName");
     rule.Pattern = new Regex(@"\d+");
     SyntaxTree[] result = rule.Parse("123abc", 1);
     Assert.IsNotNull(result);
     Assert.AreEqual(1, result.Length);
     Assert.AreEqual("23", result[0].Content);
     Assert.AreEqual(1, result[0].Index);
     Assert.AreEqual(2, result[0].Length);
     Assert.AreEqual("TestName", result[0].RuleName);
     Assert.IsNull(result[0].SyntaxTrees);
 }