ddc-source-tetra-0.4.1.1: DDC/Source/Tetra/Lexer.hs
module DDC.Source.Tetra.Lexer
(lexModuleString)
where
import DDC.Source.Tetra.Prim
import DDC.Core.Lexer
import DDC.Data.Token
-- | Lex a string to tokens, using primitive names.
--
-- The first argument gives the starting source line number.
lexModuleString :: String -> Int -> String -> [Token (Tok Name)]
lexModuleString sourceName lineStart str
= map rn $ lexModuleWithOffside sourceName lineStart str
where rn (Token strTok sp)
= case renameTok readName strTok of
Just t' -> Token t' sp
Nothing -> Token (KJunk "lexical error") sp