Пример #1
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);
    }
Пример #2
0
    public static ParserComb.NamedNode ScopeAndType(string src, CH_closedScope scopeIN, MG.PI StartProd, Func <ParserComb.NamedNode, TranslationUnit> TRInstantiate)
    {
        ParserComb.NamedNode NN = LexxAndParse_incomplete_tolerant(src, StartProd);

        // TR constructors do not provide a uniform interface because there is no need for it
        TranslationUnit TR            = TRInstantiate(NN);
        var             deltaScope    = new preCH_deltaScope(scopeIN);
        var             combinedScope = TR.scope(deltaScope);

        return(NN);
    }
Пример #3
0
    public static ParserComb.NamedNode ScopeAndType(IEnumerable <PTok> toksIN, CH_closedScope scopeIN, MG.PI StartProd, Func <NamedNode, TranslationUnit> TRInstantiate)
    {
        TranslationUnit TR;
        var             NN = Scope(toksIN, scopeIN, StartProd, TRInstantiate, out TR);

        return(NN);
    }