summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-10-19 14:17:12 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-10-19 14:17:12 -0700
commit8637782953f3eedcf7ff0499983c8c52bb0a3651 (patch)
tree07c8e6b8f35913f5b82e066b3f7885e78c9fa809
parent57689fa47c1fcc67f224a81915a46e86af3e94be (diff)
downloadtxr-8637782953f3eedcf7ff0499983c8c52bb0a3651.tar.gz
txr-8637782953f3eedcf7ff0499983c8c52bb0a3651.tar.bz2
txr-8637782953f3eedcf7ff0499983c8c52bb0a3651.zip
* parser.l (lisp_parse): Bugfix: the error_stream argument
must be checked to be a stream before we plant it in place of std_error, otherwise we will get a type exception thrown lower down, which leads to runaway recursion as TXR tries to print the error messages on std_error. * dep.mk: Regenerated.
-rw-r--r--ChangeLog10
-rw-r--r--dep.mk2
-rw-r--r--parser.l15
3 files changed, 23 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index dab14119..a01c0ef0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2014-10-19 Kaz Kylheku <kaz@kylheku.com>
+ * parser.l (lisp_parse): Bugfix: the error_stream argument
+ must be checked to be a stream before we plant it in place
+ of std_error, otherwise we will get a type exception thrown
+ lower down, which leads to runaway recursion as TXR tries
+ to print the error messages on std_error.
+
+ * dep.mk: Regenerated.
+
+2014-10-19 Kaz Kylheku <kaz@kylheku.com>
+
* parser.y (r_exprs): New grammar symbol. r_exprs uses
left-recursive rules to avoid filling the yacc stack, and
returns the items in reverse order. The output of each
diff --git a/dep.mk b/dep.mk
index 071897e6..bc7458e0 100644
--- a/dep.mk
+++ b/dep.mk
@@ -1,5 +1,5 @@
./txr.o: config.h $(top_srcdir)/./lib.h $(top_srcdir)/./stream.h $(top_srcdir)/./gc.h $(top_srcdir)/./signal.h $(top_srcdir)/./unwind.h $(top_srcdir)/./parser.h $(top_srcdir)/./match.h $(top_srcdir)/./utf8.h $(top_srcdir)/./debug.h $(top_srcdir)/./syslog.h $(top_srcdir)/./eval.h $(top_srcdir)/./regex.h $(top_srcdir)/./arith.h $(top_srcdir)/./txr.h
-./lex.yy.o: config.h $(top_srcdir)/./lib.h $(top_srcdir)/./gc.h $(top_srcdir)/./stream.h $(top_srcdir)/./utf8.h $(top_srcdir)/./signal.h $(top_srcdir)/./unwind.h $(top_srcdir)/./hash.h $(top_srcdir)/./parser.h y.tab.h
+./lex.yy.o: config.h $(top_srcdir)/./lib.h $(top_srcdir)/./gc.h $(top_srcdir)/./stream.h $(top_srcdir)/./utf8.h $(top_srcdir)/./signal.h $(top_srcdir)/./unwind.h $(top_srcdir)/./hash.h $(top_srcdir)/./parser.h $(top_srcdir)/./eval.h y.tab.h
./y.tab.o: config.h $(top_srcdir)/./lib.h $(top_srcdir)/./signal.h $(top_srcdir)/./unwind.h $(top_srcdir)/./regex.h $(top_srcdir)/./utf8.h $(top_srcdir)/./match.h $(top_srcdir)/./hash.h $(top_srcdir)/./eval.h $(top_srcdir)/./stream.h $(top_srcdir)/./parser.h
./match.o: config.h $(top_srcdir)/./lib.h $(top_srcdir)/./gc.h $(top_srcdir)/./signal.h $(top_srcdir)/./unwind.h $(top_srcdir)/./regex.h $(top_srcdir)/./stream.h $(top_srcdir)/./parser.h $(top_srcdir)/./txr.h $(top_srcdir)/./utf8.h $(top_srcdir)/./filter.h $(top_srcdir)/./hash.h $(top_srcdir)/./debug.h $(top_srcdir)/./eval.h $(top_srcdir)/./match.h
./lib.o: config.h $(top_srcdir)/./lib.h $(top_srcdir)/./gc.h $(top_srcdir)/./arith.h $(top_srcdir)/./rand.h $(top_srcdir)/./hash.h $(top_srcdir)/./signal.h $(top_srcdir)/./unwind.h $(top_srcdir)/./stream.h $(top_srcdir)/./utf8.h $(top_srcdir)/./filter.h $(top_srcdir)/./eval.h $(top_srcdir)/./sysif.h $(top_srcdir)/./regex.h
diff --git a/parser.l b/parser.l
index 7b2ffde1..92a3b08e 100644
--- a/parser.l
+++ b/parser.l
@@ -48,6 +48,7 @@
#include "unwind.h"
#include "hash.h"
#include "parser.h"
+#include "eval.h"
#include "y.tab.h"
#define YY_INPUT(buf, result, max_size) \
@@ -996,24 +997,32 @@ val lisp_parse(val source_in, val error_stream, val error_return_val)
val name = if3(stringp(source),
format(nil, lit("expr --> ~a"), source, nao),
stream_get_prop(input_stream, name_k));
- val save_stream = std_error;
val stream = make_catenated_stream(list(secret_token_stream, input_stream, nao));
+ val saved_dyn = dyn_env;
parser_t parser;
+ dyn_env = make_env(nil, nil, dyn_env);
+
error_stream = default_bool_arg(error_stream);
- std_error = if3(error_stream == t, std_output, or2(error_stream, std_null));
+ error_stream = if3(error_stream == t, std_output, or2(error_stream, std_null));
+ class_check (error_stream, stream_s);
+
+ env_vbind(dyn_env, stderr_s, error_stream);
+
{
int gc = gc_state(0);
name = if3(std_error != std_null, name, lit(""));
parse(stream, name, &parser);
gc_state(gc);
}
- std_error = save_stream;
+
+ dyn_env = saved_dyn;
if (parser.errors) {
if (missingp(error_return_val))
uw_throwf(syntax_error_s, lit("read: syntax error"), nao);
return error_return_val;
}
+
return parser.syntax_tree;
}