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); }
public bool ContainsToken(GrammarVocabulary set) { return(set.Contains(token)); }
public bool ContainsRule(GrammarVocabulary set) { return(set.Contains(rule)); }
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))); } }