(x | ("foo", y)) / z
void TestStage2(bool lexerMode, params Tuple <string, string, string>[] ruleTuples) { var helper = lexerMode ? (IPGCodeGenHelper) new IntStreamCodeGenHelper() : new GeneralCodeGenHelper(); var rules = new List <Pair <Rule, LNode> >(); foreach (var tuple in ruleTuples) { string ruleName = tuple.Item1, inputExpr = tuple.Item2; var node = LesLanguageService.Value.ParseSingle(inputExpr, ConsoleMessageSink.Value, ParsingMode.Expressions); var rule = new Rule(node, GSymbol.Get(ruleName), null); rules.Add(Pair.Create(rule, node)); } var parser = new StageTwoParser(helper, ConsoleMessageSink.Value); parser.Parse(rules); for (int i = 0; i < rules.Count; i++) { var rule = rules[i].A; var ruleAsString = rule.Pred.ToString(); var expected = ruleTuples[i].Item3; if (expected == null) { ConsoleMessageSink.Value.Warning(ruleTuples[i].Item1, ruleAsString); } else { AreEqual(expected, ruleAsString); } } }
void TestStage2(bool lexerMode, params Tuple<string,string,string>[] ruleTuples) { var helper = lexerMode ? (IPGCodeGenHelper)new IntStreamCodeGenHelper() : new GeneralCodeGenHelper(); var rules = new List<Pair<Rule,LNode>>(); foreach (var tuple in ruleTuples) { string ruleName = tuple.Item1, inputExpr = tuple.Item2; var node = LesLanguageService.Value.ParseSingle(inputExpr, ConsoleMessageSink.Value, ParsingMode.Expressions); var rule = new Rule(node, GSymbol.Get(ruleName), null); rules.Add(Pair.Create(rule, node)); } var parser = new StageTwoParser(helper, ConsoleMessageSink.Value); parser.Parse(rules); for (int i = 0; i < rules.Count; i++) { var rule = rules[i].A; var ruleAsString = rule.Pred.ToString(); var expected = ruleTuples[i].Item3; if (expected == null) ConsoleMessageSink.Value.Warning(ruleTuples[i].Item1, ruleAsString); else AreEqual(expected, ruleAsString); } }