bool RunImpl(ESampleId eSampleId, string src, TextWriter Fout,out PegNode tree) { SampleInfo sample = sampleGrammars.Find(si => si.grammarId == eSampleId); if (sample.startRule.Target is PegCharParser) { try { PegCharParser pg = (PegCharParser)sample.startRule.Target; pg.Construct(src, Fout); pg.SetSource(src); pg.SetErrorDestination(Fout); bool bMatches = sample.startRule(); tree = ((PegCharParser)sample.startRule.Target).GetRoot(); return bMatches; } catch (PegException) { tree = ((PegCharParser)sample.startRule.Target).GetRoot(); return false; } } Debug.Assert(false); tree = null; return false; }
void GetGrammarFileNameAndSource(PegCharParser parser, int ruleId, out string grammarFileName, out string src) { grammarFileName = parser.GetRuleNameFromId(ruleId) + ".cs"; src = parser.GetSource(); }