summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--debug.c4
-rw-r--r--eval.c2
-rw-r--r--match.c7
-rw-r--r--parser.h1
-rw-r--r--parser.l2
-rw-r--r--parser.y2
-rw-r--r--txr.118
8 files changed, 43 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 2796376d..8633ed6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2012-02-24 Kaz Kylheku <kaz@kylheku.com>
+ * debug.c (debug): Use new way of getting line number.
+
+ * eval.c (eval_error): Use source_loc_str to get source location.
+
+ * match.c (debuglf, sem_err, file_err): Likewise.
+
+ * parser.h (source_loc_str): Declared.
+
+ * parser.l (parse_init): form_to_ln_hash must be equal based now.
+
+ * parser.y (rl): Store new form of read-time source location info.
+
+ * txr.1: Documented load.
+
+2012-02-24 Kaz Kylheku <kaz@kylheku.com>
+
* match.c (v_load): Sanity checking on target path.
Check if it is absolute and do not substitute parent
file's directory.
diff --git a/debug.c b/debug.c
index 175dc5b7..5aa2728d 100644
--- a/debug.c
+++ b/debug.c
@@ -60,7 +60,7 @@ static void show_bindings(val env, val stream)
val debug(val form, val bindings, val data, val line, val pos, val base)
{
uses_or2;
- val lineno = source_loc(form);
+ val lineno = car(source_loc(form));
if (!step_mode && !memqual(lineno, breakpoints)
&& (debug_depth > next_depth))
@@ -74,7 +74,7 @@ val debug(val form, val bindings, val data, val line, val pos, val base)
val input, command;
if (print_form) {
- format(std_output, lit("stopped at line ~a\n"), lineno, nao);
+ format(std_output, lit("stopped at ~a\n"), source_loc_str(form), nao);
format(std_output, lit("form: ~s\n"), form, nao);
format(std_output, lit("depth: ~s\n"), num(debug_depth), nao);
print_form = nil;
diff --git a/eval.c b/eval.c
index 7fc4fb58..fe385826 100644
--- a/eval.c
+++ b/eval.c
@@ -103,7 +103,7 @@ noreturn static val eval_error(val form, val fmt, ...)
va_start (vl, fmt);
if (form)
- format(stream, lit("(~a:~a) "), spec_file_str, source_loc(form), nao);
+ format(stream, lit("(~a) "), source_loc_str(form), nao);
(void) vformat(stream, fmt, vl);
va_end (vl);
diff --git a/match.c b/match.c
index 5691511d..cbb74e3a 100644
--- a/match.c
+++ b/match.c
@@ -70,8 +70,7 @@ static void debuglf(val form, val fmt, ...)
if (opt_loglevel >= 2) {
va_list vl;
va_start (vl, fmt);
- format(std_error, lit("~a: (~a:~a) "), prog_string,
- spec_file_str, source_loc(form), nao);
+ format(std_error, lit("~a: (~a) "), prog_string, source_loc_str(form), nao);
vformat(std_error, fmt, vl);
put_char(chr('\n'), std_error);
va_end (vl);
@@ -85,7 +84,7 @@ static void sem_error(val form, val fmt, ...)
va_start (vl, fmt);
if (form)
- format(stream, lit("(~a:~a) "), spec_file_str, source_loc(form), nao);
+ format(stream, lit("(~a) "), source_loc(form), nao);
(void) vformat(stream, fmt, vl);
va_end (vl);
@@ -100,7 +99,7 @@ static void file_err(val form, val fmt, ...)
va_start (vl, fmt);
if (form)
- format(stream, lit("(~a:~a) "), spec_file_str, source_loc(form), nao);
+ format(stream, lit("(~a) "), source_loc(form), nao);
(void) vformat(stream, fmt, vl);
va_end (vl);
diff --git a/parser.h b/parser.h
index 519da719..e3e77600 100644
--- a/parser.h
+++ b/parser.h
@@ -41,6 +41,7 @@ int yylex(void);
void parse_init(void);
void parse_reset(val spec_file);
val source_loc(val form);
+val source_loc_str(val form);
val rl(val form, val lineno);
INLINE val rlcp(val to, val from)
{
diff --git a/parser.l b/parser.l
index 4925b113..6ad32847 100644
--- a/parser.l
+++ b/parser.l
@@ -692,7 +692,7 @@ void parse_init(void)
protect(&yyin_stream, &prepared_error_message,
&form_to_ln_hash, (val *) 0);
- form_to_ln_hash = make_hash(t, nil, nil);
+ form_to_ln_hash = make_hash(t, nil, t);
}
void parse_reset(val spec_file)
diff --git a/parser.y b/parser.y
index bf58d9ff..49705100 100644
--- a/parser.y
+++ b/parser.y
@@ -995,7 +995,7 @@ static val choose_quote(val quoted_form)
val rl(val form, val lineno)
{
- sethash(form_to_ln_hash, form, lineno);
+ sethash(form_to_ln_hash, form, cons(lineno, spec_file_str));
return form;
}
diff --git a/txr.1 b/txr.1
index 187d0956..beb6209b 100644
--- a/txr.1
+++ b/txr.1
@@ -1272,6 +1272,9 @@ as a filter. See Function Filters below.
The filter directive passes one or more variables through a given
filter or chain or filters, updating them with the filtered values.
+.IP @(load)
+The load directive loads another TXR file and interprets its contents.
+
.PP
.SS The Next Directive
@@ -3822,6 +3825,21 @@ Example: convert a, b, and c to upper case and HTML encode:
@(filter (:upcase :to_html) a b c)
+.SS The Load Directive
+
+The syntx of the load directive is:
+
+ @(load EXPR)
+
+Where EXPR evaluates to a string giving the path of the file to load.
+Unless the path is absolute, it is interpreted relative to the directory of the
+source file from which the @(load) form was read. If there was no such
+source file (for instance, the script was read from standard input),
+then it is resolved relative to the current working directory.
+
+Loading is performed at evaluation time; it is not a source file inclusion
+mechanism. A TXR script is read from beginning to end and parsed prior to
+being evaluated.
.SH EXCEPTIONS