internal void BuildNFA(ParserCompiler compiler)//Dictionary<SyntacticalDFAState, PredictionTreeLeaf> allLeaves, ControlledDictionary<IOilexerGrammarProductionRuleEntry, SyntacticalDFARootState> ruleDFAStates, Dictionary<IOilexerGrammarProductionRuleEntry, GrammarVocabulary> ruleGrammarLookup, GrammarSymbolSet grammarSymbolSet, ICompilerErrorCollection compilerErrorCollection) { this.nfaState = new SyntacticalNFAState(compiler.RuleDFAStates, compiler._GrammarSymbols); this.nfaState.SetInitial(this); var targetState = this.InitialPaths.GetNFAState(compiler); this.InitialPaths.BuildNFA(compiler);//allLeaves, ruleGrammarLookup, compilerErrorCollection, ruleDFAStates, (GrammarSymbolSet)grammarSymbolSet); nfaState.MoveTo(this.InitialPaths.Discriminator, targetState); }
public SyntacticalDFAState ConstructAdvanceDFA(ParserCompiler compiler)//Dictionary<SyntacticalDFAState, PredictionTreeLeaf> fullSeries, Dictionary<IOilexerGrammarProductionRuleEntry, GrammarVocabulary> ruleVocabulary, ICompilerErrorCollection compilationErrors, ControlledDictionary<IOilexerGrammarProductionRuleEntry, SyntacticalDFARootState> lookup, GrammarSymbolSet symbols) { SyntacticalNFAState resultNFANode = null; /* * * Simple for now, but I suspect it'll be more complicated * later on to provide sufficient context. * */ if (this.Veins.DFAOriginState is SyntacticalDFARootState) { resultNFANode = new SyntacticalNFARootState(this.Veins.Rule, compiler.RuleDFAStates, compiler._GrammarSymbols); } else { resultNFANode = new SyntacticalNFAState(compiler.RuleDFAStates, compiler._GrammarSymbols); } foreach (var transition in this.LookAhead.Keys) { ((PredictionTree)this.LookAhead[transition]) .BuildNFA(compiler); //fullSeries, ruleVocabulary, compilationErrors, lookup, symbols); } foreach (var transition in this.LookAhead.Keys) { ((PredictionTree)this.LookAhead[transition]). HandleReplFixups(compiler);//fullSeries, ruleVocabulary, compilationErrors, lookup, symbols); } /* * * Transition from the Variable look-ahead table * into the NFA states. * */ foreach (var transition in this.LookAhead.Keys) { var currentSet = (PredictionTree)this.LookAhead[transition]; resultNFANode.MoveTo(transition, currentSet.GetNFAState(compiler)); } /* * * Create a Deterministic automation from the results. * */ resultNFANode.SetInitial(this); return(this.DeterministicAutomata = resultNFANode.DeterminateAutomata()); }