From: Joshua Wise <jwise@andrew.cmu.edu>
Date: Wed, 14 Jul 2010 03:50:47 +0000 (-0400)
Subject: Add escape sequences to strings.
X-Git-Url: http://git.joshuawise.com/snipe.git/commitdiff_plain/c2d3f412503bdb8a1bffbfbc249d1fec256e0fc6?hp=d4e2479e280733505420e57db97768688ceda49a

Add escape sequences to strings.
---

diff --git a/parse/l5.lex b/parse/l5.lex
index 3028a6c..32665a6 100644
--- a/parse/l5.lex
+++ b/parse/l5.lex
@@ -85,6 +85,7 @@ decnum = [0-9][0-9]*;
 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());
 
-<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> .            => (addString yytext ; lex() );