summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--parser.l16
-rw-r--r--txr.15
3 files changed, 28 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d0356f49..9e2e1661 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2012-02-25 Kaz Kylheku <kaz@kylheku.com>
+ * parser.l (source_loc_str): Missing function re-written.
+ (Accidentally originally written in lex.yy.c file!)
+ (parse_reset): If file can't be opened, try adding .txr suffix
+ to it.
+
+ * txr.1: Suffix-handling behavior documented.
+
+2012-02-25 Kaz Kylheku <kaz@kylheku.com>
+
* parser.y (clause): "Doh" moment. We don't need the special
transformation of the load syntax because the parent location
is already associated with the syntax.
diff --git a/parser.l b/parser.l
index 6ad32847..3c09aabc 100644
--- a/parser.l
+++ b/parser.l
@@ -687,6 +687,14 @@ val source_loc(val form)
return gethash(form_to_ln_hash, form);
}
+val source_loc_str(val form)
+{
+ cons_bind (line, file, gethash(form_to_ln_hash, form));
+ return if3(line,
+ format(nil, lit("~a:~a"), file, line, nao),
+ lit("source location n/a"));
+}
+
void parse_init(void)
{
protect(&yyin_stream, &prepared_error_message,
@@ -702,8 +710,12 @@ void parse_reset(val spec_file)
spec_file_str = spec_file;
{
FILE *in = w_fopen(c_str(spec_file_str), L"r");
- if (in == 0)
- uw_throwf(file_error_s, lit("unable to open ~a"), spec_file_str, nao);
+ if (in == 0) {
+ spec_file_str = cat_str(list(spec_file_str, lit("txr"), nao), lit("."));
+ in = w_fopen(c_str(spec_file_str), L"r");
+ if (in == 0)
+ uw_throwf(file_error_s, lit("unable to open ~a"), spec_file, nao);
+ }
yyin_stream = make_stdio_stream(in, spec_file_str, t, nil);
}
}
diff --git a/txr.1 b/txr.1
index beb6209b..aa290163 100644
--- a/txr.1
+++ b/txr.1
@@ -3837,6 +3837,11 @@ 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.
+If the file cannot be opened, then the .txr suffix is added and another
+attempt is made. Thus load expressions need not refer to the suffix.
+In the future, additional suffixes may be searched (compiled versions
+of a file).
+
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.