| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c,
arith.h, cadr.c, cadr.h, combi.c, combi.h, configure,
debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c,
gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h,
lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h,
parser.l, parser.y, rand.c, rand.h, regex.c, regex.h,
share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl,
share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl,
share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl,
share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl,
share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl,
signal.c, signal.h, stream.c, stream.h, struct.c, struct.h,
sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h,
unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright.
* linenoise/LICENSE, linenoise/linenoise.c,
linenoise/linenoise.h: Bump one principal author's copyright
from 2014 to 2015. The code is based on a snapshot of 2015
upstream work.
|
|
|
|
|
|
|
|
|
|
|
| |
Same issue as with Vim syntax highlighting.
* eval.c (mboundp): Externalize static function.
* eval.h (mboundp): Declared.
* parser.c (find_matching_syms): Expand fboundp check to encompass
mboundp and special_operator_p.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (format_field): Function moved here from match.c,
along with the introduction of a new behavior: if a meta-expr
occurs among the modifiers, its constituent expression
is evaluated in its place. This allows for @{a @[expr]}
which was previously not allowed in Lisp quasiliterals,
but worked in TXR quasiliterals due to the treatment
of @ by txeval.
(subst_vars): Static function turns external, so code in
match.c can call it instead of the subst_vars in that module.
For that purpose, it needs to take a filter argument and
process filters, like the match.c subst_vars.
(op_quasi_lit): Pass nil as filter argument to subst_vars.
* eval.h (format_field, subst_vars): Declared.
* match.c (format_field): Function removed, moved to
eval.c and slightly changed.
(subst_vars): Renamed to tx_subst_vars. By default, now just a
wrapper for subst_vars. In compatibility mode, invokes the
old logic.
(do_txeval, do_output_line): Call tx_subst_vars rather than
subst_vars.
* match.h (format_field): Declaration removed.
* parser.y (expr): Grammar production removed: no longer
referenced.
(o_var): Braced variable case now parsed as n_expr, and
expanded as expr by default, since this is Lisp now. In
compatibility mode, expanded using expand_meta.
Also SYMTOK case must be subject to expansion; an output
var can now be a symbol macro.
(expand_meta): Expand a quasi-literal as Lisp, except
in compatibility mode.
* txr.1: Bit of a documentation update. Existing doc isn't
totally clear.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The context form arguments become just context objects in
various places. When a context form is actually needed, or the
context's symbolic name, they must be retrieved via functions
applied to a context.
* debug.c (debug): form argument is now a context. Use
the ctx_form function to retrieve the form.
* debug.h (debug_check): Rename form parameter to ctx.
* eval.c (ctx_form, ctx_name): New functions.
(eval_error): Leftmost parameter is a context now.
Use ctx_form API to obtain the context form from
this object, from which the source location info
can then be retrieved as before.
(abbrev_ctx): Function removed.
(bind_args, bindings_helper, fbindings_helper): Convert
ctx_form argument to
ctx, and use the API to access name or form.
(do_eval, do_eval_args, eval, eval_args_lisp1,
eval_lisp1, eval_progn, eval_prog1): ctx_form param
renamed to ctx.
(funcall_interp): Pass the original interpreted
function as the context to bind_args, not the
extracted code. When ctx_name sees this object, it
will compute the function name, which was not possible
from the code being used as the context. This
is the big reason for all these changes.
* eval.h (eval_error): Declaration updated.
(ctx_form, ctx_name): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (env_vbind_special): Remove unused ctx_form
parameter.
(bind_args, bind_macro_params): Don't pass ctx_form to
env_vbind_special.
(apply): Remove unused ctx_form parameter.
(apply_intrinsic, applyv, mapcarv, mappendv,
lazy_mapcarv_func, mapdov, do_mapf): Don't pass nil third
argument to apply.
* eval.h (apply): Declaration updated.
* lib.c (do_juxt): Do not bind third argument of apply
to lin when currying; curry as two argument function.
(do_not): Do not pass third nil argument to apply.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (funcall_interp): Drop the env argument.
The fun argument is now the whole function object, not the
encapsulated code to be interpreted. We pull the
environment and code out of the object locally
and interpret as before.
* eval.h (funcall_interp): Declaration updated.
* lib.c (generic_funcall, funcall, funcall1, funcall2,
* funcall3, funcall4): Calls to funcall_interp simplified,
just passing fun.
|
|
|
|
|
|
|
|
|
| |
* eval.c (interp_fun): Function renamed to funcall_interp.
* eval.h (interp_fun): Declaration updated.
* lib.c (generic_funcall, funcall, funcall1, funcall2,
funcall3, funcall4): Calls to interp_fun updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (error_trace): New function. Consolidates
error reporting between unhandled exception handling
in uw_throw, and the catcher in the repl.
(op_defmacro, expand_macrolet): Propagate location info from
body to wrapping block, and to the macro binding. In the
latter function, also to the body that is wrapped by local
macros.
(do_expand, macroexpand_1): Propagate location info from macro
expander to expansion, only taking it from the form if the
macro doesn't supply it.
* eval.h (error_trace): Declared.
* parser.c (repl): Replace error reporting code with call to
error_trace.
* unwind.c (uw_throw): uw_throw: likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (origin_hash): New global variable.
(lookup_origin): New function.
(expand_macro): Enter original form into origin hash, keyed by
new form.
(eval_init): gc-protect and initialize origin_hash.
* eval.h (lookup_origin): Declared.
* parser.c (repl): Report chain of expansions from
last_form_evaled.
* unwind.c (uw_throw): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the equal method is defined for structs, its return
value is used in their place for hashing and comparison.
* eval.h (eq_s, eql_s, equal_s): Declared.
* hash.c (equal_hash): If a COBJ defines an equalsub
function, we call it. If it returns non-nil, we
take the object in its place and recurse.
* lib.c (equal): Refactored to support equality substitution.
(less): Support equality substitution.
* lib.h (cobj_ops): New function pointer member, equalsub.
Only struct instances define this, currently.
(cobj_ops_init): Add null entry to initializer for equalsub.
(cobj_ops_init_ex): New initialiation macro for
situations when the equalsub member must be provided.
* struct.c (struct struct_type): new member eqmslot.
(make_struct_type): Initialize emslot to zero.
(static_slot_set, static_slot_ensure): If eqmslot is -1,
indicating positive knowledge that there is no equal method
static slot, we must invalidate that with a zero: it is no
longer known whether there is or isn't such a slot.
(get_equal_method, struct_inst_equalsub): New static functions.
(struct_inst_ops): Initialize the equalsub member using
new cobj_ops_init_ex macro.
* txr.1: Document equality substitution.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When continuations are captured/restored in the middle of
variable binding constructs, a hidden problem occurs.
Binding constructs work by allocating an empty environment
and then destructively extending it. Since the environment
is not on the stack, but a referenced object, it doesn't
get deep copied into a continuation. As the continuation is
revived repeatedly, parts of the variable binding code are
repeatedly re-executed, and keep pushing fresh bindings into
the same environment object. Though the new bindings
correctly shadow the old, the old bindings are there and
potentially hang on to garbage.
The solution taken here is to introduce a new kind of frame
for handling the situation: a continuation copy handling
frame. This frame allows functions to register objects to
be copied more deeply if a continuation is captured/revived
across them.
* eval.c (copy_env): New static function.
(copy_env_handler): New static function.
(bind_args, bind_macro_params): Install continuation copy
handling frame for cloning new_env.
(struct bindings_helper_vars): New struct type.
(copy_bh_env_handler): New static function.
(bindings_helper): Install continuation copy handling frame
for de and ne variables which hold environments. The variables
are moved to a struct to facilitate access from the handler.
* eval.h (copy_env): Declared.
* unwind.c (uw_push_cont_copy): New function.
(call_copy_handler): New static function.
(revive_cont): When a continuation is being revived invoke the
copying actions in its continuation copy handling frames,
but not if it is only being temporarily revived for immediate
unwinding.
(capture_cont): After copying the continuation, invoke any
continuation copying frames in the "parent": the original
frames that were captured.
* unwind.h (enum uw_frtype): New type, UW_CONT_COPY.
(struct uw_cont_copy): New struct type.
(union uw_frame): New member cp.
(uw_push_cont_copy): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (set_dyn_env): Static function becomes external.
* eval.h (set_dyn_env): Declared.
* match.c (eval_with_bindings, eval_progn_with_bindings):
Evaluate Lisp code in null lexical environment. Instead
install the pattern variables as dynamic, so they shadow
global variables. A compatibility check for 121 or earlier
provides the old behavior.
* txr.1: Document scoping rules, and added compatibility
notes.
|
|
|
|
|
|
| |
* eval.c (eval_error): Static function made external.
* eval.h (eval_error): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* combi.c (perm_list, perm_str, rperm_list, reperm_gen_fun,
rperm_vec, comb_vec, rcomb_list, rcomb_vec, rcomb_str):
Follow rename of list_vector to list_vec.
* eval.c (vector_list_s): Global variable renamed to
vec_list_s.
(expand_qquote): Follow vector_list_s to vec_list_s.
(eval_init): Follow renames of all identifiers. Functions
num-chr, chr-num, vector-list and list-vector are
registered under new names, while remaining registered
under old names.
* eval.h (vector_list_s): Declaration renamed.
* filter.c (url_encode): Follow chr_num to chr_int rename.
* lib.c (make_like, interpose, shuffle): Follow vector_list to vec_list rename.
(tolist, replace, replace_list): Follow list_vector to list_vec rename.
(num_chr): Renamed to int_chr.
(chr_num): Renamed to chr_int.
(vector_list): Renamed to vec_list.
(list_vector): Renamed to list_vec.
* lib.h (num_chr, chr_num, list_vector, vector_list):
* Declarations renamed.
* parser.y (vector): Follow vector_list to vec_list rename.
* txr.1: Updated documentation for num-chr, chr-num,
list-vector and vector-list with new names, and notes
about the old names being supported, but obsolescent.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register subtypep and typep.
* eval.h (list_s): Existing variable declared.
* lib.c (atom_s, integer_s, number_s, sequence_s, string_s):
new symbol variables.
(subtypep, typep): New functions.
(obj_init): Initialize new symbol variables.
* lib.c (atom_s, integer_s, number_s, sequence_s, string_s):
Declared.
* txr.1: Documented type hierarchy and the new functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (boundp): Static function becomes extern.
* eval.h (boundp): Declared.
* parser.c (find_matching_syms): New par parameter
lets function determine whether previous character is a an
open parenthesis or brace, based on which the set
of possible completions is restricted.
(provide_completions): Calculate the par parameter
and pass to find_matching_syms.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* args.c (args_cat_zap): New function.
* args.h: (args_cat_zap): Declared.
* eval.c (struct_lit_s): New symbol variable.
(eval_init): Initialize struct_lit_s.
* eval.h (struct_lit_s): Declared.
* gc.c (finalize): If a symbol has a struct slot
hash attached to it, we must free it when
the symbol is reclaimed.
* lib.c (make_sym): Initialize symbol's slot_cache pointer
to null.
(copy): Copy structure objects.
(init): Call struct_init to initialize struct module.
* lib.h (SLOT_CACHE_SIZE): New preprocessor symbol
(slot_cache_line_t, slot_cache_t): New typedefs.
(struct sym): New member, slot_cache.
* lisplib.c (struct_set_entries, struct_instantiate): New
static functions.
(liplib_init): Register new functions in dl_table.
parser.y (HASH_S): New terminal symbol.
(struct): New grammar rule.
(n_expr): Derive struct.
(yybadtoken): Map HASH_S to #S string.
parser.l (grammar): Recognize #S and return HASH_S token.
share/txr/stdlib/place.tl (slot): New defplace.
share/txr/stdlib/struct.tl: New file.
struct.c: New file.
struct.h: New file.
* Makefile (OBJS): Adding struct.o.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Function arguments are now allocated on the stack using alloca,
in conjunction with the struct alloc header structure.
The generic_funcall and apply functions are refactored
for this, as are most functions that take variadic arguments.
* args.c (args_add_list, args_cons_list): Functions removed.
(args_normalize, args_normalize_fill): New functions.
(args_get_checked): Draw arguments from list when array runs out.
(args_copy, args_copy_zap): New functions.
* args.h (ARGS_MAX): Reduced to 32.
(ARGS_MIN): New preprocessor symbol.
(args_init): Call args_init_list.
(args_add2, args_add3, args_add4): New inline functions.
(args_more): Take into account list, which may hold additional arguments.
(args_two_more): New inline function.
(args_normalize, args_normalize_fill): Declared.
(args_get_list): Normalize all arguments into one list and return it.
(args_get_rest, args_at, args_atz): New inline functions.
(args_get): Draw arguments from list when array runs out.
(args_clear): New inline function.
* arith.c (maskv): Convert to new args.
* eval.c (APPLY_ARGS): Preprocessor symbol removed.
(bind_args): Converted to accept struct args.
(apply): Function reduced down to trivial adapter which
converts a list of arguments to args, and calls the new
generic_funcall.
(applyv): New static function: struct args wrapper
around apply_intrinsic.
(iapply): Converted to struct args.
(call): Static function removed. The call intrinsic
function binding now goes directly to generic_funcall.
(list_star_intrinsic, interp_fun): Converted to struct args.
(op_catch): Adjustments for bind_args, which requires
a struct args arglist.
(me_op): Must use the new minl and maxl, since minv and maxv
don't take lists any more.
(mapcarv, mappendv, lazy_mapcarv, lazy_mappendv, mapdov,
weavev, or_fun, and_fun, tf, nilf, do_retf, do_apf,
do_ipf, callf, do_mapf, mapf): Converted.
(mapcarl): New function, like the old mapcarv.
(eval_init): call_f initialized from generic_funcall
rather than call. apply registered to applyv rather than
apply_intrinsic. Registrations for zip, hash_from_pairs, vec,
alist-remove, alist-nremove, and throw similarly updated to
new or renamed functions.
* eval.h (interp_fun, mapcarv): Declarations updated.
(mapcarl): Declard.
* hash.c (hashv): Converted to struct args.
(hashl): New function.
(hash_construct): Use hashl, not hashv.
(hash_from_pairs, hash_list, group_by): Converted.
* hash.h (hashv, hash_construct, hash_from_pairs, hash_list,
group_by): Declarations updated.
(hashl): Declared.
* lib.c (appendv, nconcv, lazy_appendv): Converted to
struct args.
(lazy_appendl): New function.
(multi): Converted.
(listv): New function.
(nary_op, plusv, mulv, logandv, logiorv, gtv, ltv, gev, lev,
numeqv, numneqv, maxv, minv): Converted.
(maxl, minl): New functions, like old maxv and minv.
(exptv, gcdv, lcmv, lessv, greaterv, lequalv, gequalv): Converted.
(func_f0v, func_f1v, func_f2v, func_f3v, func_f4v): Converted.
(func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted.
(func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted.
(func_n1ov, func_n2ov, func_n3ov): Converted.
(generic_funcall): Converted to take struct args.
(funcall, funcall1, funcall2, funcall4): Pass stack-allocated
struct args as trailing arguments to variadic functions, and to
generic_funcall.
(do_curry_12_1_v): New struct-args-based static function,
needed to implement curry_12_1_v now.
(curry_12_1_v): Converted.
(transposev): New function based on previous tranpose.
(transpose): Now a wrapper for transposev.
(do_chain, chainv, do_chand, chandv, do_juxt, juxtv,
do_and, andv, do_or, orv, do_not, do_iff): Converted.
(vectorv): New function. Implementation basis for vec intrinsic function.
(alist_removev, alist_nremovev): New functions.
(multi_sort): Switch from mapcarv to mapcarl.
(unique): Converted.
(uniq): Allocate struct args for calling unique.
(obj_init): list_f function now based on new listv, rather than
identity.
* list.h (varg): New typedef.
(struct func): All variadic function pointers converted to use
struct args.
(appendv, nconcv, lazy_appendv, multi, nary_op, plusv, minusv,
mulv, gtv, ltv, gev, lev, numeqv, numneqv, maxv, minv, exptv,
gcdv, lcmv, logadnv, logiorv, maskv, lessv, greaterv, lequalv,
gequalv, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v,
func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n0v,
func_n1v, func_n2v, func_n3v, func_n4v, func_n1ov, func_n2ov,
func_n3ov, generic_funcall, chainv, chandv, juxtv, adnv, orv,
unique): Declarations updated.
(lazy_appendl, listv, maxl, minl, transposev,
vectorv, alist_removev, alist_nremovev): Declared.
* stream.c (make_catenated_stream_v): New function.
(aformat): Renamed to formatv. The recognition of the nil
and t streams (standard output and string) is done here now.
(vformat): Follow rename of aformat to formatv.
(formatv): Function removed. Nobody calls this anymore.
(stream_init): make-catenated-stream re-registered to new
make_catenated_stream_v function.
* stream.h (formatv): Declaration updated.
(make_catenated_v): Declared.
* syslog.c (syslog_init): syslog registred to syslog_wrapv.
(syslog_wrapv): New function based on syslog_wrap converted to struct
args.
(syslog_wrap): Now wrapper for syslog_wrapv.
* syslog.h (syslog_wrapv): Declared.
* unwind.h (uw_throwv): New function.
(uw_throwfv, uw_errorfv): Converted to struct args.
* unwind.h (uw_throwv): Declared.
(uw_throwfv, uw_errorfv): Declarations updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
a.b.(expr ...).c -> (qref a b (expr ...) c)
Consing dot requires whitespace.
* eval.c (qref_s): New symbol global variable.
(eval_init): Initialize qref_s.
* eval.h (qref_s): Declared.
* parser.l (REQWS): New pattern definition, required whitespace.
(grammar): New rules to scan CONSDOT (space required on both
sides) and LAMBDOT (space required after).
* parser.y (CONSDOT, LAMBDOT): New token types.
(list): (. n_expr) rule replaced with LAMBDOT and CONSDOT.
(r_exprs): r_exprs . n_expr consing dot rule replaced with CONSDOT.
(n_expr): New n_expr . n_expr rule introduced here for producing
qref expressions.
(yybadtoken): Handle CONSDOT and LAMBDOT.
* txr.1: Documented qref dot.
|
|
|
|
|
|
|
|
|
|
|
|
| |
(bind_args): Include the entire context form in argument
mismatch errors.
(apply): Include the function name, or else source code
if it has no name, in argument mismatch erors.
(eval_init): Register func-get-name intrinsic.
* eval.h (func_get_name): Declared.
* txr.1: Documented func-get-name.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (arith-init): Changing *flo-...* from special to
lexical, and adding un-earmuffed variants. The earmuffed
versions are obsolescent.
Adding %pi% and %e% global lexicals. Earmuffed versions are
also made global lexical, and obsolescent.
* eval.c (lookup_global_var, lookup_global_var_l): New functions.
(lookup_var): Uses lookup_global_var.
(reg_varl): New function.
(reg_var): Uses reg_var.
(eval_init): Register global lexicals user-package, system-package
and keyword-package. Old symbols with earmuffs are obsoleted,
and also turned into global lexicals.
(top-vb, top-fb): Changed to lexical.
* eval.h (lookup_global_var, lookup_global_var_l, reg_varl):
Declared.
* genvim.txr: Scan ver.tl so that the lib-version variable
is included. Extract reg_varl calls.
* glob.c (glob_init): glob-err and other variables made lexical.
* lib.c (get_user_package, get_system_package, get_keyword_package):
Use lookup_global_var_l to avoid searching dynamic scope for
lexicals which cannot be dynamically rebound.
* share/txr/stdlib/ver.tl (lib-version): New global lexical variable.
(*lib-version*): Turned lexical. Obsolescent.
* signal.c (sig-init): sig-* variables turned lexical.
* sysif.c (sysif-init): s-*, poll-* and w-* variables turned lexical.
* syslog.c (syslog-init): log-* variables turned lexical.
* txr.c (sysroot-init): stdlib and *txr-version* variables turned
lexical. txr-version variable added, and *txr-version* is
obsolescent.
(txr-main): self-path variable added. *self-path* turns lexical
and is obsolescent.
* txr.1: Documentation updated. Lexical variables not referred
to as special. Special variables referred to as special.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (op_error): New static function.
(macro_form_p, fboundp): Static to external.
(special_operator_p): New function.
(eval_init): Register macrolet and symacrolet to op_error.
These are recognized and processed by expand, but we want
them in the op table so they are reported by special_operator_p.
* eval.h (fboundp, macro_form_p, special_operator_p): Declared.
* hash.c (print_key_val): Break long lines on spaces
between pairs with stream_width_check.
(hash_print_op): Implement split and indented printing.
* lib.c (obj_print_impl): New static function, resulting
from a merge of obj_print and obj_pprint. Fixes some
wrong-way recursion bugs: obj_pprint recursed into obj_print
in some places. Adds support for multi-line printing of
vectors and lists, with indentation using the new
interfaces in streams.
* stream.c (strm_base_init): Update initializer.
(put_indent, indent_mode_put_string): New static functions.
(put_string): Use indent_mode_put_string in either of the
two indent modes.
(put_char): Implement indent mode.
(get_indent_mode, test_set_indent_mode,
set_indent_mode, get_indent, set_indent,
inc_indent, width_check): New functions.
* stream.h (enum indent_mode): New.
(struct strm_base): indent_on member becomes indent_mode.
New members data_width and code_width.
(get_indent_mode, test_set_indent_mode,
set_indent_mode, get_indent, set_indent,
inc_indent, width_check): Declared.
* tests/009/json.expected: Updated.
* tests/010/seq.expected: Likewise.
* tests/011/macros-2.expected: Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Makefile (install): Install .tl files present in stdlib directory.
(INSTALL): Handle argument 2 being a list.
* eval.c (load): New function.
* eval.h (load): Declared.
* lisplib.c (ifa_set_entries, ifa_instantiate): New functions
to lazily load ifa.tl.
(lisplib_init): Register new functions.
* txr.c (stdlib_path): New variable.
(sysroot_init): Store the stdlib path in stdlib_path.
* txr.h (stdlib_path): Declared.
* share/txr/stdlib/ifa.tl: New file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (builtin, eval_initing): New global variable.
(op_defun, op_defmacro): During initialization, record functions
and macros in builtin hash.
(builtin_reject_test): New static function.
(expand_macrolet): Perform builtin reject test for fbind, lbind,
and macrolet.
(regfun, reg_mac): Add symbol to builtin hash.
(eval_init): GC-protect new hash table variable and initialize it.
Set eval_initing to true over eval initialization.
The flip function is renamed fo flipargs.
(eval_compat_fixup): New function, for dealing with the
operator/function conflict over flip.
* eval.h (eval_compat_fixup): Declared.
* lib.c (compat_fixup): Call eval_compat_fixup.
* tests/011/macros-2.txr: This test was defining a macro called
while which is now illegal. Renamed to whilst.
* tests/011/macros-2.expected: Regenerated.
* txr.1: Function flip renamed to flipargs and documented in
Compatibility section.
|
|
|
|
|
|
|
|
|
|
|
| |
(tprint): New function.
(eval_init): Register tprint as intrinsic.
* eval.h (prinl, pprinl, tprint): Declared.
* txr.c (txr_main): New option, -t.
* txr.1: Documented tprint and -t option.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (last_form_expanded): New variable.
(do_expand): New static function; contains previous expand
function.
(expand): Becomes a wrapper for do_expand, with re-entry
counting.
(eval_init): GC-protect last_form_expanded.
* eval.h (last_form_expanded): Declared.
* parser.l (regex_parse, lisp_parse): Just use a simple word for
the name of the regex or string parse location, not the entire
expression itself.
* unwind.c (uw_throw): Check whether expansion was going on
when the unhandled exception was thrown and print additional
information.
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c, arith.h, combi.c, combi.h, debug.c, debug.h, eval.c, eval.h,
filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h,
match.c, match.h, parser.h, rand.c, rand.h, regex.c, regex.h,
signal.c, signal.h, stream.c, stream.h, sysif.c, sysif.h, syslog.c,
syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h:
Update.
* LICENSE, METALICENSE: Likewise.
|
|
|
|
|
|
|
|
| |
debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c,
hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y,
rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c,
stream.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h,
utf8.c, utf8.h: Synchronize license header with LICENSE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
GC. The issue being solved here is the accuracy of the gc_set function.
The existing impelmentation is too conservative. It has no generation
information about the memory location being stored, and so it assumes
the worst: that it is a location in the middle of a gen 1 object.
This is sub-optimal, creating unacceptable pressure against the
checkobj array and, worse, as a consequence causing unreachable gen 0
objects to be tenured into gen 1.
To solve this problem, we replace "val *" pointers with a structure
of type "loc" which keeps track of the object too, which lets us
discover the generation.
I tried another approach: using just a pointer with a bitfield
indicating the generation. This turned out to have a serious issue:
such a bitfield goes stale when the object is moved to a different
generation. The object holding the memory location is in gen 1, but the
annotated pointer still indicates gen 0. The gc_set function then
makes the wrong decision, and premature reclamation takes place.
* combi.c (perm_init_common, comb_gen_fun_common,
rcomb_gen_fun_common, rcomb_list_gen_fun): Update to new interfaces
for managing mutation.
* debug.c (debug): Update to new interfaces for managing mutation.
Avoid loc variable name.
* eval.c (env_fbind, env_fbind): Update to new interfaces
for managing mutation.
(lookup_var_l, dwim_loc): Return loc type and update to new interfaces.
(apply_frob_args, op_modplace, op_dohash, transform_op, mapcarv,
mappendv, repeat_infinite_func, repeat_times_func): Update to new
interfaces for managing mutation.
* eval.h (lookup_var_l): Declaration updated.
* filter.c (trie_add, trie_compress, trie_compress_intrinsic,
* build_filter, built_filter_from_list, filter_init): Update to new
* interfaces.
* gc.c (gc_set): Rewritten to use loc type which provides the exact
generation. We do not need the in_malloc_range hack any more, since
we have the backpointer to the object.
(gc_push): Take loc rather than raw pointer.
* gc.h (gc_set, gc_push): Declarations updated.
* hash.c (struct hash): The acons* functions use loc instead
of val * now.
(hash_equal_op, copy_hash, gethash_c, inhash, gethash_n, pushhash,
Change to how locations are passed around, for the sake of generational
GC. The issue being solved here is the accuracy of the gc_set function.
The existing impelmentation is too conservative. It has no generation
information about the memory location being stored, and so it assumes
the worst: that it is a location in the middle of a gen 1 object.
This is sub-optimal, creating unacceptable pressure against the
checkobj array and, worse, as a consequence causing unreachable gen 0
objects to be tenured into gen 1.
To solve this problem, we replace "val *" pointers with a structure
of type "loc" which keeps track of the object too, which lets us
discover the generation.
I tried another approach: using just a pointer with a bitfield
indicating the generation. This turned out to have a serious issue:
such a bitfield goes stale when the object is moved to a different
generation. The object holding the memory location is in gen 1, but the
annotated pointer still indicates gen 0. The gc_set function then
makes the wrong decision, and premature reclamation takes place.
* combi.c (perm_init_common, comb_gen_fun_common,
rcomb_gen_fun_common, rcomb_list_gen_fun): Update to new interfaces
for managing mutation.
* debug.c (debug): Update to new interfaces for managing mutation.
Avoid loc variable name.
* eval.c (env_fbind, env_fbind): Update to new interfaces
for managing mutation.
(lookup_var_l, dwim_loc): Return loc type and update to new interfaces.
(apply_frob_args, op_modplace, op_dohash, transform_op, mapcarv,
mappendv, repeat_infinite_func, repeat_times_func): Update to new
interfaces for managing mutation.
* eval.h (lookup_var_l): Declaration updated.
* filter.c (trie_add, trie_compress, trie_compress_intrinsic,
* build_filter, built_filter_from_list, filter_init): Update to new
* interfaces.
* gc.c (gc_set): Rewritten to use loc type which provides the exact
generation. We do not need the in_malloc_range hack any more, since
we have the backpointer to the object.
(gc_push): Take loc rather than raw pointer.
* gc.h (gc_set, gc_push): Declarations updated.
* hash.c (struct hash): The acons* functions use loc instead
of val * now.
(hash_equal_op, copy_hash, gethash_c, inhash, gethash_n, pushhash,
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.h (apply_intrinsic, lazy_mapcar): Declarations added.
* stream.c (open_files, open_file_star): New functions.
(stream_init): Registered new functions as intrinsics.
* txr.1: Documented open-files and open-files*. Added to make-catenated-stream documentation.
* genvim.txr: Replace bunch of code with open-files.
* txr.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
re-binding. C code now has to go through the dynamic environment lookup
to access things like *random-state*, or *stdout*. As part of this,
I'm moving some intrinsic variable and function initializations out of
eval.c and into their respective modules. Macros are are used to make
global variables look like ordinary C variables. This is very similar
to the errno trick in POSIX threads implementations.
* eval.c (looup_var, lookup_var_l): Restructured to eliminate silly
goto, the cobjp handling is gone.
(reg_fun, reg_var): Internal function becomes external.
reg_var registers a simple cons cell binding now, without any
C pointer tricks to real C global variables.
(c_var_mark): Static function removed.
(c_var_ops): Static struct removed.
(eval_init): Numerous initializations for streams, syslog, rand,
signals and others moved to their respective modules.
The new symbol variables user_package_s, keyword_package_s
and system_package_s are interned here, and the variables are
created in a special way.
* eval.h (reg_var, reg_fun): Declared.
* gc.c (prot1): Added assert that the loc pointer isn't null.
This happened, and blew up during garbage collection.
* lib.c (system_package, keyword_package, user_package): Variables
removed these become macros.
(system_package_var, keyword_package_var, user_package_var): New
global variables.
(system_package_s, keyword_package_s, user_package_s): New
symbol globals.
(get_user_package, get_system_package, get_keyword_package): New
functions.
(obj_init): Protect new variables. Initialization order of modules
tweaked: the modules sig_init, stream_init, and rand_init are moved
after eval_init because they register variables.
* lib.h (keyword_package, system_pckage, user_package): Variables
turned into macros.
(system_package_var, keyword_package_var, user_package_var): Declared.
(system_package_s, keyword_package_s, user_package_s): Declared.
(get_user_package, get_system_package, get_keyword_package): Declared.
* rand.c (struct random_state): Renamed to struct rand_state to
avoid clash with new random_state macro.
(random_state): Global variable removed.
(random_state_s): New symbol global.
(make_state, rand32, make_random_state, random_fixnum, random):
Follow rename of struct random_state.
|
|
|
|
|
|
|
|
|
| |
* eval.h: Declare existing lambda_s extern variable.
* lib.c (obj_print, obj_pprint): print (lambda sym ...)
as (lambda (. sym) ...) and (lambda sym) as (lambda (. sym)).
* txr.1: document it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
environment down through the expander call hierarchy.
* eval.c (expand_opt_params, expand_params, expand_tree_cases,
expand_tree_case, expand_forms, val expand_cond_pairs, val
expand_place, expand_qquote, expand_vars, expand_quasi, expand_op,
expand_catch_clause, expand_catch, expand): All expanders get new
parameter, menv. expand_forms and expand handle a nil value of menv.
(eval_intrinsic): Pass nil macro environment to expand.
(eval_init): Update intrinsic registration for expand.
* eval.h (expand, expand_forms): Declarations updated.
* parser.y (expand_meta): Gets macro env parameter.
(elem, o_elem, exprs, expr): Pass nil to expand_forms and expand_meta.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
alleviate a long-standing pain: when an exception happens in
TXR's library somewhere, the program dies without leaving
a clue about what code was being evaluated when that happened.
What we can do is have the evaluator publish the most recent
compound form it has processed by stashing it in a variable.
Then when an unhandled exception occurs, we can peek at that
and try to pull out source location info.
* eval.c (last_form_evaled): New variable.
(do_eval): When evaluating a compound form, stash it in
last_form_evaled.
(eval_init): Protect last_form_evaled from gc.
* eval.h (last_form_evaled): Declared.
(eval_error_s): Existing variable declared.
* unwind.c: Has to include "eval.h" for the above variable
and "parser.h" for the source_loc function.
(uw_throw): When an exception is unhandled, if
last_form_evaled has source info, add it to the diagnostic.
But not if the exception is eval-error; because errors from
the evaluators already have the info.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* dep.mk: Updated.
* eval.c: Removed combination and permutation functions; they
now reside in combi.c.
(generate): Changed from static to external linkage.
* eval.h (generate): Declared.
* combi.c: New file.
* combi.h: New file.
* txr.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (expand_forms): Static function becomes external.
(expand_form): Remove case which handles do_s.
* eval.h (expand_forms): Declared.
* parser.y (elem): Expand both do_s and require_s forms by
using expand_forms.
|
|
|
|
|
|
|
|
|
| |
* eval.h (eval_intrinsic): Declared.
* txr.c (spec_file): Global variable removed.
(txr_main): Support for -e and -p options. Minor code cleanup.
* txr.1: Documented new options.
|
|
|
|
| |
Fixing some errors in copyright comments.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.h (mapcarv): Declaration added.
(eval_init): New intrinsic multi-sort registered.
* lib.c (multi_sort_less): New static function.
(multi_sort): New function.
* lib.h (multi_sort): Declared.
* txr.1: stub section added.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
quasiquoting. We cannot use the same symbol for the
literal form from the parser, and for the expanded form,
because this creates a confusion when there are multiple
nestings of quasiquote expansion.
* eval.c (vector_lit_s, vector_list_s, hash_lit_s): New symbol
variables.
(hash_construct_s): Relocated here from hash.c.
(expand_qquote): Part of bugfix: look for hash_lit_s
instead of has_construct_s. Translate to a hash_construct_s
form which is no longer recognizes as a hash literal.
Implementing recognition of a quasiquote vector literal,
handled similarly.
(eval_init): Initialize vector_lit_s, vector_list_s,
hash_list_s and hash_lit_s.
Use vector_list_s when registering vector_list function.
* eval.h (vector_lit_s, vector_list_s, hash_lit_s,
hash_constuct_s): Declared.
* hash.c (hash_construct_s): Variable removed
and relocated into eval.c.
(hash_init): Initialization of hash_construct_s removed.
* hash.h (hash_construct_s): Declaration removed.
* parser.y: (vector): Action updated to generate
a (vec-lit ...) form if the object contains unquotes,
otherwise generate a vector object.
(hash): Generate hash-lit form, not a
hash-construct form.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.h: Likewise.
* debug.c: Added copyright header.
* debug.h: Updated copyright year.
* eval.c: Likewise.
* eval.h: Likewise.
* filter.c: Likewise.
* filter.h: Likewise.
* gc.c: Likewise.
* gc.h: Likewise.
* hash.c: Likewise.
* hash.h: Likewise.
* lib.c: Likewise.
* lib.h: Likewise.
* match.c: Likewise.
* match.h: Likewise.
* parser.h: Likewise.
* regex.c: Likewise.
* regex.h: Likewise.
* stream.c: Likewise.
* stream.h: Likewise.
* txr.c: Likewise, and e-mail address.
* txr.h: Updated copyright year.
* unwind.c: Likewise.
* unwind.h: Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(dwim_loc, op_dwim): New static functions.
(op_modplace): Support assignment to dwim forms
with the help of dwim_loc.
(expand_place): Handle dwim places.
(eval_init): Initialize dwim_s. Register dwim operator
in op_table.
* eval.h (dwim_s): Declared.
* lib.c (chr_str, chr_str_set): Allow negative indices to index
backwards from end of string.
(vecref, vecref_l): Allow negative indices to index from
rear of array.
(obj_print, obj_pprint): Render (dwim ...) forms as [...].
* parser.l: Peoduce new METABKT token type for @[,
and '[', ']' tokens.
* parser.y (METABKT): New token. %type declaration for '['.
(list): Support square-bracket style of list, translated
into dwim form.
(meta_expr): Support @[...] variant.
(yybadtoken): Handle METABKT in switch.
* txr.1: Documented [...] syntax and dwim operator.
* txr.vim: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
assigning *stdout*, it really overwrites the underlying C variable.
* eval.c (lookup_var): Handle new kind of toplevel binding.
If the hash value is a cptr, it points to a val storage location.
(lookup_val_l): New function.
(op_modplace): Get location of variable using lookup_val_l
rather than assuming there is a cons-based binding.
(reg_var): Argument changed to val * pointer.
Register the variable as a cptr referencing the location.
(eval_init): reg_var calls pass address of each global.
* eval.h (lookup_var_l): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New functions list, append and eval. Code walking framework for
expanding quasiquotes. quotes right now.
* eval.c (let_s, lambda_s, call_s, cond_s, if_s, and_s, or_s
defvar_s, defun_s, list_s, append_s): New symbol variables.
(eval_intrinsic, op_quote, expand_forms, expand_cond_pairs,
expand_place, expand_qquote): New static functions.
(expand): New external function.
(eval_init): Initialize new symbol variables. Use newly defined symbol
variables to register functions. Also, new functions: quote, append,
list and eval.
* eval.h (expand): Declared.
* lib.c (appendv): New function.
(obj_init): quote and splice operator symbols moved into system
package.
(obj_print, obj_pprint): Support for printing quotes and splices.
* lib.h (appendv): Declared.
* match.c (do_s): New symbol variable.
(syms_init): New variable initialized.
(dir_tales_init): New variable used instead of intern.
* match.h (do_s): Declared.
* parser.y (elem): @(do) form recognized and its argument passed
through the new expander.
(o_elem, quasi_item): Pass list through expander.
(list): Use choose_quote to decide whether to put
regular quote or quasiquote on quoted list.
(meta_expr): Fixed abstract syntax so the expression is a single
argument of the sys:expr, rather than multiple arguments.
(unquotes_occur, choose_quote): New static function.
|
|
Lisp interpreter added.
* gc.c (finalize, mark_obj): Handle ENV objects.
* hash.c (struct hash): acons_new_l_fun function
pointer order of arguments change.
(equal_hash): Handle ENV.
(make_hash, gethash_l): Use cobj_handle for
type safety. Follow change in acons_new_l.
(gethash, gethash_f, remhash, hash_count,
hash_get_userdata, hash_set_userdata, hash_next): Use cobj_handle.
(gethash_n): New function.
* hash.h (gethash_n): Declared.
* lib.c (env_s): New symbol variable.
(code2type, equal): Handle ENV. (plusv, minusv, mul, mulv, trunc, mod,
gtv, ltv, gev, lev, maxv, minv, int_str): New functions.
(rehome_sym): New static function.
(func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1,
func_n2, func_n3, func_n4): Initialize new fields of struct func.
(func_f0v, func_f1v, func_f2v, func_f3v, func_f4v,
func_n0v, func_n1v, func_n2v, func_n3v, func_n4v,
func_interp): New functions.
(apply): Function removed: sanely re-implemented in new eval.c file.
(funcall, funcall1, funcall2, funcall3, funcall4): Handle
variadic and interpreted functions.
(acons, acons_new, acons_new_l, aconsq_new, aconsq_new_l): Reordered
arguments for compatibility with Common Lisp acons.
(obj_init): Special hack to prepare hash_s symbol, which is
needed for type checking inside the hash table funtions invoked
by make_package, at a time when the symbol is not yet interned.
Initialize new env_s variable.
(obj_print, obj_pprint): Handle ENV. Fix confusing rendering of
of function type.
(init): Call new function eval_init.
* lib.h (enum type): New enumeration member ENV.
(struct func): functype member changed to bitfield.
New bitfied members minparam and variadic.
New members in f union: f0v, f1v, f2v, f3v,
f4v, n0v, n1v, n2v, n3v, n4v.
(struct env): New type.
(union obj): New member e of type struct env.
(env_s): Variable declared.
(plusv, minusv, mul, mulv, trunc, mod, gtv, ltv, gev, lev, maxv, minv,
|