diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-12-29 12:55:26 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-12-29 12:55:26 -0500 |
commit | de4f70ffc465a40cef860b944e9afc8335e7d11b (patch) | |
tree | 6710ef8f9a6e07767e6ece949a49c50bf103423c | |
parent | 2f54e30867a5996b2c05e08c10cceff32153880f (diff) |
Octal and hexidecimal string escapes
-rw-r--r-- | src/urweb.lex | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/urweb.lex b/src/urweb.lex index 5fb767b1..d2227d16 100644 --- a/src/urweb.lex +++ b/src/urweb.lex @@ -168,6 +168,8 @@ ws = [\ \t\012]; intconst = [0-9]+; realconst = [0-9]+\.[0-9]*; notags = [^<{\n]+; +oint = [0-9][0-9][0-9]; +xint = x[0-9a-fA-F][0-9a-fA-F]; %% @@ -199,6 +201,16 @@ notags = [^<{\n]+; <STRING,CHAR> "\\t" => (str := #"\t" :: !str; continue()); <STRING,CHAR> "\n" => (newline yypos; str := #"\n" :: !str; continue()); +<STRING,CHAR> "\\" {oint} => (case StringCvt.scanString (Int.scan StringCvt.OCT) + (String.extract (yytext, 1, NONE)) of + NONE => ErrorMsg.errorAt' (pos yypos, pos yypos) "Illegal string escape" + | SOME n => str := chr n :: !str; + continue()); +<STRING,CHAR> "\\" {xint} => (case StringCvt.scanString (Int.scan StringCvt.HEX) + (String.extract (yytext, 2, NONE)) of + NONE => ErrorMsg.errorAt' (pos yypos, pos yypos) "Illegal string escape" + | SOME n => str := chr n :: !str; + continue()); <INITIAL> "#\"" => (YYBEGIN CHAR; strEnder := #"\""; strStart := pos yypos; str := []; continue()); |