module Language.Haskell.Exts.Lexer
(
lexTokenStream, lexTokenStreamWithMode,
Token(..), Loc(..),
showToken
) where
import Language.Haskell.Exts.InternalLexer
import Language.Haskell.Exts.ParseMonad
import Language.Haskell.Exts.SrcLoc
lexTokenStream :: String -> ParseResult [Loc Token]
lexTokenStream = lexTokenStreamWithMode defaultParseMode
lexTokenStreamWithMode :: ParseMode -> String -> ParseResult [Loc Token]
lexTokenStreamWithMode mode = runParserWithMode mode lexIt
where lexIt :: P [Loc Token]
lexIt = runL go return
go :: Lex [Loc Token] [Loc Token]
go = do
ltok <- topLexer
case ltok of
Loc _ EOF -> return []
_ -> do ts <- go
return (ltok:ts)