@@ -160,6 +160,16 @@ hexDigit = pred isHexDigit
160160hexDigits : Lexer
161161hexDigits = some hexDigit
162162
163+||| Recognise a single octal digit
164+||| /[0-8]/
165+octDigit : Lexer
166+octDigit = pred isHexDigit
167+
168+||| Recognise one or more octal digits
169+||| /[0-8]+/
170+octDigits : Lexer
171+octDigits = some hexDigit
172+
163173||| Recognise a single alpha character
164174||| /[A-Za-z]/
165175alpha : Lexer
@@ -269,7 +279,20 @@ stringLit = quote (is '"') (escape '\\' any <|> any)
269279||| /'(\\\\.|[\^'])'/
270280charLit : Lexer
271281charLit = let q = '\'' in
272− is q <+> (escape '\\' any <|> isNot q) <+> is q
282+ is q <+> (escape '\\' (control <|> any) <|> isNot q) <+> is q
283+ where
284+ lexStr : List String -> Lexer
285+ lexStr [] = fail
286+ lexStr (t :: ts) = exact t <|> lexStr ts
287+
288+ control : Lexer
289+ control = lexStr ["NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
290+ "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
291+ "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
292+ "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"]
293+ <|> (is 'x' <+> hexDigits)
294+ <|> (is 'o' <+> octDigits)
295+ <|> digits
273296
274297||| Recognise an integer literal (possibly with a '-' prefix)
275298||| /-?[0-9]+/