summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-02-25 04:27:49 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-02-25 04:27:49 -0800
commit1eb5c9800789e0f6b14c84656b12418bd86e0786 (patch)
tree1a1bff8fe449f1f20d151c9574cf88b3cc0b0daf /parser.l
parent267a20b4c57f13ccbf89e54469c8dcb5ad09b631 (diff)
downloadtxr-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.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l16
1 files changed, 14 insertions, 2 deletions
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);
}
}