public bool Run(ESampleId eSampleId, byte[] src, TextWriter Fout, out double elapsedTime, out PegNode tree) { int startTickCount = Environment.TickCount; bool bResult = RunImpl(eSampleId, src, Fout, out tree); elapsedTime = (Environment.TickCount - startTickCount); return bResult; }
internal SampleInfo(ESampleId grammarId,PegCharParser.Matcher startRule, string grammarName, string grammarDescription, string samplesDirectory, List<IParserPostProcessor> postProcessors) { this.grammarId = grammarId; this.startRule = startRule; grammarName_ = grammarName; grammarDescription_ = grammarDescription; this.samplesDirectory = samplesDirectory; postProcessors_ = postProcessors; }
bool RunImpl(ESampleId eSampleId, byte[] src, TextWriter Fout, out PegNode tree) { SampleInfo sample = sampleGrammars.Find(si => si.grammarId == eSampleId); if (sample.startRule.Target is PegByteParser) { try { PegByteParser pg = (PegByteParser)sample.startRule.Target; pg.Construct(src, Fout); bool bMatches = sample.startRule(); tree = ((PegByteParser)sample.startRule.Target).GetRoot(); return bMatches; } catch (PegException) { tree = ((PegByteParser)sample.startRule.Target).GetRoot(); return false; } } Debug.Assert(false); tree = null; return false; }
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); }