コード例 #1
0
    //public static ParserComb.NamedNode LexxAndParse ( string arg ) { return  LexxAndParse( arg , TestMG1.TestStart ) ; }
    public static ParserComb.NamedNode LexxAndParse_incomplete_tolerant(string arg, ParserComb.Parser <Tok> .PI startProd)
    {
        arg.NLSend("lexx and parse incomplete tolerant: ");
        var parse_matches = MG.RUN_with_rest(startProd, LexxAndStripWS(arg));

        foreach (var z in parse_matches)
        {
            z.rest.NLSendRec("pmatch_rest");
        }
        return(parse_matches.First().N);
    }
コード例 #2
0
    public static ParserComb.NamedNode LexxAndParse(string arg, ParserComb.Parser <Tok> .PI startProd)
    {
        var parse_matches = MG.RUN_with_rest(startProd, LexxAndStripWS(arg));

        var pmatch_want = parse_matches.First(); // throws, if zero productions - leave this for now

        if (pmatch_want.rest.Any())
        {
            throw new Exception(" first matching prod is an incomplete parse ");
        }


        return(pmatch_want.N);
    }
コード例 #3
0
    public static ParserComb.NamedNode Scope(
        IEnumerable <PTok> toksIN,
        CH_closedScope scopeIN,
        MG.PI StartProd, Func <NamedNode, TranslationUnit> TRInstantiate,
        out TranslationUnit TRU)
    {
        var matches = MG.RUN_with_rest(StartProd, toksIN).ToArray();

        if (matches.Length.NLSend("matchlen") == 0 || matches[0].rest.Any())
        {
            throw new Exception();                                                                 // no match , or the most greedy match could not consume whole input
        }
        // MAJOR-TODO !!  ambigous grammars with epsilon consuming productions can yield
        //                an INFINITE number of alternatives , if there is a .ToArray() somewhere -> CRASH !!

        NamedNode       NN            = matches[0].N;
        TranslationUnit TR            = TRInstantiate(NN);
        var             deltaScope    = new preCH_deltaScope(scopeIN);
        var             combinedScope = TR.scope(deltaScope);

        TRU = TR;
        return(NN);
    }