module Language.Haskell.Exts.Lexer
(
lexTokenStream, lexTokenStreamWithMode,
Token(..), Loc(..)
) 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 str = runParserWithMode mode lexIt str
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)