module Language.Lexer.Tlex (
    module Language.Lexer.Tlex.Syntax,
    module Language.Lexer.Tlex.Runner,
    module Language.Lexer.Tlex.Data.InputString,
    buildRunner,
) where

import           Language.Lexer.Tlex.Data.InputString
import           Language.Lexer.Tlex.Prelude
import           Language.Lexer.Tlex.Runner
import           Language.Lexer.Tlex.Syntax

import qualified Language.Lexer.Tlex.Machine.NFA          as NFA
import qualified Language.Lexer.Tlex.Pipeline.Dfa2Runner  as TlexPipeline
import qualified Language.Lexer.Tlex.Pipeline.MinDfa      as TlexPipeline
import qualified Language.Lexer.Tlex.Pipeline.Nfa2Dfa     as TlexPipeline
import qualified Language.Lexer.Tlex.Pipeline.Scanner2Nfa as TlexPipeline


buildRunner :: Enum e => Scanner e a -> Runner e a
buildRunner :: forall e a. Enum e => Scanner e a -> Runner e a
buildRunner Scanner e a
scanner =
    let nfa :: NFA a
nfa = forall m. NFABuilder m () -> NFA m
NFA.buildNFA do forall e m. Enum e => Scanner e m -> NFABuilder m ()
TlexPipeline.scanner2Nfa Scanner e a
scanner
        dfa :: DFA a
dfa = forall a. NFA a -> DFA a
TlexPipeline.nfa2Dfa NFA a
nfa
        minDfa :: DFA a
minDfa = forall a. DFA a -> DFA a
TlexPipeline.minDfa DFA a
dfa
    in forall e a. Enum e => DFA a -> Runner e a
TlexPipeline.dfa2Runner DFA a
minDfa