# HG changeset patch # User Adam Chlipala # Date 1262109326 18000 # Node ID c023bc6ab914ea8f9f63be22d465f0b39cc841f8 # Parent 80d048a8efe58b29b26b5875f49964d644449c43 Octal and hexidecimal string escapes diff -r 80d048a8efe5 -r c023bc6ab914 src/urweb.lex --- 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 @@ "\\t" => (str := #"\t" :: !str; continue()); "\n" => (newline yypos; str := #"\n" :: !str; continue()); + "\\" {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()); + "\\" {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()); "#\"" => (YYBEGIN CHAR; strEnder := #"\""; strStart := pos yypos; str := []; continue());