public static SyntacticalNFAState BuildNFA(this IRuleReferenceProductionRuleItem ruleReference, IGrammarSymbolSet symbols, ControlledDictionary <IOilexerGrammarProductionRuleEntry, SyntacticalDFARootState> lookup, Dictionary <IProductionRuleSource, IProductionRuleCaptureStructuralItem> replacements)
        {
            SyntacticalNFAState state    = new SyntacticalNFAState(lookup, (GrammarSymbolSet)symbols);
            GrammarVocabulary   movement = new GrammarVocabulary(symbols, symbols[ruleReference.Reference]);
            var stateEnd = new SyntacticalNFAState(lookup, (GrammarSymbolSet)symbols);

            state.MoveTo(movement, stateEnd);
            return(state);
        }
        public static SyntacticalNFAState BuildNFA <T, TLiteral>(this ILiteralReferenceProductionRuleItem <T, TLiteral> item, IGrammarSymbolSet symbols, ControlledDictionary <IOilexerGrammarProductionRuleEntry, SyntacticalDFARootState> lookup, Dictionary <IProductionRuleSource, IProductionRuleCaptureStructuralItem> replacements)
            where TLiteral :
        ILiteralTokenItem <T>
        {
            SyntacticalNFAState state    = new SyntacticalNFAState(lookup, (GrammarSymbolSet)symbols);
            GrammarVocabulary   movement = new GrammarVocabulary(symbols, symbols[item.Literal]);
            var stateEnd = new SyntacticalNFAState(lookup, (GrammarSymbolSet)symbols);

            state.MoveTo(movement, stateEnd);
            return(state);
        }
        public static SyntacticalNFAState BuildNFA(this ITokenReferenceProductionRuleItem tokenReference, IGrammarSymbolSet symbols, ControlledDictionary <IOilexerGrammarProductionRuleEntry, SyntacticalDFARootState> lookup, Dictionary <IProductionRuleSource, IProductionRuleCaptureStructuralItem> replacements)
        {
            SyntacticalNFAState state = new SyntacticalNFAState(lookup, (GrammarSymbolSet)symbols);
            var symbol = symbols[tokenReference.Reference];
            GrammarVocabulary movement = null;

            if (symbol is IGrammarConstantItemSymbol)
            {
                IGrammarConstantItemSymbol constantItemSymbol = (IGrammarConstantItemSymbol)symbol;
                movement = new GrammarVocabulary(symbols, (from s in symbols
                                                           let cis = s as IGrammarConstantItemSymbol
                                                                     where cis != null && cis.Source == constantItemSymbol.Source
                                                                     select cis).ToArray());
            }
            else
            {
                movement = new GrammarVocabulary(symbols, symbol);
            }
            var stateEnd = new SyntacticalNFAState(lookup, (GrammarSymbolSet)symbols);

            state.MoveTo(movement, stateEnd);
            return(state);
        }
Esempio n. 4
0
 public bool ContainsToken(GrammarVocabulary set)
 {
     return(set.Contains(token));
 }
Esempio n. 5
0
 public bool ContainsRule(GrammarVocabulary set)
 {
     return(set.Contains(rule));
 }
Esempio n. 6
0
        private static IEnumerable <Tuple <IGrammarSymbol, IIntermediateEnumFieldMember> > GetVocabularyIdentities(GrammarVocabulary vocabulary, ParserCompiler compiler)
        {
            var symbols = vocabulary.GetSymbols();
            var tokens  = symbols.Where(k => k is IGrammarTokenSymbol && (!(((IGrammarTokenSymbol)k).Source is IOilexerGrammarTokenEofEntry)));
            var rules   = symbols.Where(k => k is IGrammarRuleSymbol);

            foreach (var token in tokens)
            {
                yield return(Tuple.Create(token, compiler.LexicalSymbolModel.GetIdentitySymbolField(token)));
            }
            foreach (var rule in rules)
            {
                yield return(Tuple.Create(rule, compiler.SyntacticalSymbolModel.GetIdentitySymbolField(rule)));
            }
        }