Esempio n. 1
0
 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;
 }
Esempio n. 2
0
        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);
        }