public void RuleSetTest5() { string srcText = @"1, 2 3, 4 5, 6 7, 8 9, 10"; var rule = new RTRuleData(@"(\d+)\s*,\s*(\d+)", "[@{(:: var1 (+ 1 1)) (::var2 (+ var1 1)) (+ var1 var2 11)@}]", "@{(merge)@}", new RuleOptions()); RTRuleSet rules = new RTRuleSet(srcText, new[] { rule }); string result = rules.ExecuteAll(); Assert.AreEqual(result, "[16] [16] [16] [16] [16]"); }
public void RuleSetTest1() { string srcText = @"1, 2 3, 4 5, 6 7, 8 9, 10"; var rule = new RTRuleData(@"(\d+)\s*,\s*(\d+)", "", "", new RuleOptions()); RTRuleSet rules = new RTRuleSet(srcText, new[] { rule }); string result = rules.ExecuteAll(); Assert.AreEqual(result, ""); }
public void RuleSetTest7() { string srcText = @"1, 2 3, 4 5, 6 7, 8 9, 10"; var rule = new RTRuleData(@"(\d+)\s*,\s*(\d+)", "[@{ (:: add1 (+ x 1)) (add1 6) @}]", "@{(merge)@}", new RuleOptions()); RTRuleSet rules = new RTRuleSet(srcText, new[] { rule }); string result = rules.ExecuteAll(); Assert.AreEqual(result, "[7] [7] [7] [7] [7]"); }
public void TestGetFunction() { string srcText = @"goose says this is very good."; var rule = new RTRuleData(@"g(o)+[ds]", "[@{($1)@}]", "@{(merge)@}", new RuleOptions()); RTRuleSet rules = new RTRuleSet(srcText, new[] { rule }); string result = rules.ExecuteAll(); Assert.AreEqual("[o]e says this is very [o].", result); }
public string Run(string source) { RTRuleSet interpreter = new RTRuleSet(source, Rules.ToArray()); return interpreter.ExecuteAll(); }