From 8637782953f3eedcf7ff0499983c8c52bb0a3651 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 19 Oct 2014 14:17:12 -0700 Subject: * 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. --- ChangeLog | 10 ++++++++++ dep.mk | 2 +- parser.l | 15 ++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index dab14119..a01c0ef0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2014-10-19 Kaz Kylheku + + * 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 * parser.y (r_exprs): New grammar symbol. r_exprs uses 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; } -- cgit v1.2.3