public void Compile() { if (compiled) { return; } tokenCreators = new Dictionary <int, Func <Token> >(); for (int i = 0; i < tokenTypes.Count; i++) { if (tokenTypes[i] != null) { tokenCreators[i] = CreatorActivator(tokenTypes[i]); } } NFA nfa = NFA.Empty(); for (int i = 0; i < tokenTypes.Count; i++) { if (tokenTypes[i] == null) { continue; } IHasPattern token = (IHasPattern)tokenCreators[i](); string pattern = token.Pattern; if (pattern != null) { RegularExpression regex = new RegularExpression(pattern); NFA automaton = regex.ToNfa(); automaton.Exit.Values = new[] { i }; nfa = NFA.Or(nfa, automaton); } } dfa = nfa.ToDfa(); dfa.Minimize(); compiled = true; }