comparison src/urweb.lex @ 1098:c023bc6ab914

Octal and hexidecimal string escapes
author Adam Chlipala <adamc@hcoop.net>
date Tue, 29 Dec 2009 12:55:26 -0500
parents 0657e5adc938
children e1cf925e2074
comparison
equal deleted inserted replaced
1097:80d048a8efe5 1098:c023bc6ab914
166 cid = [A-Z][A-Za-z0-9_]*; 166 cid = [A-Z][A-Za-z0-9_]*;
167 ws = [\ \t\012]; 167 ws = [\ \t\012];
168 intconst = [0-9]+; 168 intconst = [0-9]+;
169 realconst = [0-9]+\.[0-9]*; 169 realconst = [0-9]+\.[0-9]*;
170 notags = [^<{\n]+; 170 notags = [^<{\n]+;
171 oint = [0-9][0-9][0-9];
172 xint = x[0-9a-fA-F][0-9a-fA-F];
171 173
172 %% 174 %%
173 175
174 <INITIAL> \n => (newline yypos; 176 <INITIAL> \n => (newline yypos;
175 continue ()); 177 continue ());
197 <STRING,CHAR> "\\'" => (str := #"'" :: !str; continue()); 199 <STRING,CHAR> "\\'" => (str := #"'" :: !str; continue());
198 <STRING,CHAR> "\\n" => (str := #"\n" :: !str; continue()); 200 <STRING,CHAR> "\\n" => (str := #"\n" :: !str; continue());
199 <STRING,CHAR> "\\t" => (str := #"\t" :: !str; continue()); 201 <STRING,CHAR> "\\t" => (str := #"\t" :: !str; continue());
200 <STRING,CHAR> "\n" => (newline yypos; 202 <STRING,CHAR> "\n" => (newline yypos;
201 str := #"\n" :: !str; continue()); 203 str := #"\n" :: !str; continue());
204 <STRING,CHAR> "\\" {oint} => (case StringCvt.scanString (Int.scan StringCvt.OCT)
205 (String.extract (yytext, 1, NONE)) of
206 NONE => ErrorMsg.errorAt' (pos yypos, pos yypos) "Illegal string escape"
207 | SOME n => str := chr n :: !str;
208 continue());
209 <STRING,CHAR> "\\" {xint} => (case StringCvt.scanString (Int.scan StringCvt.HEX)
210 (String.extract (yytext, 2, NONE)) of
211 NONE => ErrorMsg.errorAt' (pos yypos, pos yypos) "Illegal string escape"
212 | SOME n => str := chr n :: !str;
213 continue());
202 214
203 <INITIAL> "#\"" => (YYBEGIN CHAR; strEnder := #"\""; strStart := pos yypos; str := []; continue()); 215 <INITIAL> "#\"" => (YYBEGIN CHAR; strEnder := #"\""; strStart := pos yypos; str := []; continue());
204 216
205 <CHAR> . => (let 217 <CHAR> . => (let
206 val ch = String.sub (yytext, 0) 218 val ch = String.sub (yytext, 0)