summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-11-28 18:57:18 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-11-28 18:57:18 -0800
commit8bd9d47e3c25bfd964bb6950362d169c49887b66 (patch)
treed8d99533b099f8a0ea5d5a11c33f6bf4638eab99 /parser.c
parenta67a10b463c0c43d851ec2bb72311130be306128 (diff)
downloadtxr-8bd9d47e3c25bfd964bb6950362d169c49887b66.tar.gz
txr-8bd9d47e3c25bfd964bb6950362d169c49887b66.tar.bz2
txr-8bd9d47e3c25bfd964bb6950362d169c49887b66.zip
Error reports trace through layers of macroexpansion.
* eval.c (error_trace): New function. Consolidates error reporting between unhandled exception handling in uw_throw, and the catcher in the repl. (op_defmacro, expand_macrolet): Propagate location info from body to wrapping block, and to the macro binding. In the latter function, also to the body that is wrapped by local macros. (do_expand, macroexpand_1): Propagate location info from macro expander to expansion, only taking it from the form if the macro doesn't supply it. * eval.h (error_trace): Declared. * parser.c (repl): Replace error reporting code with call to error_trace. * unwind.c (uw_throw): uw_throw: likewise.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c27
1 files changed, 2 insertions, 25 deletions
diff --git a/parser.c b/parser.c
index c3c581e4..ec59399d 100644
--- a/parser.c
+++ b/parser.c
@@ -49,6 +49,7 @@
#include "stream.h"
#include "y.tab.h"
#include "sysif.h"
+#include "cadr.h"
#include "parser.h"
#if HAVE_TERMIOS
#include "linenoise/linenoise.h"
@@ -751,31 +752,7 @@ val repl(val bindings, val in_stream, val out_stream)
if (uw_exception_subtype_p(exsym, syntax_error_s)) {
put_line(lit("** syntax error"), out_stream);
} else if (uw_exception_subtype_p(exsym, error_s)) {
- val info = source_loc_str(last_form_evaled, nil);
- val ex_info = source_loc_str(last_form_expanded, nil);
- val origin = last_form_evaled;
-
- if (cdr(exvals))
- format(out_stream, lit("** ~!~a ~!~s\n"),
- car(exvals), cdr(exvals), nao);
- else
- format(out_stream, lit("** ~!~a\n"), car(exvals), nao);
-
- if (info && exsym != eval_error_s) {
- format(out_stream, lit("** possibly triggered at ~a by form ~!~s\n"),
- info, last_form_evaled, nao);
-
- while ((origin = lookup_origin(origin))) {
- val oinfo = source_loc_str(origin, lit("(n/a)"));
- format(out_stream, lit("** which is an expansion at ~a of ~!~s\n"),
- oinfo, origin, nao);
- }
- }
-
- if (ex_info)
- format(out_stream, lit("** during expansion at ~a of form ~!~s\n"),
- ex_info, last_form_expanded, nao);
-
+ error_trace(exsym, exvals, std_error, lit("**"));
} else {
format(out_stream, lit("** ~!~s exception, args: ~!~s\n"),
exsym, exvals, nao);