From addaa90f75a4901481fb0f0f5890fff7e85e94db Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 29 Dec 2009 12:55:26 -0500 Subject: Octal and hexidecimal string escapes --- src/urweb.lex | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/urweb.lex') 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]+; "\\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()); -- cgit v1.2.3