diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-02-25 04:27:49 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-02-25 04:27:49 -0800 |
commit | 1eb5c9800789e0f6b14c84656b12418bd86e0786 (patch) | |
tree | 1a1bff8fe449f1f20d151c9574cf88b3cc0b0daf | |
parent | 267a20b4c57f13ccbf89e54469c8dcb5ad09b631 (diff) | |
download | txr-1eb5c9800789e0f6b14c84656b12418bd86e0786.tar.gz txr-1eb5c9800789e0f6b14c84656b12418bd86e0786.tar.bz2 txr-1eb5c9800789e0f6b14c84656b12418bd86e0786.zip |
* 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.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | parser.l | 16 | ||||
-rw-r--r-- | txr.1 | 5 |
3 files changed, 28 insertions, 2 deletions
@@ -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. @@ -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); } } @@ -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. |