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