diff options
-rw-r--r-- | ChangeLog | 63 | ||||
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | lib.c | 193 | ||||
-rw-r--r-- | lib.h | 24 | ||||
-rw-r--r-- | match.c | 109 | ||||
-rw-r--r-- | parser.y | 105 | ||||
-rw-r--r-- | regex.c | 32 | ||||
-rw-r--r-- | stream.c | 50 | ||||
-rw-r--r-- | txr.c | 4 | ||||
-rw-r--r-- | unwind.c | 32 | ||||
-rw-r--r-- | unwind.h | 6 |
11 files changed, 345 insertions, 275 deletions
@@ -1,3 +1,66 @@ +2009-11-24 Kaz Kylheku <kkylheku@gmail.com> + + Renaming global variables that denote symbols, such that they + have a _s suffix. + + * lib.c (cons_t, str_t, chr_t, num_t, sym_t, pkg_t, fun_t, vec_t, + stream_t, hash_t, lcons_t, lstr_t, cobj_t var, regex, set, cset, wild, + oneplus zeroplus, optional, compound, or, quasi skip, trailer, block, + next, freeform, fail, accept all, some, none, maybe, cases, collect, + until, coll define, output, single, frst, lst, empty, repeat, rep + flattn, forget, local, mrge, bind, cat, args try, catch, finally, + nothrow, throw, defex error, type_error, internal_err, numeric_err, + range_err query_error, file_error, process_error): Symbol globals + renamed to cons_s, str_s, chr_s, num_s, sym_s, pkg_s, fun_s, vec_s, t, + cons_s, str_s, chr_s, num_s, sym_s, pkg_s, fun_s, vec_s, stream_s, + hash_s, lcons_s, lstr_s, cobj_s, var_s, regex_s, set_s, cset_s, wild_s, + oneplus_s, zeroplus_s, optional_s, compound_s, or_s, quasi_s, skip_s, + trailer_s, block_s, next_s, freeform_s, fail_s, accept_s, all_s, + some_s, none_s, maybe_s, cases_s, collect_s, until_s, coll_s, define_s, + output_s, single_s, first_s, last_s, empty_s, repeat_s, rep_s, + flattn_s, forget_s, local_s, merge_s, bind_s, cat_s, args_s, try_s, + catch_s, finally_s, nothrow_s, throw_s, defex_s, error_s, type_error_s, + internal_error_s, numeric_error_s, range_error_s, query_error_s, + file_error_s, process_error_s, + (code2type, typeof, make_package, intern, obj_init): Symbols + references follow rename. + + * lib.h (cons_t, str_t, chr_t, num_t, sym_t, pkg_t, fun_t, vec_t, + stream_t, hash_t, lcons_t, lstr_t, cobj_t var, regex, set, cset, wild, + oneplus zeroplus, optional, compound, or, quasi skip, trailer, block, + next, freeform, fail, accept all, some, none, maybe, cases, collect, + until, coll define, output, single, frst, lst, empty, repeat, rep + flattn, forget, local, mrge, bind, cat, args try, catch, finally, + nothrow, throw, defex error, type_error, internal_err, numeric_err, + range_err query_error, file_error, process_error): Declarations + updated. + + * hash.c (make_hash): Symbol references follow rename. + + * match.c (sem_error, file_err, dump_var, match_line, subst_vars, + eval_form, complex_stream, extract_vars, do_output_line, do_output, + match_files): Likewise. + + * parser.y (grammar, repeat_rep_helper, define_transform): Likewise. + + * regex.c (nfa_compile_set, nf_compile_regex, regex_compile, + regexp, regex_nfa): Likewise. + + * stream.c (stdio_maybe_read_error, stdio_maybe_write_error, + stdio_close, pipe_close, make_stdio_stream, make_pipe_stream, + make_string_input_stream, make_string_byte_input_stream, + make_string_output_stream, get_string_from_stream, make_dir_stream, + close_stream, get_line, get_char, get_byte, vformat, format, + put_string, put_char): Likewise. + + * txr.c (txr_main): Likewise. + + * unwind.c (uw_throw, uw_errorf, type_mismatch, uw_register_subtype, + uw_init): Likewise. + + * unwind.h (internal_error, numeric_assert, range_bug_unless); + Likewise. + 2009-11-23 Kaz Kylheku <kkylheku@gmail.com> * configure (platform_flags, remove_flags): New config variables. @@ -229,7 +229,7 @@ val make_hash(val weak_keys, val weak_vals) struct hash *h = (struct hash *) chk_malloc(sizeof *h); val mod = num(256); val table = vector(mod); - val hash = cobj((void *) h, hash_t, &hash_ops); + val hash = cobj((void *) h, hash_s, &hash_ops); vec_set_fill(table, mod); @@ -49,17 +49,20 @@ val packages; val system_package, keyword_package, user_package; -val null, t, cons_t, str_t, chr_t, num_t, sym_t, pkg_t, fun_t, vec_t; -val stream_t, hash_t, lcons_t, lstr_t, cobj_t; -val var, regex, set, cset, wild, oneplus; -val zeroplus, optional, compound, or, quasi; -val skip, trailer, block, next, freeform, fail, accept; -val all, some, none, maybe, cases, collect, until, coll; -val define, output, single, frst, lst, empty, repeat, rep; -val flattn, forget, local, mrge, bind, cat, args; -val try, catch, finally, nothrow, throw, defex; -val error, type_error, internal_err, numeric_err, range_err; -val query_error, file_error, process_error; +val null, t, cons_s, str_s, chr_s, num_s, sym_s, pkg_s, fun_s, vec_s; +val t, cons_s, str_s, chr_s, num_s, sym_s, pkg_s, fun_s, vec_s; +val stream_s, hash_s, lcons_s, lstr_s, cobj_s; +val var_s, regex_s, set_s, cset_s, wild_s, oneplus_s; +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 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 zero, one, two, negone, maxint, minint; val null_string; @@ -90,18 +93,18 @@ static val equal_tramp(val env, val , val ); static val code2type(int code) { switch ((type_t) code) { - case CONS: return cons_t; - case STR: return str_t; - case LIT: return str_t; - case CHR: return chr_t; - case NUM: return num_t; - case SYM: return sym_t; - case PKG: return pkg_t; - case FUN: return fun_t; - case VEC: return vec_t; - case LCONS: return lcons_t; - case LSTR: return lstr_t; - case COBJ: return cobj_t; + case CONS: return cons_s; + case STR: return str_s; + case LIT: return str_s; + case CHR: return chr_s; + case NUM: return num_s; + case SYM: return sym_s; + case PKG: return pkg_s; + case FUN: return fun_s; + case VEC: return vec_s; + case LCONS: return lcons_s; + case LSTR: return lstr_s; + case COBJ: return cobj_s; } return nil; } @@ -110,9 +113,9 @@ val typeof(val obj) { switch (tag(obj)) { case TAG_NUM: - return num_t; + return num_s; case TAG_CHR: - return chr_t; + return chr_s; case TAG_PTR: if (obj == nil) { return null; @@ -1084,7 +1087,7 @@ val make_sym(val name) val make_package(val name) { if (find_package(name)) - uw_throwf(error, lit("make_package: ~a exists already"), name, nao); + uw_throwf(error_s, lit("make_package: ~a exists already"), name, nao); val obj = make_obj(); obj->pk.type = PKG; @@ -1109,7 +1112,7 @@ val intern(val str, val package) } else if (stringp(package)) { package = find_package(str); if (!package) - uw_throwf(error, lit("make_package: ~a exists already"), str, nao); + uw_throwf(error_s, lit("make_package: ~a exists already"), str, nao); } type_check (package, PKG); @@ -1838,74 +1841,74 @@ static void obj_init(void) t->s.package = user_package; null = intern(lit("null"), user_package); - cons_t = intern(lit("cons"), user_package); - str_t = intern(lit("str"), user_package); - chr_t = intern(lit("chr"), user_package); - num_t = intern(lit("num"), user_package); - sym_t = intern(lit("sym"), user_package); - pkg_t = intern(lit("pkg"), user_package); - fun_t = intern(lit("fun"), user_package); - vec_t = intern(lit("vec"), user_package); - stream_t = intern(lit("stream"), user_package); - hash_t = intern(lit("hash"), user_package); - lcons_t = intern(lit("lcons"), user_package); - lstr_t = intern(lit("lstr"), user_package); - cobj_t = intern(lit("cobj"), user_package); - var = intern(lit("var"), system_package); - regex = intern(lit("regex"), system_package); - set = intern(lit("set"), user_package); - cset = intern(lit("cset"), user_package); - wild = intern(lit("wild"), user_package); - oneplus = intern(lit("1+"), user_package); - zeroplus = intern(lit("0+"), user_package); - optional = intern(lit("?"), user_package); - compound = intern(lit("compound"), user_package); - or = intern(lit("or"), user_package); - quasi = intern(lit("quasi"), system_package); - skip = intern(lit("skip"), user_package); - trailer = intern(lit("trailer"), user_package); - block = intern(lit("block"), user_package); - next = intern(lit("next"), user_package); - freeform = intern(lit("freeform"), user_package); - fail = intern(lit("fail"), user_package); - accept = intern(lit("accept"), user_package); - all = intern(lit("all"), user_package); - some = intern(lit("some"), user_package); - none = intern(lit("none"), user_package); - maybe = intern(lit("maybe"), user_package); - cases = intern(lit("cases"), user_package); - collect = intern(lit("collect"), user_package); - until = intern(lit("until"), user_package); - coll = intern(lit("coll"), user_package); - define = intern(lit("define"), user_package); - output = intern(lit("output"), user_package); - single = intern(lit("single"), user_package); - frst = intern(lit("first"), user_package); - lst = intern(lit("last"), user_package); - empty = intern(lit("empty"), user_package); - repeat = intern(lit("repeat"), user_package); - rep = intern(lit("rep"), user_package); - flattn = intern(lit("flatten"), user_package); - forget = intern(lit("forget"), user_package); - local = intern(lit("local"), user_package); - mrge = intern(lit("merge"), user_package); - bind = intern(lit("bind"), user_package); - cat = intern(lit("cat"), user_package); - args = intern(lit("args"), user_package); - try = intern(lit("try"), user_package); - catch = intern(lit("catch"), user_package); - finally = intern(lit("finally"), user_package); - nothrow = intern(lit("nothrow"), user_package); - throw = intern(lit("throw"), user_package); - defex = intern(lit("defex"), user_package); - error = intern(lit("error"), user_package); - type_error = intern(lit("type_error"), user_package); - internal_err = intern(lit("internal_error"), user_package); - numeric_err = intern(lit("numeric_error"), user_package); - range_err = intern(lit("range_error"), user_package); - query_error = intern(lit("query_error"), user_package); - file_error = intern(lit("file_error"), user_package); - process_error = intern(lit("process_error"), user_package); + cons_s = intern(lit("cons"), user_package); + str_s = intern(lit("str"), user_package); + chr_s = intern(lit("chr"), user_package); + num_s = intern(lit("num"), user_package); + sym_s = intern(lit("sym"), user_package); + pkg_s = intern(lit("pkg"), user_package); + fun_s = intern(lit("fun"), user_package); + vec_s = intern(lit("vec"), user_package); + stream_s = intern(lit("stream"), user_package); + hash_s = intern(lit("hash"), user_package); + lcons_s = intern(lit("lcons"), user_package); + lstr_s = intern(lit("lstr"), user_package); + cobj_s = intern(lit("cobj"), user_package); + var_s = intern(lit("var"), system_package); + regex_s = intern(lit("regex"), system_package); + set_s = intern(lit("set"), user_package); + cset_s = intern(lit("cset"), user_package); + wild_s = intern(lit("wild"), user_package); + oneplus_s = intern(lit("1+"), user_package); + zeroplus_s = intern(lit("0+"), user_package); + optional_s = intern(lit("?"), user_package); + compound_s = intern(lit("compound"), user_package); + or_s = intern(lit("or"), user_package); + quasi_s = intern(lit("quasi"), system_package); + skip_s = intern(lit("skip"), user_package); + trailer_s = intern(lit("trailer"), user_package); + block_s = intern(lit("block"), user_package); + next_s = intern(lit("next"), user_package); + freeform_s = intern(lit("freeform"), user_package); + fail_s = intern(lit("fail"), user_package); + accept_s = intern(lit("accept"), user_package); + all_s = intern(lit("all"), user_package); + some_s = intern(lit("some"), user_package); + none_s = intern(lit("none"), user_package); + maybe_s = intern(lit("maybe"), user_package); + cases_s = intern(lit("cases"), user_package); + collect_s = intern(lit("collect"), user_package); + until_s = intern(lit("until"), user_package); + coll_s = intern(lit("coll"), user_package); + define_s = intern(lit("define"), user_package); + output_s = intern(lit("output"), user_package); + single_s = intern(lit("single"), user_package); + first_s = intern(lit("first"), user_package); + last_s = intern(lit("last"), user_package); + 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); + 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); + type_error_s = intern(lit("type_error"), user_package); + internal_error_s = intern(lit("internal_error"), user_package); + numeric_error_s = intern(lit("numeric_error"), user_package); + range_error_s = intern(lit("range_error"), user_package); + query_error_s = intern(lit("query_error"), user_package); + file_error_s = intern(lit("file_error"), user_package); + process_error_s = intern(lit("process_error"), user_package); equal_f = func_f2(nil, equal_tramp); identity_f = func_f1(nil, identity_tramp); @@ -193,17 +193,19 @@ inline wchar_t *litptr(val obj) #define lit(strlit) lit_noex(strlit) extern val keyword_package; -extern val t, cons_t, str_t, chr_t, num_t, sym_t, pkg_t, fun_t, vec_t; -extern val stream_t, hash_t, lcons_t, lstr_t, cobj_t; -extern val var, regex, set, cset, wild, oneplus; -extern val zeroplus, optional, compound, or, quasi; -extern val skip, trailer, block, next, freeform, fail, accept; -extern val all, some, none, maybe, cases, collect, until, coll; -extern val define, output, single, frst, lst, empty, repeat, rep; -extern val flattn, forget, local, mrge, bind, cat, args; -extern val try, catch, finally, nothrow, throw, defex; -extern val error, type_error, internal_err, numeric_err, range_err; -extern val query_error, file_error, process_error; +extern val t, cons_s, str_s, chr_s, num_s, sym_s, pkg_s, fun_s, vec_s; +extern val stream_s, hash_s, lcons_s, lstr_s, cobj_s; +extern val var_s, regex_s, set_s, cset_s, wild_s, oneplus_s; +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 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 zero, one, two, negone, maxint, minint; extern val null_string; @@ -82,7 +82,7 @@ static void sem_error(val line, val fmt, ...) (void) vformat(stream, fmt, vl); va_end (vl); - uw_throw(query_error, get_string_from_stream(stream)); + uw_throw(query_error_s, get_string_from_stream(stream)); abort(); } @@ -97,7 +97,7 @@ static void file_err(val line, val fmt, ...) (void) vformat(stream, fmt, vl); va_end (vl); - uw_throw(file_error, get_string_from_stream(stream)); + uw_throw(file_error_s, get_string_from_stream(stream)); abort(); } @@ -132,7 +132,6 @@ void dump_var(val var, char *pfx1, size_t len1, if (len1 >= 112 || len2 >= 112) internal_error("too much depth in bindings"); - if (listp(value)) { val iter; int i; @@ -308,7 +307,7 @@ val match_line(val bindings, val specline, val dataline, { val directive = first(elem); - if (directive == var) { + if (directive == var_s) { val sym = second(elem); val pat = third(elem); val modifier = fourth(elem); @@ -378,7 +377,7 @@ val match_line(val bindings, val specline, val dataline, LOG_MATCH("var delimiting string", find); bindings = acons_new(bindings, sym, sub_str(dataline, pos, find)); pos = plus(find, length_str(pat)); - } else if (consp(pat) && typeof(first(pat)) == regex) { + } else if (consp(pat) && typeof(first(pat)) == regex_s) { val find = search_regex(dataline, first(pat), pos, modifier); val fpos = car(find); val flen = cdr(find); @@ -389,7 +388,7 @@ val match_line(val bindings, val specline, val dataline, LOG_MATCH("var delimiting regex", fpos); bindings = acons_new(bindings, sym, sub_str(dataline, pos, fpos)); pos = plus(fpos, flen); - } else if (consp(pat) && first(pat) == var) { + } else if (consp(pat) && first(pat) == var_s) { /* Unbound var followed by var: the following one must be bound. */ val second_sym = second(pat); val next_pat = third(pat); @@ -401,7 +400,7 @@ val match_line(val bindings, val specline, val dataline, /* Re-generate a new spec with an edited version of the element we just processed, and repeat. */ { - val new_elem = list(var, sym, cdr(pair), modifier, nao); + val new_elem = list(var_s, sym, cdr(pair), modifier, nao); if (next_pat) specline = cons(new_elem, cons(next_pat, rest(specline))); @@ -422,7 +421,7 @@ val match_line(val bindings, val specline, val dataline, sem_error(spec_lineno, lit("variable followed by invalid element"), nao); } - } else if (typeof(directive) == regex) { + } else if (typeof(directive) == regex_s) { val past = match_regex(dataline, directive, pos); if (nullp(past)) { LOG_MISMATCH("regex"); @@ -430,7 +429,7 @@ val match_line(val bindings, val specline, val dataline, } LOG_MATCH("regex", past); pos = past; - } else if (directive == coll) { + } else if (directive == coll_s) { val coll_specline = second(elem); val until_specline = third(elem); val bindings_coll = nil; @@ -563,7 +562,7 @@ val subst_vars(val spec, val bindings) val elem = first(spec); if (consp(elem)) { - if (first(elem) == var) { + if (first(elem) == var_s) { val sym = second(elem); val pat = third(elem); val modifier = fourth(elem); @@ -578,7 +577,7 @@ val subst_vars(val spec, val bindings) spec = cons(cdr(pair), rest(spec)); continue; } - } else if (first(elem) == quasi) { + } else if (first(elem) == quasi_s) { val nested = subst_vars(rest(elem), bindings); list_collect_append(iter, nested); spec = cdr(spec); @@ -605,7 +604,7 @@ val eval_form(val form, val bindings) } else if (bindable(form)) { return assoc(bindings, form); } else if (consp(form)) { - if (car(form) == quasi) { + if (car(form) == quasi_s) { return cons(t, cat_str(subst_vars(rest(form), bindings), nil)); } else if (regexp(car(form))) { return cons(t, form); @@ -709,7 +708,7 @@ val complex_stream(fpip_t fp, val name) case fpip_pclose: return make_pipe_stream(fp.f, name, t, nil); case fpip_closedir: - uw_throwf(query_error, lit("cannot output to directory: ~a"), name, nao); + uw_throwf(query_error_s, lit("cannot output to directory: ~a"), name, nao); } internal_error("bad input source type"); @@ -744,7 +743,7 @@ val extract_vars(val output_spec) list_collect_decl (vars, tai); if (consp(output_spec)) { - if (first(output_spec) == var) { + if (first(output_spec) == var_s) { list_collect (tai, second(output_spec)); } else { for (; output_spec; output_spec = cdr(output_spec)) @@ -778,13 +777,13 @@ void do_output_line(val bindings, val specline, { val directive = first(elem); - if (directive == var) { + if (directive == var_s) { val str = cat_str(subst_vars(cons(elem, nil), bindings), nil); if (str == nil) sem_error(spec_lineno, lit("bad substitution: ~a"), second(elem), nao); put_string(out, str); - } else if (directive == rep) { + } else if (directive == rep_s) { val main_clauses = second(elem); val single_clauses = third(elem); val first_clauses = fourth(elem); @@ -850,7 +849,7 @@ void do_output(val bindings, val specs, val out) if (consp(first_elem)) { val sym = first(first_elem); - if (sym == repeat) { + if (sym == repeat_s) { val main_clauses = second(first_elem); val single_clauses = third(first_elem); val first_clauses = fourth(first_elem); @@ -912,14 +911,14 @@ val match_files(val spec, val files, fpip_t fp = (errno = 0, complex_open(name, nil)); val first_spec_item = second(first(spec)); - if (consp(first_spec_item) && eq(first(first_spec_item), next)) { + if (consp(first_spec_item) && eq(first(first_spec_item), next_s)) { debugf(lit("not opening source ~a " "since query starts with next directive"), name, nao); } else { debugf(lit("opening data source ~a"), name, nao); if (complex_open_failed(fp)) { - if (consp(source_spec) && car(source_spec) == nothrow) { + if (consp(source_spec) && car(source_spec) == nothrow_s) { debugf(lit("could not open ~a: " "treating as failed match due to nothrow"), name, nao); return nil; @@ -949,7 +948,7 @@ repeat_spec_same_data: if (consp(first_spec)) { val sym = first(first_spec); - if (sym == skip) { + if (sym == skip_s) { val max = first(rest(first_spec)); cnum cmax = nump(max) ? c_num(max) : 0; cnum reps = 0; @@ -989,7 +988,7 @@ repeat_spec_same_data: debuglf(spec_linenum, lit("skip failed"), nao); return nil; - } else if (sym == trailer) { + } else if (sym == trailer_s) { if (rest(specline)) sem_error(spec_linenum, lit("unexpected material after trailer directive"), nao); @@ -1006,7 +1005,7 @@ repeat_spec_same_data: return cons(new_bindings, cons(data, num(data_lineno))); return nil; } - } else if (sym == freeform) { + } else if (sym == freeform_s) { val args = rest(first_spec); val vals = mapcar(func_n1(cdr), mapcar(bind2other(func_n2(eval_form), @@ -1042,7 +1041,7 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == block) { + } else if (sym == block_s) { val name = first(rest(first_spec)); if (rest(specline)) sem_error(spec_linenum, @@ -1055,14 +1054,14 @@ repeat_spec_same_data: uw_block_end; return result; } - } else if (sym == fail || sym == accept) { + } else if (sym == fail_s || sym == accept_s) { val target = first(rest(first_spec)); if (rest(specline)) sem_error(spec_linenum, lit("unexpected material after ~a"), sym, nao); uw_block_return(target, - if2(sym == accept, + if2(sym == accept_s, cons(bindings, if3(data, cons(data, num(data_lineno)), t)))); /* TODO: uw_block_return could just throw this */ @@ -1073,7 +1072,7 @@ repeat_spec_same_data: sem_error(spec_linenum, lit("%~a: no anonymous block in scope"), sym, nao); return nil; - } else if (sym == next) { + } else if (sym == next_s) { if (rest(first_spec) && rest(specline)) sem_error(spec_linenum, lit("invalid combination of old " "and new next syntax"), nao); @@ -1084,9 +1083,9 @@ repeat_spec_same_data: if (rest(first_spec)) { val source = rest(first_spec); - if (eq(first(source), nothrow)) + if (eq(first(source), nothrow_s)) push(nil, &source); - else if (eq(first(source), args)) { + else if (eq(first(source), args_s)) { val input_name = string(L"args"); cons_bind (new_bindings, success, match_files(spec, cons(input_name, files), @@ -1105,16 +1104,16 @@ repeat_spec_same_data: sem_error(spec_linenum, lit("next: unbound variable in form ~a"), first(source), nao); - if (eq(second(source), nothrow)) { + if (eq(second(source), nothrow_s)) { if (name) { - files = cons(cons(nothrow, name), files); + files = cons(cons(nothrow_s, name), files); } else { files = rest(files); if (!files) { debuglf(spec_linenum, lit("next: out of arguments"), nao); return nil; } - files = cons(cons(nothrow, first(files)), rest(files)); + files = cons(cons(nothrow_s, first(files)), rest(files)); } } else { if (name) { @@ -1123,7 +1122,7 @@ repeat_spec_same_data: files = rest(files); if (!files) sem_error(spec_linenum, lit("next: out of arguments"), nao); - files = cons(cons(nothrow, first(files)), rest(files)); + files = cons(cons(nothrow_s, first(files)), rest(files)); } } } @@ -1135,7 +1134,7 @@ repeat_spec_same_data: nao); continue; } - files = cons(cons(nothrow, str), files); + files = cons(cons(nothrow_s, str), files); } else { files = rest(files); if (!files) @@ -1154,8 +1153,8 @@ repeat_spec_same_data: if3(data, cons(data, num(data_lineno)), t)); return nil; } - } else if (sym == some || sym == all || sym == none || sym == maybe || - sym == cases) + } else if (sym == some_s || sym == all_s || sym == none_s || + sym == maybe_s || sym == cases_s) { val specs; val all_match = t; @@ -1185,24 +1184,24 @@ repeat_spec_same_data: max_data = new_data; } } - if (sym == cases) + if (sym == cases_s) break; } else { all_match = nil; } } - if (sym == all && !all_match) { + if (sym == all_s && !all_match) { debuglf(spec_linenum, lit("all: some clauses didn't match"), nao); return nil; } - if ((sym == some || sym == cases) && !some_match) { + if ((sym == some_s || sym == cases_s) && !some_match) { debuglf(spec_linenum, lit("some/cases: no clauses matched"), nao); return nil; } - if (sym == none && some_match) { + if (sym == none_s && some_match) { debuglf(spec_linenum, lit("none: some clauses matched"), nao); return nil; } @@ -1220,7 +1219,7 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == collect) { + } else if (sym == collect_s) { val coll_spec = second(first_spec); val until_spec = third(first_spec); val bindings_coll = nil; @@ -1310,7 +1309,7 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == flattn) { + } else if (sym == flattn_s) { val iter; for (iter = rest(first_spec); iter; iter = rest(iter)) { @@ -1331,14 +1330,14 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == forget || sym == local) { + } else if (sym == forget_s || sym == local_s) { bindings = alist_remove(bindings, rest(first_spec)); if ((spec = rest(spec)) == nil) break; goto repeat_spec_same_data; - } else if (sym == mrge) { + } else if (sym == merge_s) { val target = first(rest(first_spec)); val args = rest(rest(first_spec)); val merged = nil; @@ -1370,7 +1369,7 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == bind) { + } else if (sym == bind_s) { val args = rest(first_spec); val pattern = first(args); val form = second(args); @@ -1389,7 +1388,7 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == cat) { + } else if (sym == cat_s) { val iter; for (iter = rest(first_spec); iter; iter = rest(iter)) { @@ -1416,7 +1415,7 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == output) { + } else if (sym == output_s) { val specs = second(first_spec); val old_style_dest = third(first_spec); val new_style_dest = fourth(first_spec); @@ -1427,7 +1426,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)) + if (eq(first(new_style_dest), nothrow_s)) push(nil, &new_style_dest); { @@ -1438,7 +1437,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); + nt = eq(second(new_style_dest), nothrow_s); dest = or2(cdr(val), string(L"-")); } } @@ -1468,7 +1467,7 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == define) { + } else if (sym == define_s) { val args = second(first_spec); val body = third(first_spec); val name = first(args); @@ -1484,7 +1483,7 @@ repeat_spec_same_data: break; goto repeat_spec_same_data; - } else if (sym == try) { + } else if (sym == try_s) { val catch_syms = second(first_spec); val try_clause = third(first_spec); val catch_fin = fourth(first_spec); @@ -1513,7 +1512,7 @@ repeat_spec_same_data: exvals, cons(cons(t, exvals), nil)); - if (first(clause) == catch) { + if (first(clause) == catch_s) { if (uw_exception_subtype_p(exsym, type)) { val all_bind = t; val piter, viter; @@ -1552,7 +1551,7 @@ repeat_spec_same_data: } break; } - } else if (car(clause) == finally) { + } else if (car(clause) == finally_s) { finally_clause = body; } } @@ -1581,7 +1580,7 @@ repeat_spec_same_data: if (!finally_clause) { for (iter = catch_fin; iter; iter = cdr(iter)) { val clause = car(iter); - if (first(clause) == finally) { + if (first(clause) == finally_s) { finally_clause = third(clause); break; } @@ -1616,7 +1615,7 @@ repeat_spec_same_data: goto repeat_spec_same_data; } - } else if (sym == defex) { + } else if (sym == defex_s) { val types = rest(first_spec); if (!all_satisfy(types, func_n1(symbolp), nil)) sem_error(spec_linenum, lit("defex arguments must all be symbols"), @@ -1625,7 +1624,7 @@ repeat_spec_same_data: if ((spec = rest(spec)) == nil) break; goto repeat_spec_same_data; - } else if (sym == throw) { + } else if (sym == throw_s) { val type = second(first_spec); val args = rest(rest(first_spec)); if (!symbolp(type)) @@ -111,7 +111,7 @@ clause : all_clause { $$ = list(num(lineno - 1), $1, nao); } yyerror("repeat outside of output"); } ; -all_clause : ALL newl clause_parts { $$ = cons(all, $3); } +all_clause : ALL newl clause_parts { $$ = cons(all_s, $3); } | ALL newl error { $$ = nil; yybadtoken(yychar, "all clause"); } @@ -120,7 +120,7 @@ all_clause : ALL newl clause_parts { $$ = cons(all, $3); } ; -some_clause : SOME newl clause_parts { $$ = cons(some, $3); } +some_clause : SOME newl clause_parts { $$ = cons(some_s, $3); } | SOME newl error { $$ = nil; yybadtoken(yychar, "some clause"); } @@ -128,7 +128,7 @@ some_clause : SOME newl clause_parts { $$ = cons(some, $3); } yyerror("empty some clause"); } ; -none_clause : NONE newl clause_parts { $$ = cons(none, $3); } +none_clause : NONE newl clause_parts { $$ = cons(none_s, $3); } | NONE newl error { $$ = nil; yybadtoken(yychar, "none clause"); } @@ -136,7 +136,7 @@ none_clause : NONE newl clause_parts { $$ = cons(none, $3); } yyerror("empty none clause"); } ; -maybe_clause : MAYBE newl clause_parts { $$ = cons(maybe, $3); } +maybe_clause : MAYBE newl clause_parts { $$ = cons(maybe_s, $3); } | MAYBE newl error { $$ = nil; yybadtoken(yychar, "maybe clause"); } @@ -144,7 +144,7 @@ maybe_clause : MAYBE newl clause_parts { $$ = cons(maybe, $3); } yyerror("empty maybe clause"); } ; -cases_clause : CASES newl clause_parts { $$ = cons(cases, $3); } +cases_clause : CASES newl clause_parts { $$ = cons(cases_s, $3); } | CASES newl error { $$ = nil; yybadtoken(yychar, "cases clause"); } @@ -152,9 +152,10 @@ cases_clause : CASES newl clause_parts { $$ = cons(cases, $3); } yyerror("empty cases clause"); } ; -collect_clause : COLLECT newl clauses END newl { $$ = list(collect, $3, nao); } +collect_clause : COLLECT newl clauses END newl { $$ = list(collect_s, + $3, nao); } | COLLECT newl clauses - UNTIL newl clauses END newl { $$ = list(collect, $3, + UNTIL newl clauses END newl { $$ = list(collect_s, $3, $6, nao); } | COLLECT newl error { $$ = nil; if (yychar == UNTIL || yychar == END) @@ -189,19 +190,19 @@ elem : TEXT { $$ = string_own($1); } | var { $$ = $1; } | list { $$ = $1; } | regex { $$ = cons(regex_compile($1), $1); } - | COLL elems END { $$ = list(coll, $2, nao); } + | COLL elems END { $$ = list(coll_s, $2, nao); } | COLL elems - UNTIL elems END { $$ = list(coll, $2, $4, nao); } + UNTIL elems END { $$ = list(coll_s, $2, $4, nao); } | COLL error { $$ = nil; yybadtoken(yychar, "coll clause"); } ; define_clause : DEFINE exprs ')' newl clauses_opt - END newl { $$ = list(define, $2, $5, nao); } + END newl { $$ = list(define_s, $2, $5, nao); } | DEFINE ')' newl clauses_opt - END newl { $$ = list(define, nil, $4, nao); } + END newl { $$ = list(define_s, nil, $4, nao); } | DEFINE error { $$ = nil; yybadtoken(yychar, "list expression"); } | DEFINE exprs ')' newl @@ -214,7 +215,7 @@ define_clause : DEFINE exprs ')' newl try_clause : TRY newl clauses catch_clauses_opt - END newl { $$ = list(try, + END newl { $$ = list(try_s, flatten(mapcar(func_n1(second), $4)), $3, $4, nao); } @@ -233,14 +234,14 @@ try_clause : TRY newl catch_clauses_opt : CATCH ')' newl clauses_opt - catch_clauses_opt { $$ = cons(list(catch, cons(t, nil), + catch_clauses_opt { $$ = cons(list(catch_s, cons(t, nil), $4, nao), $5); } | CATCH exprs ')' newl clauses_opt - catch_clauses_opt { $$ = cons(list(catch, $2, $5, nao), + catch_clauses_opt { $$ = cons(list(catch_s, $2, $5, nao), $6); } | FINALLY newl - clauses_opt { $$ = cons(list(finally, nil, + clauses_opt { $$ = cons(list(finally_s, nil, $3, nao), nil); } | { $$ = nil; } @@ -258,13 +259,13 @@ catch_clauses_opt : CATCH ')' newl output_clause : OUTPUT ')' o_elems '\n' out_clauses - END newl { $$ = list(output, $5, $3, nao); } + END newl { $$ = list(output_s, $5, $3, nao); } | OUTPUT ')' newl out_clauses - END newl { $$ = list(output, $4, nao); } + END newl { $$ = list(output_s, $4, nao); } | OUTPUT exprs ')' newl out_clauses - END newl { $$ = list(output, $5, nil, $2, nao); } + END newl { $$ = list(output_s, $5, nil, $2, nao); } | OUTPUT exprs ')' o_elems '\n' out_clauses END newl { $$ = nil; @@ -316,7 +317,7 @@ out_clause : repeat_clause { $$ = list(num(lineno - 1), $1, nao); } repeat_clause : REPEAT newl out_clauses repeat_parts_opt - END newl { $$ = repeat_rep_helper(repeat, $3, $4); } + END newl { $$ = repeat_rep_helper(repeat_s, $3, $4); } | REPEAT newl error { $$ = nil; yybadtoken(yychar, "repeat clause"); } @@ -324,16 +325,16 @@ repeat_clause : REPEAT newl repeat_parts_opt : SINGLE newl out_clauses_opt - repeat_parts_opt { $$ = cons(cons(single, $3), $4); } + repeat_parts_opt { $$ = cons(cons(single_s, $3), $4); } | FIRST newl out_clauses_opt - repeat_parts_opt { $$ = cons(cons(frst, $3), $4); } + repeat_parts_opt { $$ = cons(cons(first_s, $3), $4); } | LAST newl out_clauses_opt - repeat_parts_opt { $$ = cons(cons(lst, $3), $4); } + repeat_parts_opt { $$ = cons(cons(last_s, $3), $4); } | EMPTY newl out_clauses_opt - repeat_parts_opt { $$ = cons(cons(empty, $3), $4); } + repeat_parts_opt { $$ = cons(cons(empty_s, $3), $4); } | /* empty */ { $$ = nil; } ; @@ -362,18 +363,18 @@ o_elem : TEXT { $$ = string_own($1); } ; rep_elem : REP o_elems - rep_parts_opt END { $$ = repeat_rep_helper(rep, $2, $3); } + rep_parts_opt END { $$ = repeat_rep_helper(rep_s, $2, $3); } | REP error { $$ = nil; yybadtoken(yychar, "rep clause"); } ; rep_parts_opt : SINGLE o_elems_opt2 - rep_parts_opt { $$ = cons(cons(single, $2), $3); } + rep_parts_opt { $$ = cons(cons(single_s, $2), $3); } | FIRST o_elems_opt2 - rep_parts_opt { $$ = cons(cons(frst, $2), $3); } + rep_parts_opt { $$ = cons(cons(first_s, $2), $3); } | LAST o_elems_opt2 - rep_parts_opt { $$ = cons(cons(lst, $2), $3); } + rep_parts_opt { $$ = cons(cons(last_s, $2), $3); } | EMPTY o_elems_opt2 - rep_parts_opt { $$ = cons(cons(empty, $2), $3); } + rep_parts_opt { $$ = cons(cons(empty_s, $2), $3); } | /* empty */ { $$ = nil; } ; @@ -381,26 +382,26 @@ rep_parts_opt : SINGLE o_elems_opt2 /* This sucks, but factoring '*' into a nonterminal * that generates an empty phrase causes reduce/reduce conflicts. */ -var : IDENT { $$ = list(var, intern(string_own($1), nil), +var : IDENT { $$ = list(var_s, intern(string_own($1), nil), nao); } - | IDENT elem { $$ = list(var, intern(string_own($1), nil), + | IDENT elem { $$ = list(var_s, intern(string_own($1), nil), $2, nao); } - | '{' IDENT '}' { $$ = list(var, intern(string_own($2), nil), + | '{' IDENT '}' { $$ = list(var_s, intern(string_own($2), nil), nao); } - | '{' IDENT '}' elem { $$ = list(var, intern(string_own($2), nil), + | '{' IDENT '}' elem { $$ = list(var_s, intern(string_own($2), nil), $4, nao); } - | '{' IDENT regex '}' { $$ = list(var, intern(string_own($2), nil), + | '{' IDENT regex '}' { $$ = list(var_s, intern(string_own($2), nil), nil, cons(regex_compile($3), $3), nao); } - | '{' IDENT NUMBER '}' { $$ = list(var, intern(string_own($2), nil), + | '{' IDENT NUMBER '}' { $$ = list(var_s, intern(string_own($2), nil), nil, num($3), nao); } - | var_op IDENT { $$ = list(var, intern(string_own($2), nil), + | var_op IDENT { $$ = list(var_s, intern(string_own($2), nil), nil, $1, nao); } - | var_op IDENT elem { $$ = list(var, intern(string_own($2), nil), + | var_op IDENT elem { $$ = list(var_s, intern(string_own($2), nil), $3, $1, nao); } - | var_op '{' IDENT '}' { $$ = list(var, intern(string_own($3), nil), + | var_op '{' IDENT '}' { $$ = list(var_s, intern(string_own($3), nil), nil, $1, nao); } - | var_op '{' IDENT '}' elem { $$ = list(var, intern(string_own($3), nil), + | var_op '{' IDENT '}' elem { $$ = list(var_s, intern(string_own($3), nil), $5, $1, nao); } | var_op '{' IDENT regex '}' { $$ = nil; yyerror("longest match " @@ -447,7 +448,7 @@ regex : '/' regexpr '/' { $$ = $2; } ; regexpr : regbranch { $$ = $1; } - | regbranch '|' regbranch { $$ = list(list(or, $1, + | regbranch '|' regbranch { $$ = list(list(or_s, $1, $3, nao), nao); } ; @@ -455,17 +456,17 @@ regbranch : regterm { $$ = cons($1, nil); } | regterm regbranch { $$ = cons($1, $2); } ; -regterm : '[' regclass ']' { $$ = cons(set, $2); } - | '[' '^' regclass ']' { $$ = cons(cset, $3); } - | '.' { $$ = wild; } +regterm : '[' regclass ']' { $$ = cons(set_s, $2); } + | '[' '^' regclass ']' { $$ = cons(cset_s, $3); } + | '.' { $$ = wild_s; } | '^' { $$ = chr('^'); } | ']' { $$ = chr(']'); } | '-' { $$ = chr('-'); } - | regterm '*' { $$ = list(zeroplus, $1, nao); } - | regterm '+' { $$ = list(oneplus, $1, nao); } - | regterm '?' { $$ = list(optional, $1, nao); } + | regterm '*' { $$ = list(zeroplus_s, $1, nao); } + | regterm '+' { $$ = list(oneplus_s, $1, nao); } + | regterm '?' { $$ = list(optional_s, $1, nao); } | REGCHAR { $$ = chr($1); } - | '(' regexpr ')' { $$ = cons(compound, $2); } + | '(' regexpr ')' { $$ = cons(compound_s, $2); } | '(' error { $$ = nil; yybadtoken(yychar, "regex subexpression"); } | '[' error { $$ = nil; @@ -516,7 +517,7 @@ chrlit : '\'' '\'' { $$ = nil; ; quasilit : '`' '`' { $$ = null_string; } - | '`' quasi_items '`' { $$ = cons(quasi, $2); } + | '`' quasi_items '`' { $$ = cons(quasi_s, $2); } | '`' error { $$ = nil; yybadtoken(yychar, "string literal"); } ; @@ -551,13 +552,13 @@ val repeat_rep_helper(val sym, val main, val parts) val sym = car(part); val clauses = cdr(part); - if (sym == single) + if (sym == single_s) single_parts = nappend2(single_parts, clauses); - else if (sym == frst) + else if (sym == first_s) first_parts = nappend2(first_parts, clauses); - else if (sym == lst) + else if (sym == last_s) last_parts = nappend2(last_parts, clauses); - else if (sym == empty) + else if (sym == empty_s) empty_parts = nappend2(empty_parts, clauses); else abort(); @@ -575,7 +576,7 @@ val define_transform(val define_form) if (define_form == nil) return nil; - assert (sym == define); + assert (sym == define_s); if (args == nil) { yyerror("define requires arguments"); @@ -565,7 +565,7 @@ nfa_t nfa_compile_set(val args, int compl) val from = car(item); val to = cdr(item); - assert (typeof(from) == chr_t && typeof(to) == chr_t); + assert (typeof(from) == chr_s && typeof(to) == chr_s); if (c_chr(from) < min) min = c_chr(from); @@ -576,7 +576,7 @@ nfa_t nfa_compile_set(val args, int compl) min = c_chr(to); if (c_chr(to) > max) max = c_chr(to); - } else if (typeof(item) == chr_t) { + } else if (typeof(item) == chr_s) { if (c_chr(item) < min) min = c_chr(item); if (c_chr(item) > max) @@ -608,9 +608,9 @@ nfa_t nfa_compile_set(val args, int compl) val from = car(item); val to = cdr(item); - assert (typeof(from) == chr_t && typeof(to) == chr_t); + assert (typeof(from) == chr_s && typeof(to) == chr_s); char_set_add_range(set, c_chr(from), c_chr(to)); - } else if (typeof(item) == chr_t) { + } else if (typeof(item) == chr_s) { char_set_add(set, c_chr(item)); } else { assert(0 && "bad regex set"); @@ -639,11 +639,11 @@ nfa_t nfa_compile_regex(val items) val item = first(items), others = rest(items); nfa_t nfa; - if (typeof(item) == chr_t) { + if (typeof(item) == chr_s) { nfa_state_t *acc = nfa_state_accept(); nfa_state_t *s = nfa_state_single(acc, c_chr(item)); nfa = nfa_make(s, acc); - } else if (item == wild) { + } else if (item == wild_s) { nfa_state_t *acc = nfa_state_accept(); nfa_state_t *s = nfa_state_wild(acc); nfa = nfa_make(s, acc); @@ -651,13 +651,13 @@ nfa_t nfa_compile_regex(val items) val sym = first(item); val args = rest(item); - if (sym == set) { + if (sym == set_s) { nfa = nfa_compile_set(args, 0); - } else if (sym == cset) { + } else if (sym == cset_s) { nfa = nfa_compile_set(args, 1); - } else if (sym == compound) { + } else if (sym == compound_s) { nfa = nfa_compile_regex(args); - } else if (sym == zeroplus) { + } else if (sym == zeroplus_s) { nfa_t nfa_args = nfa_compile_regex(args); nfa_state_t *acc = nfa_state_accept(); /* New start state has empty transitions going through @@ -668,7 +668,7 @@ nfa_t nfa_compile_regex(val items) an empty transition to the new acceptance state. */ nfa_state_empty_convert(nfa_args.accept, nfa_args.start, acc); nfa = nfa_make(s, acc); - } else if (sym == oneplus) { + } else if (sym == oneplus_s) { /* One-plus case differs from zero-plus in that the new start state does not have an empty transition to the acceptance state. So the inner NFA must be traversed once. */ @@ -677,7 +677,7 @@ nfa_t nfa_compile_regex(val items) nfa_state_t *s = nfa_state_empty(nfa_args.start, 0); /* <-- diff */ nfa_state_empty_convert(nfa_args.accept, nfa_args.start, acc); nfa = nfa_make(s, acc); - } else if (sym == optional) { + } else if (sym == optional_s) { /* In this case, we can keep the acceptance state of the inner NFA as the acceptance state of the new NFA. We simply add a new start state which can short-circuit to it via an empty @@ -685,7 +685,7 @@ nfa_t nfa_compile_regex(val items) nfa_t nfa_args = nfa_compile_regex(args); nfa_state_t *s = nfa_state_empty(nfa_args.start, nfa_args.accept); nfa = nfa_make(s, nfa_args.accept); - } else if (sym == or) { + } else if (sym == or_s) { /* Simple: make a new start and acceptance state, which form the ends of a spindle that goes through two branches. */ nfa_t nfa_first = nfa_compile_regex(first(args)); @@ -1057,18 +1057,18 @@ val regex_compile(val regex_sexp) { nfa_t *pnfa = (nfa_t *) chk_malloc(sizeof *pnfa); *pnfa = nfa_compile_regex(regex_sexp); - return cobj(pnfa, regex, ®ex_obj_ops); + return cobj(pnfa, regex_s, ®ex_obj_ops); } val regexp(val obj) { - return (is_ptr(obj) && obj->co.type == COBJ && obj->co.cls == regex) + return (is_ptr(obj) && obj->co.type == COBJ && obj->co.cls == regex_s) ? t : nil; } nfa_t *regex_nfa(val reg) { - assert (reg->co.type == COBJ && reg->co.cls == regex); + assert (reg->co.type == COBJ && reg->co.cls == regex_s); return (nfa_t *) reg->co.handle; } @@ -93,10 +93,10 @@ static val stdio_maybe_read_error(val stream) { struct stdio_handle *h = (struct stdio_handle *) stream->co.handle; if (h->f == 0) - uw_throwf(file_error, lit("error reading ~a: file closed"), stream, nao); + uw_throwf(file_error_s, lit("error reading ~a: file closed"), stream, nao); if (ferror(h->f)) { clearerr(h->f); - uw_throwf(file_error, lit("error reading ~a: ~a/~s"), + uw_throwf(file_error_s, lit("error reading ~a: ~a/~s"), stream, num(errno), string_utf8(strerror(errno)), nao); } return nil; @@ -106,9 +106,9 @@ static val stdio_maybe_write_error(val stream) { struct stdio_handle *h = (struct stdio_handle *) stream->co.handle; if (h->f == 0) - uw_throwf(file_error, lit("error reading ~a: file closed"), stream, nao); + uw_throwf(file_error_s, lit("error reading ~a: file closed"), stream, nao); clearerr(h->f); - uw_throwf(file_error, lit("error writing ~a: ~a/~s"), + uw_throwf(file_error_s, lit("error writing ~a: ~a/~s"), stream, num(errno), string_utf8(strerror(errno)), nao); } @@ -217,7 +217,7 @@ static val stdio_close(val stream, val throw_on_error) int result = fclose(h->f); h->f = 0; if (result == EOF && throw_on_error) { - uw_throwf(file_error, lit("error closing ~a: ~a/~s"), + uw_throwf(file_error_s, lit("error closing ~a: ~a/~s"), stream, num(errno), string_utf8(strerror(errno)), nao); } return result != EOF ? t : nil; @@ -249,24 +249,24 @@ static val pipe_close(val stream, val throw_on_error) if (status != 0 && throw_on_error) { if (status < 0) { - uw_throwf(process_error, + uw_throwf(process_error_s, lit("unable to obtain status of command ~a: ~a/~s"), stream, num(errno), string_utf8(strerror(errno)), nao); } else if (WIFEXITED(status)) { int exitstatus = WEXITSTATUS(status); - uw_throwf(process_error, lit("pipe ~a terminated with status ~a"), + uw_throwf(process_error_s, lit("pipe ~a terminated with status ~a"), stream, num(exitstatus), nao); } else if (WIFSIGNALED(status)) { int termsig = WTERMSIG(status); - uw_throwf(process_error, lit("pipe ~a terminated by signal ~a"), + uw_throwf(process_error_s, lit("pipe ~a terminated by signal ~a"), stream, num(termsig), nao); } else if (WIFSTOPPED(status) || WIFCONTINUED(status)) { - uw_throwf(process_error, + uw_throwf(process_error_s, lit("processes of closed pipe ~a still running"), stream, nao); } else { - uw_throwf(file_error, lit("strange status in when closing pipe ~a"), + uw_throwf(file_error_s, lit("strange status in when closing pipe ~a"), stream, nao); } } @@ -486,7 +486,7 @@ static struct strm_ops dir_ops = { val make_stdio_stream(FILE *f, val descr, val input, val output) { struct stdio_handle *h = (struct stdio_handle *) chk_malloc(sizeof *h); - val stream = cobj((void *) h, stream_t, &stdio_ops.cobj_ops); + val stream = cobj((void *) h, stream_s, &stdio_ops.cobj_ops); h->f = f; h->descr = descr; utf8_decoder_init(&h->ud); @@ -496,7 +496,7 @@ val make_stdio_stream(FILE *f, val descr, val input, val output) val make_pipe_stream(FILE *f, val descr, val input, val output) { struct stdio_handle *h = (struct stdio_handle *) chk_malloc(sizeof *h); - val stream = cobj((void *) h, stream_t, &pipe_ops.cobj_ops); + val stream = cobj((void *) h, stream_s, &pipe_ops.cobj_ops); h->f = f; h->descr = descr; utf8_decoder_init(&h->ud); @@ -505,7 +505,7 @@ val make_pipe_stream(FILE *f, val descr, val input, val output) val make_string_input_stream(val string) { - return cobj((void *) cons(string, zero), stream_t, &string_in_ops.cobj_ops); + return cobj((void *) cons(string, zero), stream_s, &string_in_ops.cobj_ops); } val make_string_byte_input_stream(val string) @@ -518,7 +518,7 @@ val make_string_byte_input_stream(val string) bi->buf = utf8; bi->size = strlen((char *) utf8); bi->index = 0; - return cobj(bi, stream_t, &byte_in_ops.cobj_ops); + return cobj(bi, stream_s, &byte_in_ops.cobj_ops); } } @@ -529,13 +529,13 @@ val make_string_output_stream(void) so->buf = (wchar_t *) chk_malloc(so->size * sizeof so->buf); so->fill = 0; so->buf[0] = 0; - return cobj((void *) so, stream_t, &string_out_ops.cobj_ops); + return cobj((void *) so, stream_s, &string_out_ops.cobj_ops); } val get_string_from_stream(val stream) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); if (stream->co.ops == &string_out_ops.cobj_ops) { @@ -562,13 +562,13 @@ val get_string_from_stream(val stream) val make_dir_stream(DIR *dir) { - return cobj((void *) dir, stream_t, &dir_ops.cobj_ops); + return cobj((void *) dir, stream_s, &dir_ops.cobj_ops); } val close_stream(val stream, val throw_on_error) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, (lit("~a is not a stream"), + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); { @@ -580,7 +580,7 @@ val close_stream(val stream, val throw_on_error) val get_line(val stream) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, (lit("~a is not a stream"), + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); { @@ -592,7 +592,7 @@ val get_line(val stream) val get_char(val stream) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, (lit("~a is not a stream"), + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); { @@ -604,7 +604,7 @@ val get_char(val stream) val get_byte(val stream) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, (lit("~a is not a stream"), + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); { @@ -710,7 +710,7 @@ val vformat_str(val stream, val str, int width, int left, val vformat(val stream, val fmtstr, va_list vl) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, (lit("~a is not a stream"), + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); { @@ -912,7 +912,7 @@ toobig: val format(val stream, val str, ...) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, (lit("~a is not a stream"), + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); { @@ -928,7 +928,7 @@ val format(val stream, val str, ...) val put_string(val stream, val string) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, (lit("~a is not a stream"), + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); { @@ -940,7 +940,7 @@ val put_string(val stream, val string) val put_char(val stream, val ch) { type_check (stream, COBJ); - type_assert (stream->co.cls == stream_t, (lit("~a is not a stream"), + type_assert (stream->co.cls == stream_s, (lit("~a is not a stream"), stream, nao)); { @@ -323,7 +323,7 @@ static int txr_main(int argc, char **argv) if (wcscmp(c_str(spec_file_str), L"-") != 0) { FILE *in = w_fopen(c_str(spec_file_str), L"r"); if (in == 0) - uw_throwf(file_error, lit("unable to open ~a"), spec_file_str, nao); + uw_throwf(file_error_s, lit("unable to open ~a"), spec_file_str, nao); yyin_stream = make_stdio_stream(in, spec_file_str, t, nil); } else { spec_file = L"stdin"; @@ -338,7 +338,7 @@ static int txr_main(int argc, char **argv) FILE *in = fopen(*argv, "r"); val name = string_utf8(*argv); if (in == 0) - uw_throwf(file_error, lit("unable to open ~a"), name, nao); + uw_throwf(file_error_s, lit("unable to open ~a"), name, nao); yyin_stream = make_stdio_stream(in, name, t, nil); spec_file = utf8_dup_from(*argv); } else { @@ -228,8 +228,8 @@ val uw_throw(val sym, val exception) format(std_error, s ? lit("~a: ~a\n") : lit("~a: ~s\n"), prog_string, exception, nao); } - if (uw_exception_subtype_p(sym, query_error) || - uw_exception_subtype_p(sym, file_error)) { + if (uw_exception_subtype_p(sym, query_error_s) || + uw_exception_subtype_p(sym, file_error_s)) { if (!output_produced) put_line(std_output, lit("false")); exit(EXIT_FAILURE); @@ -266,7 +266,7 @@ val uw_errorf(val fmt, ...) (void) vformat(stream, fmt, vl); va_end (vl); - uw_throw(error, get_string_from_stream(stream)); + uw_throw(error_s, get_string_from_stream(stream)); abort(); } @@ -279,7 +279,7 @@ val type_mismatch(val fmt, ...) (void) vformat(stream, fmt, vl); va_end (vl); - uw_throw(type_error, get_string_from_stream(stream)); + uw_throw(type_error_s, get_string_from_stream(stream)); abort(); } @@ -297,21 +297,23 @@ val uw_register_subtype(val sub, val sup) if (sub == t) { if (sup == t) return sup; - uw_throwf(type_error, lit("cannot define ~a as an exception subtype of ~a"), + uw_throwf(type_error_s, + lit("cannot define ~a as an exception subtype of ~a"), sub, sup, nao); } if (sup == nil) { - uw_throwf(type_error, lit("cannot define ~a as an exception subtype of ~a"), + uw_throwf(type_error_s, + lit("cannot define ~a as an exception subtype of ~a"), sub, sup, nao); } if (uw_exception_subtype_p(sub, sup)) - uw_throwf(type_error, lit("~a is already an exception subtype of ~a"), + uw_throwf(type_error_s, lit("~a is already an exception subtype of ~a"), sub, sup, nao); if (uw_exception_subtype_p(sup, sub)) - uw_throwf(type_error, lit("~a is already an exception supertype of ~a"), + uw_throwf(type_error_s, lit("~a is already an exception supertype of ~a"), sub, sup, nao); /* If sup symbol not registered, then we make it @@ -343,11 +345,11 @@ void uw_init(void) { protect(&toplevel_env.ev.func_bindings, &exception_subtypes, (val *) 0); exception_subtypes = cons(cons(t, nil), exception_subtypes); - uw_register_subtype(type_error, error); - uw_register_subtype(internal_err, error); - uw_register_subtype(numeric_err, error); - uw_register_subtype(range_err, error); - uw_register_subtype(query_error, error); - uw_register_subtype(file_error, error); - uw_register_subtype(process_error, error); + uw_register_subtype(type_error_s, error_s); + uw_register_subtype(internal_error_s, error_s); + uw_register_subtype(numeric_error_s, error_s); + uw_register_subtype(range_error_s, error_s); + uw_register_subtype(query_error_s, error_s); + uw_register_subtype(file_error_s, error_s); + uw_register_subtype(process_error_s, error_s); } @@ -149,7 +149,7 @@ noreturn val type_mismatch(val, ...); #define internal_error(STR) \ do { \ extern obj_t *num(cnum); \ - uw_throwf(internal_err, \ + uw_throwf(internal_error_s, \ lit("~a:~a ~a"), \ lit(__FILE__), \ num(__LINE__), lit(STR), \ @@ -167,13 +167,13 @@ noreturn val type_mismatch(val, ...); #define numeric_assert(EXPR) \ if (!(EXPR)) \ - uw_throwf(numeric_err, \ + uw_throwf(numeric_error_s, \ lit("assertion " #EXPR \ "failed"), nao) #define range_bug_unless(EXPR) \ if (!(EXPR)) \ - uw_throwf(range_err, \ + uw_throwf(range_error_s, \ lit("assertion " #EXPR \ "failed"), nao) |