Commit 7085fc83 authored by Roland Levillain's avatar Roland Levillain
Browse files

Handle octal escapes in literal strings.

	* src/Scan.hs (scanLiteralContent): Here.
parent 243bbf30
2012-01-27 Roland Levillain <roland@lrde.epita.fr>
Handle octal escapes in literal strings.
* src/Scan.hs (scanLiteralContent): Here.
2011-10-21 Roland Levillain <roland@lrde.epita.fr>
Add compatibility with GHC 7.
......
module Scan (end, scan)
where
import Data.Char (isSpace, isAlpha, isAlphaNum, isDigit, isHexDigit,
import Data.Char (isSpace, isAlpha, isAlphaNum, isDigit, isOctDigit, isHexDigit,
digitToInt, chr)
import Data.List (isPrefixOf)
......@@ -87,6 +87,14 @@ scanLiteralContent ('\\' : 'x' : h : l : cs) loc
(string, loc, tokens) -> (c : string, loc, tokens)
where c = chr ((digitToInt h) * 16 + (digitToInt l))
scanLiteralContent ('\\' : h : m : l : cs) loc
| isOctDigit h && isOctDigit m && isOctDigit l =
case scanLiteralContent cs (incc 4 loc) of
(string, loc, tokens) -> (c : string, loc, tokens)
where c = chr ((digitToInt h) * 64
+ (digitToInt m) * 8
+ (digitToInt l))
scanLiteralContent ('\\' : c : cs) loc =
error (show loc ++ ": unexpected escape: \\" ++ [c])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment