summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-09-26 21:39:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2011-09-26 21:45:45 -0700
commit7185545a38de4f53bf3c92be5d1d97d2928ffbb9 (patch)
treefcc1a4a6f69cf716e9212802a777068444756411
parent070d3dfe7759943406cd76e7aebe72bf92ab3503 (diff)
downloadtxr-7185545a38de4f53bf3c92be5d1d97d2928ffbb9.tar.gz
txr-7185545a38de4f53bf3c92be5d1d97d2928ffbb9.tar.bz2
txr-7185545a38de4f53bf3c92be5d1d97d2928ffbb9.zip
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.
-rw-r--r--ChangeLog11
-rw-r--r--parser.l16
-rw-r--r--parser.y2
3 files changed, 23 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 41a7a8d1..691bbc77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-09-26 Kaz Kylheku <kaz@kylheku.com>
+ 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 <kaz@kylheku.com>
+
New feature: @(deffilter)
Bugfix in @(throw) when non-symbol is thrown: exception message
diff --git a/parser.l b/parser.l
index 437d504c..0fd39c5b 100644
--- a/parser.l
+++ b/parser.l
@@ -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;
}
diff --git a/parser.y b/parser.y
index e6e66d1d..2ad2d53f 100644
--- a/parser.y
+++ b/parser.y
@@ -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