From c2d3f412503bdb8a1bffbfbc249d1fec256e0fc6 Mon Sep 17 00:00:00 2001 From: Joshua Wise Date: Tue, 13 Jul 2010 23:50:47 -0400 Subject: [PATCH] Add escape sequences to strings. --- parse/l5.lex | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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]; \n => (ParseState.newline yypos; YYBEGIN INITIAL; lex()); . => (lex()); - [^\"\\]* => (addString yytext ; lex() ); + "\\\\" => (addString "\\" ; lex() ); + "\\n" => (addString "\n" ; lex() ); + "\\t" => (addString "\t" ; lex() ); + "\\\"" => (addString "\t" ; lex() ); + "\\". => (ErrorMsg.error (ParseState.ext (yypos,yypos)) + ("illegal escape sequence: \"" ^ yytext ^ "\""); + lex ()); + "\n" => (ErrorMsg.error (ParseState.ext (yypos,yypos)) + ("illegal newline in the middle of the string, asshole"); + lex ()); "\"" => (YYBEGIN INITIAL; endString yypos ); + . => (addString yytext ; lex() ); -- 2.43.0