summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-16 00:59:47 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-16 00:59:47 -0800
commitb68fb2aad15663edfe7c3671c97bd85bc531c565 (patch)
treec2a0446e7a38a1921a1f837ec6f001203a2a3342
parentced323fff8f93bffe0666eba6e498b113aa3bd0a (diff)
downloadtxr-b68fb2aad15663edfe7c3671c97bd85bc531c565.tar.gz
txr-b68fb2aad15663edfe7c3671c97bd85bc531c565.tar.bz2
txr-b68fb2aad15663edfe7c3671c97bd85bc531c565.zip
Nice idea: how about a function which walks the tree structure and
back-fills some missing source code location info. We apply this to macro expansions. If some error occurs in expanded code, this way it is referenced to the line where the macro *call* occurs. Not only is this better than nothing, it may be better than tracing it to the macro definition. Ideally, we would have both places: ("the error is in the code expanded from this macro, at this site"). * eval.c (expand): Use rlcp_tree to back-fill source info in macro expansion by taking it from the unexpanded form. * parser.h (rlcp_tree): Declared. * parser.y (rlcp_tree): New function.
-rw-r--r--ChangeLog17
-rw-r--r--eval.c3
-rw-r--r--parser.h1
-rw-r--r--parser.y13
4 files changed, 32 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f0220877..791936d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2014-02-16 Kaz Kylheku <kaz@kylheku.com>
+ Nice idea: how about a function which walks the tree structure and
+ back-fills some missing source code location info. We apply this to
+ macro expansions. If some error occurs in expanded code, this way it
+ is referenced to the line where the macro *call* occurs.
+ Not only is this better than nothing, it may be better than tracing
+ it to the macro definition. Ideally, we would have both places:
+ ("the error is in the code expanded from this macro, at this site").
+
+ * eval.c (expand): Use rlcp_tree to back-fill source info in
+ macro expansion by taking it from the unexpanded form.
+
+ * parser.h (rlcp_tree): Declared.
+
+ * parser.y (rlcp_tree): New function.
+
+2014-02-16 Kaz Kylheku <kaz@kylheku.com>
+
Bugfixes: not propagating source loc info in quasiliterals.
* eval.c (expand_quasi): Add some rlcp's here.
diff --git a/eval.c b/eval.c
index f272db01..0be885d3 100644
--- a/eval.c
+++ b/eval.c
@@ -2086,8 +2086,7 @@ tail:
val mac_expand = expand_macro(form_ex, macro, make_env(nil, nil, nil));
if (mac_expand == form)
return form;
- if (!source_loc(mac_expand))
- rlcp(mac_expand, form);
+ rlcp_tree(mac_expand, form);
form = mac_expand;
goto tail;
} else {
diff --git a/parser.h b/parser.h
index bf582fcb..aa190805 100644
--- a/parser.h
+++ b/parser.h
@@ -49,5 +49,6 @@ INLINE val rlcp(val to, val from)
{
return rlset(to, source_loc(from));
}
+val rlcp_tree(val to, val from);
val regex_parse(val string, val error_stream);
val lisp_parse(val source, val error_stream);
diff --git a/parser.y b/parser.y
index 797d3711..a4a7aa61 100644
--- a/parser.y
+++ b/parser.y
@@ -1149,6 +1149,19 @@ val rlset(val form, val info)
return form;
}
+val rlcp_tree(val to, val from)
+{
+ if (atom(to)) {
+ return nil;
+ } else {
+ if (!source_loc(to))
+ rlcp(to, from);
+ for (; consp(to); to = cdr(to))
+ rlcp_tree(car(to), from);
+ return t;
+ }
+}
+
static wchar_t char_from_name(const wchar_t *name)
{
static struct {