Mercurial > urweb
changeset 1098:c023bc6ab914
Octal and hexidecimal string escapes
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 29 Dec 2009 12:55:26 -0500 |
parents | 80d048a8efe5 |
children | 118ab9641a64 |
files | src/urweb.lex |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/urweb.lex Tue Dec 29 10:28:02 2009 -0500 +++ b/src/urweb.lex Tue Dec 29 12:55:26 2009 -0500 @@ -168,6 +168,8 @@ 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 @@ <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());