]> Joshua Wise's Git repositories - snipe.git/commitdiff
Add escape sequences to strings.
authorJoshua Wise <jwise@andrew.cmu.edu>
Wed, 14 Jul 2010 03:50:47 +0000 (23:50 -0400)
committerJoshua Wise <jwise@andrew.cmu.edu>
Wed, 14 Jul 2010 03:50:47 +0000 (23:50 -0400)
parse/l5.lex

index 3028a6c9407460d83bdf00a64e5c8fc146e9b2a6..32665a64d5c69b2fefb3d0daaa76140e17bd70d4 100644 (file)
@@ -85,6 +85,7 @@ decnum = [0-9][0-9]*;
 hexnum = 0x[0-9a-fA-F][0-9a-fA-F]*;
 
 ws = [\ \t\012];
 hexnum = 0x[0-9a-fA-F][0-9a-fA-F]*;
 
 ws = [\ \t\012];
+quote = [\"];
 
 %%
 
 
 %%
 
@@ -188,5 +189,15 @@ ws = [\ \t\012];
 <COMMENT_LINE> \n     => (ParseState.newline yypos; YYBEGIN INITIAL; lex());
 <COMMENT_LINE> .      => (lex());
 
 <COMMENT_LINE> \n     => (ParseState.newline yypos; YYBEGIN INITIAL; lex());
 <COMMENT_LINE> .      => (lex());
 
-<STRING> [^\"\\]*     => (addString yytext ; lex() );
+<STRING> "\\\\"       => (addString "\\" ; lex() );
+<STRING> "\\n"        => (addString "\n" ; lex() );
+<STRING> "\\t"        => (addString "\t" ; lex() );
+<STRING> "\\\""       => (addString "\t" ; lex() );
+<STRING> "\\".        => (ErrorMsg.error (ParseState.ext (yypos,yypos))
+                              ("illegal escape sequence: \"" ^ yytext ^ "\"");
+                          lex ());
+<STRING> "\n"         => (ErrorMsg.error (ParseState.ext (yypos,yypos))
+                              ("illegal newline in the middle of the string, asshole");
+                          lex ());
 <STRING> "\""         => (YYBEGIN INITIAL; endString yypos );
 <STRING> "\""         => (YYBEGIN INITIAL; endString yypos );
+<STRING> .            => (addString yytext ; lex() );
This page took 0.026843 seconds and 4 git commands to generate.