From 7185545a38de4f53bf3c92be5d1d97d2928ffbb9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 26 Sep 2011 21:39:44 -0700 Subject: Bugfixes: Consistent escaping in various literals. Double backslash codes for single backslash. Output clause can be empty. * parser.l (char_esc): Backslash handled. Use internal_error rather than abort. (REGCHAR, LITCHAR): Backslash added to lexical syntax. * parser.y (output_clause): Allow empty output clause. --- ChangeLog | 11 +++++++++++ parser.l | 16 ++++++++++------ parser.y | 2 ++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41a7a8d1..691bbc77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-09-26 Kaz Kylheku + + Bugfixes: Consistent escaping in various literals. Double + backslash codes for single backslash. Output clause can be empty. + + * parser.l (char_esc): Backslash handled. + Use internal_error rather than abort. + (REGCHAR, LITCHAR): Backslash added to lexical syntax. + + * parser.y (output_clause): Allow empty output clause. + 2011-09-26 Kaz Kylheku New feature: @(deffilter) diff --git a/parser.l b/parser.l index 437d504c..0fd39c5b 100644 --- a/parser.l +++ b/parser.l @@ -34,12 +34,14 @@ #include #include #include +#include #include "config.h" #include "lib.h" #include "y.tab.h" #include "gc.h" #include "stream.h" #include "utf8.h" +#include "unwind.h" #include "parser.h" #define YY_INPUT(buf, result, max_size) \ @@ -145,9 +147,11 @@ static wchar_t char_esc(int letter) case '"': return L'"'; case '\'': return L'\''; case '`': return L'`'; + case '/': return L'/'; + case '\\': return L'\\'; } - abort(); + internal_error("unhandled escape character"); } static wchar_t num_esc(char *num) @@ -425,10 +429,10 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} } -[\\][abtnvfre] { - yylval.chr = char_esc(yytext[1]); - return REGCHAR; - } +[\\][abtnvfre\\] { + yylval.chr = char_esc(yytext[1]); + return REGCHAR; + } [\\](x{HEX}+|{OCT}+) { yylval.chr = num_esc(yytext + 1); @@ -516,7 +520,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return yytext[0]; } -[\\][abtnvfre"`'] { +[\\][abtnvfre"`'\\] { yylval.chr = char_esc(yytext[1]); return LITCHAR; } diff --git a/parser.y b/parser.y index e6e66d1d..2ad2d53f 100644 --- a/parser.y +++ b/parser.y @@ -270,6 +270,8 @@ output_clause : OUTPUT ')' o_elems '\n' out_clauses END newl { $$ = nil; yyerror("obsolete output syntax: trailing material"); } + | OUTPUT ')' newl + END newl { $$ = list(output_s, nao); } | OUTPUT ')' newl out_clauses END newl { $$ = list(output_s, $4, nao); } -- cgit v1.2.3