diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-09-26 21:39:44 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-09-26 21:39:44 -0700 |
commit | 22e2a2063358540cb5cd3a4ffa2258f417234692 (patch) | |
tree | 6b0ad9de2cff27bb7621bc2b762e03c54ab38fa5 | |
parent | 070d3dfe7759943406cd76e7aebe72bf92ab3503 (diff) | |
download | txr-22e2a2063358540cb5cd3a4ffa2258f417234692.tar.gz txr-22e2a2063358540cb5cd3a4ffa2258f417234692.tar.bz2 txr-22e2a2063358540cb5cd3a4ffa2258f417234692.zip |
Bugfixeses: 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.
-rw-r--r-- | parser.l | 16 | ||||
-rw-r--r-- | parser.y | 2 |
2 files changed, 12 insertions, 6 deletions
@@ -34,12 +34,14 @@ #include <errno.h> #include <dirent.h> #include <wchar.h> +#include <setjmp.h> #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} } -<REGEX>[\\][abtnvfre] { - yylval.chr = char_esc(yytext[1]); - return REGCHAR; - } +<REGEX>[\\][abtnvfre\\] { + yylval.chr = char_esc(yytext[1]); + return REGCHAR; + } <REGEX>[\\](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]; } -<STRLIT,CHRLIT,QSILIT>[\\][abtnvfre"`'] { +<STRLIT,CHRLIT,QSILIT>[\\][abtnvfre"`'\\] { yylval.chr = char_esc(yytext[1]); return LITCHAR; } @@ -271,6 +271,8 @@ output_clause : OUTPUT ')' o_elems '\n' 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); } | OUTPUT exprs ')' newl |