From 8bd9d47e3c25bfd964bb6950362d169c49887b66 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 28 Nov 2015 18:57:18 -0800 Subject: 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. --- parser.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'parser.c') 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); -- cgit v1.2.3