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 | addaa90f75a4901481fb0f0f5890fff7e85e94db (patch) | |
tree | 6710ef8f9a6e07767e6ece949a49c50bf103423c | |
parent | f9655fb308ab1ed953788b9077be10d781bf07e0 (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()); |