summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2009-11-24 18:30:47 -0800
committerKaz Kylheku <kaz@kylheku.com>2009-11-24 18:30:47 -0800
commitfbec2eb30da83f77f0f25edf0b3e3f9b6da07e07 (patch)
tree6d2802cf31584627c62b3f32ee821fc3053a3c59
parent2fb589dc0bc66b0efa10e152153a3b9e6571bfd7 (diff)
downloadtxr-fbec2eb30da83f77f0f25edf0b3e3f9b6da07e07.tar.gz
txr-fbec2eb30da83f77f0f25edf0b3e3f9b6da07e07.tar.bz2
txr-fbec2eb30da83f77f0f25edf0b3e3f9b6da07e07.zip
Switching to keyword symbols for :args and :nothrow.
-rw-r--r--ChangeLog16
-rw-r--r--lib.c15
-rw-r--r--lib.h8
-rw-r--r--match.c22
-rw-r--r--tests/004/query-1.txr2
-rw-r--r--txr.116
6 files changed, 50 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index b467d30f..8896665a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2009-11-24 Kaz Kylheku <kkylheku@gmail.com>
+ Switching to keyword symbols for :args and :nothrow.
+
+ * lib.c (args_s, nothrow_s): Renamed to args_k and nothrow_k.
+ (flattn_s): Renamed to flatten_s.
+ (obj_init): args_k and nothrow_k interned in keyword package.
+
+ * lib.h (args_s, nothrow_s, flattn_s): Declarations updated.
+
+ * match.c (match_files): Follow name changes.
+
+ * tests/004/query1.txr: Changed nothrow to :nothrow.
+
+ * txr.1: Documentation updated.
+
+2009-11-24 Kaz Kylheku <kkylheku@gmail.com>
+
/Now/ this can be released as 025.
utf8.c (utf8_from_uc): Fix bug introduced several commits ago (porting
diff --git a/lib.c b/lib.c
index b48fa41d..efd77320 100644
--- a/lib.c
+++ b/lib.c
@@ -56,13 +56,15 @@ val zeroplus_s, optional_s, compound_s, or_s, quasi_s;
val skip_s, trailer_s, block_s, next_s, freeform_s, fail_s, accept_s;
val all_s, some_s, none_s, maybe_s, cases_s, collect_s, until_s, coll_s;
val define_s, output_s, single_s, first_s, last_s, empty_s;
-val repeat_s, rep_s, flattn_s, forget_s;
-val local_s, merge_s, bind_s, cat_s, args_s;
-val try_s, catch_s, finally_s, nothrow_s, throw_s, defex_s;
+val repeat_s, rep_s, flatten_s, forget_s;
+val local_s, merge_s, bind_s, cat_s;
+val try_s, catch_s, finally_s, throw_s, defex_s;
val error_s, type_error_s, internal_error_s;
val numeric_error_s, range_error_s;
val query_error_s, file_error_s, process_error_s;
+val nothrow_k, args_k;
+
val zero, one, two, negone, maxint, minint;
val null_string;
val nil_string;
@@ -1889,17 +1891,15 @@ static void obj_init(void)
empty_s = intern(lit("empty"), user_package);
repeat_s = intern(lit("repeat"), user_package);
rep_s = intern(lit("rep"), user_package);
- flattn_s = intern(lit("flatten"), user_package);
+ flatten_s = intern(lit("flatten"), user_package);
forget_s = intern(lit("forget"), user_package);
local_s = intern(lit("local"), user_package);
merge_s = intern(lit("merge"), user_package);
bind_s = intern(lit("bind"), user_package);
cat_s = intern(lit("cat"), user_package);
- args_s = intern(lit("args"), user_package);
try_s = intern(lit("try"), user_package);
catch_s = intern(lit("catch"), user_package);
finally_s = intern(lit("finally"), user_package);
- nothrow_s = intern(lit("nothrow"), user_package);
throw_s = intern(lit("throw"), user_package);
defex_s = intern(lit("defex"), user_package);
error_s = intern(lit("error"), user_package);
@@ -1911,6 +1911,9 @@ static void obj_init(void)
file_error_s = intern(lit("file_error"), user_package);
process_error_s = intern(lit("process_error"), user_package);
+ args_k = intern(lit("args"), keyword_package);
+ nothrow_k = intern(lit("nothrow"), keyword_package);
+
equal_f = func_f2(nil, equal_tramp);
identity_f = func_f1(nil, identity_tramp);
prog_string = string(progname);
diff --git a/lib.h b/lib.h
index 5f2dddfa..b8948351 100644
--- a/lib.h
+++ b/lib.h
@@ -200,13 +200,15 @@ extern val zeroplus_s, optional_s, compound_s, or_s, quasi_s;
extern val skip_s, trailer_s, block_s, next_s, freeform_s, fail_s, accept_s;
extern val all_s, some_s, none_s, maybe_s, cases_s, collect_s, until_s, coll_s;
extern val define_s, output_s, single_s, first_s, last_s, empty_s;
-extern val repeat_s, rep_s, flattn_s, forget_s;
-extern val local_s, merge_s, bind_s, cat_s, args_s;
-extern val try_s, catch_s, finally_s, nothrow_s, throw_s, defex_s;
+extern val repeat_s, rep_s, flatten_s, forget_s;
+extern val local_s, merge_s, bind_s, cat_s;
+extern val try_s, catch_s, finally_s, throw_s, defex_s;
extern val error_s, type_error_s, internal_error_s;
extern val numeric_error_s, range_error_s;
extern val query_error_s, file_error_s, process_error_s;
+extern val nothrow_k, args_k;
+
extern val zero, one, two, negone, maxint, minint;
extern val null_string;
extern val null_list; /* (nil) */
diff --git a/match.c b/match.c
index a9ca7d24..322a4b01 100644
--- a/match.c
+++ b/match.c
@@ -920,7 +920,7 @@ val match_files(val spec, val files,
debugf(lit("opening data source ~a"), name, nao);
if (complex_open_failed(fp)) {
- if (consp(source_spec) && car(source_spec) == nothrow_s) {
+ if (consp(source_spec) && car(source_spec) == nothrow_k) {
debugf(lit("could not open ~a: "
"treating as failed match due to nothrow"), name, nao);
return nil;
@@ -1085,9 +1085,9 @@ repeat_spec_same_data:
if (rest(first_spec)) {
val source = rest(first_spec);
- if (eq(first(source), nothrow_s))
+ if (eq(first(source), nothrow_k))
push(nil, &source);
- else if (eq(first(source), args_s)) {
+ else if (eq(first(source), args_k)) {
val input_name = string(L"args");
cons_bind (new_bindings, success,
match_files(spec, cons(input_name, files),
@@ -1106,16 +1106,16 @@ repeat_spec_same_data:
sem_error(spec_linenum, lit("next: unbound variable in form ~a"),
first(source), nao);
- if (eq(second(source), nothrow_s)) {
+ if (eq(second(source), nothrow_k)) {
if (name) {
- files = cons(cons(nothrow_s, name), files);
+ files = cons(cons(nothrow_k, name), files);
} else {
files = rest(files);
if (!files) {
debuglf(spec_linenum, lit("next: out of arguments"), nao);
return nil;
}
- files = cons(cons(nothrow_s, first(files)), rest(files));
+ files = cons(cons(nothrow_k, first(files)), rest(files));
}
} else {
if (name) {
@@ -1124,7 +1124,7 @@ repeat_spec_same_data:
files = rest(files);
if (!files)
sem_error(spec_linenum, lit("next: out of arguments"), nao);
- files = cons(cons(nothrow_s, first(files)), rest(files));
+ files = cons(cons(nothrow_k, first(files)), rest(files));
}
}
}
@@ -1136,7 +1136,7 @@ repeat_spec_same_data:
nao);
continue;
}
- files = cons(cons(nothrow_s, str), files);
+ files = cons(cons(nothrow_k, str), files);
} else {
files = rest(files);
if (!files)
@@ -1311,7 +1311,7 @@ repeat_spec_same_data:
break;
goto repeat_spec_same_data;
- } else if (sym == flattn_s) {
+ } else if (sym == flatten_s) {
val iter;
for (iter = rest(first_spec); iter; iter = rest(iter)) {
@@ -1428,7 +1428,7 @@ repeat_spec_same_data:
if (old_style_dest) {
dest = cat_str(subst_vars(old_style_dest, bindings), nil);
} else {
- if (eq(first(new_style_dest), nothrow_s))
+ if (eq(first(new_style_dest), nothrow_k))
push(nil, &new_style_dest);
{
@@ -1439,7 +1439,7 @@ repeat_spec_same_data:
sem_error(spec_linenum,
lit("output: unbound variable in form ~a"), form, nao);
- nt = eq(second(new_style_dest), nothrow_s);
+ nt = eq(second(new_style_dest), nothrow_k);
dest = or2(cdr(val), string(L"-"));
}
}
diff --git a/tests/004/query-1.txr b/tests/004/query-1.txr
index c8a9e226..2d695242 100644
--- a/tests/004/query-1.txr
+++ b/tests/004/query-1.txr
@@ -1,5 +1,5 @@
#!./txr
-@(next args)
+@(next :args)
@#
@# Define option_error exception, subtyped from error
@#
diff --git a/txr.1 b/txr.1
index 370beb11..ecd88dab 100644
--- a/txr.1
+++ b/txr.1
@@ -897,8 +897,8 @@ with, or without arguments:
@(next)
@(next SOURCE)
- @(next SOURCE nothrow)
- @(next args)
+ @(next SOURCE :nothrow)
+ @(next :args)
The lone @(next) without arguments switches to the next file in the
argument list which was passed to the
@@ -919,16 +919,16 @@ If the input source cannot be opened for whatever reason,
.B txr
throws an exception (see EXCEPTIONS below). An unhandled exception will
terminate the program. Often, such a drastic measure is inconvenient;
-if @(next) is invoked with the nothrow keyword, then if the input
+if @(next) is invoked with the :nothrow keyword, then if the input
source cannot be opened, the situation is treated as a simple
match failure.
-The variant @(next args) means that the remaining command line arguments are to
+The variant @(next :args) means that the remaining command line arguments are to
be treated as a data source. For this purpose, each argument is considered to
be a line of text. If an argument is currently being processed as an input
source, that argument is included. Note that if the first entry in the argument
list does not name an input source, then the query should begin with
-@(next args) or some other form of next directive, to prevent an attempt to
+@(next :args) or some other form of next directive, to prevent an attempt to
open the input source named by that argument. If the very first directive of a query is any variant of the next directive, then
.B txr
avoids opening the first input source, but it does open the input source for
@@ -941,7 +941,7 @@ example:
@(next)/path/to/@foo.txt
The trailing material specifies gives the input source.
-The nothrow behavior is implicit in this form. The syntax will
+The :nothrow behavior is implicit in this form. The syntax will
disappear in some future version of
.B txr
.
@@ -2104,7 +2104,7 @@ usual printing of the variable bindings or the word false.
The syntax of the @(output) directive is:
- @(output [ DESTINATION ] [ nothrow ])
+ @(output [ DESTINATION ] [ :nothrow ])
.
. one or more output directives or lines
.
@@ -2127,7 +2127,7 @@ In the second obsolescent form, the material to the right of @(output)
is query text which may contain variables.
The new syntax throws an exception if the output destination
-cannot be opened, unless the nothrow keyword is present, in which
+cannot be opened, unless the :nothrow keyword is present, in which
case the situation is treated as a match failure. The old syntax throws an
exception.