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)
|
tmatch t f = match t (T . f)
|
||||||
|
|
||||||
|
|
||||||
||| [todo] escapes other than `\"` and (accidentally) `\\`
|
|
||||||
export
|
export
|
||||||
fromStringLit : String -> String
|
fromStringLit : String -> String
|
||||||
fromStringLit = pack . go . unpack . drop 1 . dropLast 1 where
|
fromStringLit = pack . go . unpack . drop 1 . dropLast 1 where
|
||||||
go : List Char -> List Char
|
go : List Char -> List Char
|
||||||
go [] = []
|
go [] = []
|
||||||
go ['\\'] = ['\\'] -- i guess???
|
go ['\\'] = ['\\'] -- i guess???
|
||||||
go ('\\' :: c :: cs) = c :: go cs
|
go ('\\' :: 'n' :: cs) = '\n' :: go cs
|
||||||
go (c :: cs) = c :: go cs
|
go ('\\' :: 't' :: cs) = '\t' :: go cs
|
||||||
|
-- [todo] others
|
||||||
|
go ('\\' :: c :: cs) = c :: go cs
|
||||||
|
go (c :: cs) = c :: go cs
|
||||||
|
|
||||||
private
|
private
|
||||||
string : Tokenizer ExtToken
|
string : Tokenizer ExtToken
|
||||||
|
|
Loading…
Reference in a new issue