Example #1
0
        private Lexer(RegEx <char>[] regexCategories, string lexerName, IReadOnlyCollection <string> regexes)
        {
            _atomicCategoryLimit = (uint)regexCategories.Length;
            _nextCategory        = _atomicCategoryLimit + 1;
            if (regexCategories.Length == 0)
            {
                var dfa = DfaUtils.MakeEmptyLanguageDfa <char>();
                _engine = CompileLexer(dfa, lexerName, regexes);
                if (_engine == null)
                {
                    _dfa = dfa;
                }
                return;
            }
            var lastDfa = MakeRegexDfa(regexCategories[0], 1).Minimized <RegExDfa <char>, DFAState <char>, char>();

            DfaUtils.DfaStatesConcpetCheck <char> .CheckDfaStates(lastDfa);

            var handler = lexerName == null ? (DfaUtils.AmbiguityHandler)GetProductAccepting : GetCompiledAccepting;

            for (uint i = 1; i < regexCategories.Length; ++i)
            {
                lastDfa =
                    DfaUtils
                    .MakeMinimizedProductDfa
                    <DfaUtils.MinimizedDfa <char>, DfaUtils.MinimizedDfaState <char>, RegExDfa <char>, DFAState <char>,
                     char>(lastDfa, MakeRegexDfa(regexCategories[i], i + 1), handler);
            }
            if (_canBeCompiled)
            {
                _engine = CompileLexer(lastDfa, lexerName, regexes);
            }
            if (_engine == null)
            {
                _dfa = lastDfa;
            }
        }
Example #2
0
 private static ProxyLexer CompileLexer(DfaUtils.MinimizedDfa <char> dfa, string lexerName,
                                        IReadOnlyCollection <string> regexes)
 {
     return(LexerCompiler.CompileLexer <DfaUtils.MinimizedDfa <char>, DfaUtils.MinimizedDfaState <char> >(dfa,
                                                                                                          lexerName, regexes));
 }