add \n and \t escapes to the lexer
This commit is contained in:
parent
d4639a35c6
commit
90cdcfe4da
1 changed files with 7 additions and 5 deletions
|
@ -71,15 +71,17 @@ tmatch : Lexer -> (String -> Token) -> Tokenizer ExtToken
|
|||
tmatch t f = match t (T . f)
|
||||
|
||||
|
||||
||| [todo] escapes other than `\"` and (accidentally) `\\`
|
||||
export
|
||||
fromStringLit : String -> String
|
||||
fromStringLit = pack . go . unpack . drop 1 . dropLast 1 where
|
||||
go : List Char -> List Char
|
||||
go [] = []
|
||||
go ['\\'] = ['\\'] -- i guess???
|
||||
go ('\\' :: c :: cs) = c :: go cs
|
||||
go (c :: cs) = c :: go cs
|
||||
go [] = []
|
||||
go ['\\'] = ['\\'] -- i guess???
|
||||
go ('\\' :: 'n' :: cs) = '\n' :: go cs
|
||||
go ('\\' :: 't' :: cs) = '\t' :: go cs
|
||||
-- [todo] others
|
||||
go ('\\' :: c :: cs) = c :: go cs
|
||||
go (c :: cs) = c :: go cs
|
||||
|
||||
private
|
||||
string : Tokenizer ExtToken
|
||||
|
|
Loading…
Reference in a new issue