summaryrefslogtreecommitdiffstats
path: root/lisplib.c
Commit message (Collapse)AuthorAgeFilesLines
* getopts: autoload: opt-error not interned.Kaz Kylheku2021-06-301-1/+1
| | | | | | * lisplib.c (getopts_set_entries): Add opt-error to list of interned symbols. Without this, getopts throws sys:opt-error. Reported by Paul A. Patience.
* New function: path-search.Kaz Kylheku2021-06-291-1/+1
| | | | | | | | | | | | * lisplib.c (path_test_set_entries): Autoload on path-search. * stdlib/path-test.tl (path-search): New function. * tests/018/path-test.tl: New file. * txr.1: Documented. * stdlib/doc-lookup.tl: Updated.
* constantp: fully expand; recognize functions.Kaz Kylheku2021-06-281-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch improves the constantp function dramatically. It now performs a full expansion of its argument, and recognizes all of the constant foldable functions that the compiler recognizes. * eval.c (const_foldable_s): New symbol variable. (const_foldable_hash): New static variable. (constantp_noex): Look up function in the hash table of const foldable functions, including in the case when it appears in a dwim form as in [+ 2 2] which is (dwim + 2 2). In this case, recursively check the arguments for constantp_noex. We get the hash table of foldable functions from the sys:%const-foldable% variable, which comes from an autoloaded module. (constantp): Fully expand the input form, not just m macroexpand. (eval_init): Register the const_foldable_s variable. * lisplib.c (constfun_instantiate, constfun_set_entries): New static functions. (lisplib_init): Register auto-loading of constfun module via new static functions. * stdlib/compiler.tl; Load the constfun module if %const-foldable% is not defined. (%const-foldable-funs%, %const-foldable%): Removed from here. * stdlib/constfun.tl: New file. (%const-foldable-funs%, %const-foldable%): Moved here. * txr.1: Documented changes to constantp.
* matcher: new looping macros.Kaz Kylheku2021-06-241-0/+1
| | | | | | | | | | | | | | * lisplib.c (match_set_entries): Autoload on new while-match, while-match-case and while-true-match-case symbols. * share/txr/stdlib/match.tl (while-match, while-match-case, while-true-match-case): New macros. * tests/011/patmatch.tl: Tests. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* New macro: flow.Kaz Kylheku2021-06-161-1/+1
| | | | | | | | | | | | | | | There has been interest in the community in a threading macro; a triviality which which applies the opip syntax to a value. Eschewing unusual glyph combinations like ->> and whatnot, I've chosen the English word flow for this. * share/txr/stdlib/op.tl (flow): New macro. * lisplib.c (op_set_entries): Set up autoload for flow. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* New macro: pic.Kaz Kylheku2021-06-101-0/+18
| | | | | | | | | * lisplib.c (pic_instantiate, pic_set_entries): New static functions. (lisplib_init): Register autoloading of pic.tl module via new functions. * share/txr/stdlib/pic.tl: New file.
* ffi: new macros deffi-struct and deffi-union.Kaz Kylheku2021-06-081-1/+2
| | | | | | | | | | | | * lisplib.c (ffi_set_entries): Autoload for deffi-struct and deffi-union symbols. * share/txr/stdlib/ffi.tl (deffi-struct, deffi-union): New macros. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* json: convenience I/O routines.Kaz Kylheku2021-05-301-0/+5
| | | | | | | | | | | | | | * lisplib.c (getput_set_entries): Register autoload for get-jsons, put-jsons, file-get-json, file-put-json, file-append-json, file-get-jsons, file-put-jsons, file-append-jsons, command-get-json, command-put-json, command-get-jsons and command-put-jsons. * share/txr/stdlib/getput.tl (get-jsons, put-jsons, file-get-json, file-put-json, file-append-json, file-get-jsons, file-put-jsons, file-append-jsons, command-get-json, command-put-json, command-get-jsons and command-put-jsons): New functions.
* matcher: new "each-match family" of macros.Kaz Kylheku2021-05-041-0/+3
| | | | | | | | | | | | | | | | | | * lisplib.c (match_set_entries): New autoload symbols: each-match, append-matches, keep-matches, each-match-product, append-match-products, keep-match-products. * share/txr/stdlib/doc-syms.tl: Updated. * share/txr/stdlib/match.tl (each-match-expander): New function. (each-match, append-matches, keep-matches, each-match-product, append-match-products, keep-match-products): New macros. * tests/011/patmatch.tl: New tests covering each macro, far from exhaustively. * txr.1: Documented.
* New function: rel-path.Kaz Kylheku2021-05-031-1/+1
| | | | | | | | | | | | | * lisplib.c (copy_file_set_entries): Add rel-path as autoload trigger for copy-file module. * share/txr/stdlib/copy-file.tl (rel-path): New function. * tests/018/rel-path.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* matcher: first pattern macro, sme.Kaz Kylheku2021-04-191-1/+1
| | | | | | | | | | | | * lisplib.c (match_instantiate): Intern sme symbol. * share/txr/stdlib/doc-syms.tl: Update with sme entry. * share/txr/stdlib/match.tl (sme): New defmatch macro. * tests/011/patmatch.tl: New tests for sme. * txr.1: Documented.
* matcher: new @(scan) operator.Kaz Kylheku2021-04-181-1/+1
| | | | | | | | | | | | | | * share/txr/stdlib/match.tl (compile-scan-match): New function. (compile-match): Hook scan operator into compiler. * lisplib.c (match_set_entries): Ensure scan is interned in usr package. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated with new entry for scan.
* matcher: allow user-defined patterns via defmatchKaz Kylheku2021-04-171-1/+2
| | | | | | | | | | | | | | | | | * lisplib.c (match_set_entries): Register defmatch and *match-symbol* to autoload match.tl. * share/txr/stdlib/doc-syms.tl: Updated with entries for defmatch and *match-macro*. * share/txr/stdlib/match.tl (*match-macro*): New special variable holding hash. (compile-match): Handle macros via *match-macro* hash. (defmatch): New macro. * txr.1: Documented. * tags.tl: Recognize defmatch forms.
* lib: new function for documentation lookup.Kaz Kylheku2021-04-031-0/+18
| | | | | | | | | | | | | | | | * genman.txr: dump contents of symhash into a doc-syms.tl library file, as a defvarl form. * lisplib.c (doc_instantiate, doc_set_entries): New static functions. (lisplib_init): Register autoload for doc-lookup module to symbols doc and *doc-url*. * share/txr/stdlib/doc-lookup.tl: New file. * share/txr/stdlib/doc-syms.tl: Likewise. * txr.1: Documented.
* compiler: optimization control.Kaz Kylheku2021-03-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * lisplib.c (compiler_set_entries): Register *opt-level* symbol for auto-loading. * share/txr/stdlib/compiler.tl (*opt-level*): New special variable. (compiler comp-let): Eliminate frames only at level 3. (compiler comp-lambda-impl): Lift load time at level 3. (compiler comp-arith-form): Constant-folding only at lvl 1. (compiler comp-fun-form): Algebraic substitutions and reductions and constant-folding only at level 1. (compiler comp-apply-call): Constant folding at level 1. (compiler optimize): Optimizations off if level zero. Thread jumps and eliminate dead code at level 2. Flow-analysis based optimizations at level 3. Additional optimizations at level 4. (compile comp-block): Block elimination at level 3. (compile-toplevel): Rebind *opt-level*, giving it value zero if it is previously nil. * share/txr/stdlib/optimize.tl (basic-blocks get-insns): Just retrieve the instructions, letting caller decide whether to call late-peephole or not. * txr.1: Documented *opt-level*.
* matcher: add :match parameter macro.Kaz Kylheku2021-02-041-0/+6
| | | | | | | | | | | | | With this, we can do matching anywhere we are able to specify a function parameter list and a body, and we can specify ordinary arguments, which are inserted to the left of the implicit match. Plus, it specialy integrates with :key. * lisplib.c (match_set_entries): Autoload on :match. * share/txr/stdlib/match.tl (:match): New parameter macro. * txr.1: Documented.
* matcher: new @(with) operator.Kaz Kylheku2021-02-011-1/+1
| | | | | | | | | | | | * lisplib.c (match_instantiate): Ensure usr:with is interned. * share/txr/stdlib/match.tl (compile-with-match): New function. (compile-match): Wire in with operator. * tests/011/patmatch.tl: Test cases. * txr.1: Documented.
* matcher: rename @(let) to @(as).Kaz Kylheku2021-02-011-1/+1
| | | | | | | | | | | | | * lisplib.c (match_instantiate): Ensure usr:as is interned. * share/txr/stdlib/match.tl (compile-let-match): Rename to compile-as-match. (compile-match): Remove handling of let symbol; route as symbol to compile-as-match. * tests/011/patmatch.tl: Update all uses of let to as. * txr.1: Updated.
* place: bug: call-delete-expander not in usr package.Kaz Kylheku2021-01-231-1/+1
| | | | | * lisplib.c (place_set_entries): Fix misspelling of call-delete-expander entry: stray parenthesis.
* matcher: add lambda-match and defun-matchKaz Kylheku2021-01-161-0/+1
| | | | | | | * lisplib.c (match_set_entries): New autoload triggers. * share/txr/stdlib/match.tl (lambda-match, defun-match): New macros.
* matcher: add if-match and match-case.Kaz Kylheku2021-01-151-1/+1
| | | | | | | | * lisplib.c (match_set_entries): Add match-case and if-match autoload trigger symbols. * share/txr/stdlib/match.tl (if-match, match-case): New macros.
* matcher: fix semantics of empty @(all ...) match.Kaz Kylheku2021-01-151-0/+6
| | | | | | | | | | | | * lisplib.c (match_set_entries): Ensure usr:all* is interned. * share/txr/stdlib/match.tl (compile-all-match): When the operator is the existing all, we must listp as a guard, not consp, because an empty list must match vacuously by virtue of not containing any counterexample to the pattern. For situations when a vacuous empty match is not desired, we support the all* alternative operator, which uses consp. (compile-match): Wire in the all* operator.
* new: structural pattern matching.Kaz Kylheku2021-01-141-0/+18
| | | | | | | | * lisplib.c (match_instantiate, match_set_entries): New static functions. (lisplib_init): Register autoload using new statics. * share/txr/stdlib/match.tl: New file.
* Copyright year bump 2021.Kaz Kylheku2021-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * METALICENSE: 2020 copyrights bumped to 2021. Added note about SHA-256 routines from Colin Percival. * LICENSE, LICENSE-CYG, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lex.yy.c.shipped, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/copy-file.tl, share/txr/stdlib/debugger.tl, share/txr/stdlib/defset.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/each-prod.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/param.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/quips.tl, share/txr/stdlib/save-exe.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/vm-param.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, time.c, time.h, tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr, y.tab.c.shipped: Copyright year bumped to 2021.
* awk: bugfix: fconv symbols not in usr package.Kaz Kylheku2020-12-291-1/+4
| | | | | | | * share/txr/stdlib/conv.tl (sys:conv-let): Use usr: package prefix on the conversion symbols i, o, x, b. They are being interned in the system package, which breaks the awk fconv macro.
* New: quip function for random humor.Kaz Kylheku2020-10-041-0/+18
| | | | | | | | | | | | Add this to your .txr_profile startup file. * lisplib.c (quips_instantiate, quips_set_entries): New static functions. (lisplib_init): Register autoloading of quip. * share/txr/stdlib/quips.tl: New file. * txr.1: Documented.
* New inaddr-str and in6addr-str functions.Kaz Kylheku2020-07-241-1/+2
| | | | | | | | | | | | | | | | | * lisplib.c (sock_set_entries): Register autoload entries for inaddr-str and in6addr-str. Register prefix symbol to be interned. * share/txr/stdlib/socket.tl (sockaddr-in, sockaddr-in6): Both structs get a new member, prefix, defaulting to the respective number of bits in the address. (inaddr-str, in6addr-str): New functions. * tests/014/iaddr-str, tests/014/inaddr-str.expected, tests/014/in6addr-str.tl, tests/014/in6addr-str.expected: New files * txr.1: Documented.
* New producting each operator family.Kaz Kylheku2020-06-281-0/+18
| | | | | | | | | | | | | * lisplib.c (each_prod_instantiate, each_prod_set_entries): New static functions. (lisplib_init): Register autoload of each-prod.tl via new functions. * share/txr/stdlib/each-prod.tl: New file. * txr.1: Documented. Also, under the existing collect-each family of operators, added the equivalence to mapping with lambda to help clarify the semantics.
* Replace trivial format(nil, ...) with simpler ops.Kaz Kylheku2020-05-301-34/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gencadr.txr (cadr_register): Use scat2 to glue two strings. * cadr.c: Regenerated. * lib.c (scat2, scat3): New functions. * lib.h (scat2, scat3): Declared. * liblib.c (place_instantiate, ver_instantiate, ifa_instantiate, txr_case_instantiate, with_resources_instantiate, path_test_instantiate, struct_instantiate, with_stream_instantiate, hash_instantiate, except_instantiate, type_instantiate, yield_instantiate, sock_instantiate, termios_instantiate, awk_instantiate, build_instantiate, trace_instantiate, getopts_instantiate, package_instantiate, getput_instantiate, tagbody_instantiate, pmac_instantiate, error_instantiate, keyparams_instantiate, ffi_instantiate, doloop_instantiate, stream_wrap_instantiate, asm_instantiate, compiler_instantiate, debugger_instantiate, op_instantiate, save_exe_instantiate, defset_instantiate, copy_file_instantiate): Use scat2 to glue two strings instead of format. * parser.c (find_matching_syms, hist_save, repl): Replace trivial uses of format with scat2 or scat3. * sysif.c (ensure_dir): Likewise. * txr.c (get_self_path, substitute_basename, sysroot, sysroot_init, parse_once_noerr, read_compiled_file_noerr, read_eval_stream_noerr): Likewise. * unwind.c (uw_unwind_to_exit_point): Likewise.
* Remove unnecessary #include directives.Kaz Kylheku2020-04-221-1/+0
| | | | | | | | | | Time for some spring cleaning. * args.c, arith.c, buf.c, cadr.c, chksum.c, debug.c, ftw.c, gc.c, gencadr.txr, glob.c, hash.c, lisplib.c, match.c, parser.c, parser.l, parser.y, rand.c, signal.c, stream.c, strudel.c, syslog.c, tree.c, unwind.c, utf8.c, vm.c: Numerous unnecessary #include directives removed.
* New function: touch.Kaz Kylheku2020-04-151-1/+1
| | | | | | | | | * lisplib.c (copy_file_set_entries): Register autoload for touch. * share/txr/stdlib/copy-file.tl (touch): New function. * txr.1: Documented.
* sockets: missing shut-rd, shut-wr, shut-rdwr.Kaz Kylheku2020-04-131-0/+1
| | | | | | | | | | | | * socket.c (sock_load_init): Register documented but completely missing intrinsic variables shut-rd, shut-wr, shut-rdwr. * lisplib.c (sock_set_entries): Register autoload for shut-rd, shut-wr, shut-rdwr. * txr.1: In sock-shutdown description, fix shut-rw typo that should be shut-wr.
* getopts: new feature: cumulative options.Kaz Kyheku2020-03-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An option declared as (cumul <type>) indicates that it is of type <type>, and that multiple occurrences of the option produce values that are accumulated into a list. The accumulation is in reverse order: the rightmost occurrence ends up the first in the list. * lisplib.c (getopts_set_entries): Add cumul to list of interned symbols, so that the getopts.tl code isn't mistakenly working with sys:cumul. * share/txr/stdlib/getopts.tl (opt-parsed): New slot, cumul. (opt-desc basic-type p, opt-desc list-type-p, opt-desc cumul-type-p): New methods. (opt-desc check): Rework type validity check using the new methods. (opt-parsed convert-type): Support 'cumul type by instantiating an opt-parsed object for the wrapped type, and stealing its converted argument into the current object, and setting the cumul flag. (opts add-opt, option-base add-opt): Support options that have the cumul flag set by accumulating list values. The code is different due to different amounts of encapsulation. The opts structure stores the raw opt-parsed objects, whereas option-base just takes the decoded values. (opthelp): Parse through the (cumul ...) type syntax, so cumulative options are printed in the help text the same way as if they were non-cumulative. * txr.1: Documented.
* file-put-buf: new argument; also, new file-place-bufKaz Kylheku2020-02-071-1/+2
| | | | | | | | | | | | | Like file-put-buf but doesn't overwrite the file. * lisplib.c (getput_set_entries): New autoload for file-place-buf. * share/txr/stdlib/getput.tl (file-put-buf): New argument for seeking into the file. (file-place-buf): New function. * txr.1: Documented.
* New functions chmod-rec and chown-rec.Kaz Kylheku2020-01-311-0/+1
| | | | | | | | | | | * lisplib.c (copy_file_set_entries): Add chown-rec and chmod-rec to list of symbols that trigger auto-load of copy-file.tl. * share/txr/stdlib/copy-file.tl (chmod-rec, chown-rec): Neew functions. * txr.1: Documented.
* New: file copy, recursive copy, recursive delete.Kaz Kylheku2020-01-291-0/+20
| | | | | | | | | | | | | * lisplib.c (copy_file_instantiate, copy_file_set_entries): New static functions. (lisplib_init): Register auto-load of copy-file.tl via new functions. * share/txr/stdlib/copy-file.tl: New file. * txr.1: New section Unix Filesystem Complex Operations. Here copy-file, copy-files, copy-path-rec and remove-path-rec are documented.
* Copyright year bump 2020.Kaz Kylheku2019-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/debugger.tl, share/txr/stdlib/defset.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/param.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/save-exe.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/vm-param.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr: Extended copyright notices to 2020.
* New function: compile-update-file.Kaz Kylheku2019-12-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | The new function only compiles a file if the output file doesn't exist or is out of date. In addition, both compile-file now deletes the output file if compilation fails, and has a documented return value. * lisplib.c (compiler_set_entries): Add autoload entry fro compile-update-file. (open-compile-streams): Accepts a third argument: a function to test the input stream against the output path. The output file is opened, and the streams are returned, only if that test function returns true. Also, a third element is returned: the output path. This lets the caller to know what to delete, if the output file must be deleted. (compile-file-conditionally): New internal function, formed from compile-file. Takes an extra argument, the test function to pass to open-compile-streams. Compilation is skipped if open-compile-streams returns nil. Internals reshuffled a bit. If compilation doesn't set the success flag, then the with-resources logic now removes the output file in addition to closing the output stream. Prior to setting the success flag, we flush the output stream. * txr.1: Documented new function, all return values, and deletion of output file on unsuccessful compilation.
* New function: path-dir-empty.Kaz Kylheku2019-12-091-0/+1
| | | | | | | | | | * lisplib.c (path_test_set_entries): Autoload entry for path-dir-empty. * share/txr/stdlib/path-test.tl (path-dir-empty): New function. * txr.1: Documented.
* getopts: new define-option-struct macro.Kaz Kylheku2019-11-291-1/+1
| | | | | | | | | | | | This provides more streamlined option processing. * lisplib.c (getopts_set_entries): Add auto-load entry for define-option-struct. * share/txr/stdlib/getopts.tl (define-option-struct): New macro. * txr.1: Documented.
* New macro: ldo.Kaz Kylheku2019-10-231-1/+1
| | | | | | | | | | This is a left-argument-inserting syntactic sugar for do. * lisplib.c (op_set_entries): Add auto-load entry for ldo. * share/txr/stdlib/op.tl (ldo): New macro. * txr.1: Documented.
* tree: node set functions and syntactic places.Kaz Kylheku2019-10-161-0/+1
| | | | | | | | | | | | | | | | | * lisplib.c (defset_set_entries): Autoload entries for left, right and key. * share/txr/stdlib/defset.tl (left, right, key): New simple-form defsets. * tree.c (set_left, set_right, set_key): New functions. (tree_init): Register intrinsics set-left, set-right and set-key. * tree.h (set_left, set_right, set_key): Declared. * txr.1: key, left and right classified as accessors. Documented set-key, set-left and set-right.
* list-builder: dequeue capabilities with del/del* operators.Kaz Kylheku2019-08-171-2/+4
| | | | | | | | | | | | | | | * lisplib.c (build_set_entries): Add buildn for autload, and intern del and del* symbols. * share/txr/stdlib/build.tl (list-builder): New methods del and del*. (sys:list-builder-flets): Generate flet for del*. (sys:build-expander): New function, consisting of expansion logic previously in build function. Macrolet added for del. (build): Call sys:build-expander. (buildn): New macro. * txr.1: Documented.
* autoload: bugfix: wire in forgotten test-set and others.Kaz Kylheku2019-08-131-0/+2
| | | | | * lisplib.c (place_set_entries): Add missing entries for test-set, test-clear, compare-swap, test-inc and test-dec.
* sub-list, sub-vec, sub-str: becoming accessors.Kaz Kylheku2019-06-171-1/+1
| | | | | | | | | | | * lisplib.c (defset_instantiate): Add sub-list, sub-vec and sub-str symbols as autoload triggers for defset.tl. * share/txr/stdlib/defset.tl (sub-list, sub-vec, sub-str): New syntactic places defined with defset. * txr.1: sub-list, sub-vec and sub-str documented as accessors.
* buffers: sub-buf becomes accessor.Kaz Kylheku2019-06-171-1/+1
| | | | | | | | | | * lisplib.c (ffi_set_entries): Register autoload for sub-buf symbol. * share/txr/stdlib/ffi.tl (sub-buf): Syntactic place defined via defset. * txr.1: Updated sub-buf documentation.
* oop: new new* and lnew* macros.Kaz Kylheku2019-05-151-0/+1
| | | | | | | | | | | | * lisplib.c (struct_set_entries): Add autoload entries for new* and lnew* symbols. * share/txr/stdlib/struct.tl (sys:new-type, sys:new-expander): New functions. (new, lnew): Macros now implemented using sys:new-expander. (new*, lnew*): New macros. * txr.1: Documented.
* debugger: initial backtrace support.Kaz Kylheku2019-04-161-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * debug.c (debug_state): Switch to unsigned, since this is now a bitmask. (sys_print_backtrace_s): New symbol variable. (dbg_clear, dbg_set, dbg_restore): New static functions. (debug_init): Initialize sys_print_backtrace_s. Register dbg-clear, dbg-set, dbg-restore intrinsics. Register dbg-enable, dbg-step, dbg-backtrace and dbg-all bitmask variables, Lisp equivalents of DBG_ENABLE, DBG_SETP, DBG_BACKTRACE and DBG_ALL. (debug_dump_backtrace): New function. * debug.h (opt_debugger): Declaration removed. (debug_state): Declaration updated. (DBG_ENABLE, DBG_STEP, DBG_BACKTRACE, DBG_ALL): New preprocessor symbols. (debug_set_state): Inline function removed. (debug_clear, debug_set, debug_restore): New inline functions. (dbg_backtrace, dbg_fcall_begin, dbg_fcall_end): New macros. (debug_dump_backtrace): Declared. * eval.c (error_trace): Invoke debug_dump_backtrace if support is compiled in and backtraces are enabled. * lib.c (do_generic_funcall): New function, copy of generic_funcall. (generic_funcall): Now a wrapper for do_generic_funcall which registers fcall frames if backtrace support is enabled. (funcall, funcall1, funcall2, funcall3, funcall4): Route to slow generic_funcall path if backtraces are enabled. * lisplib.c (debugger_instantiate, debugger_set_entries): New static functions. (lisplib_init): Autload support for debug module via above new functions. (lisplib_try_load): Save and restore debugger state in new way using debug_set and debug_restore, with specific mask values. * parser.y (parse_once): Disable debugging in new way. * share/txr/stdlib/debug.tl New file. * sighal.h (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST): New macros for saving/restoring debug state. (EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): Reference the above macros to include debug state in extended jump context. * txr.c (help): Document --backtrace and that that -d implies --backtrace. (txr_main): Enable debugger using debug_set. Provide new --backtrace option to enable backtraces only. * unwind.c (args_s): New symbol variable. (fcall_frame_type): New static variable. (unwind_to_exit_point): Save pointer to original frame stack and restore it when calling error_trace. This is so that error_trace can walk the stack to collect a backtrace. (uw_find_frames_by_mask, uw_push_fcall): New functions. (uw_late_init): Initialize args_s and fcall_frame_type. gc-protect fcall_frame_type. Register uw-* variables corresponding to the UW_* frame types. * unwind.h (uw_frtype_t): New enum constant UW_FCALL. (struct uw_fcall): New frame structure. (union uw_frame): New member fc. (uw_push_fcall, uw_find_frames_by_mask): Declared.
* New catch** macro.Kaz Kylheku2019-04-101-1/+1
| | | | | | | | | * lisplib.c (except_set_entries): Autoload for catch** symbol. * share/txr/stdlib/except.tl (catch**): New macro. * txr.1: Document catch** macro, and the desc slot of the catch-frame struct.
* debug support: crude debugger removed.Kaz Kylheku2019-04-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * debug.c (debug_depth, debug_quit_s): Variables removed. (step_mode, next_depth, breakpoints, last_command, cols): Static variables removed. (debug_check): C99 inline instantiation removed. (help, show_bindings): Static functions removed. (debug): Function removed. (debug_set_state): Now takes one int argument, returns int. It's anticipated that the new debug system will have a simple on-off switch; there won't be a debug_depth hack. (debug_restore_state): Function removed. (debug_init): Emptied. * debug.h (debug_depth, debug_state_t): Declarations removed. (debug_enter, debug_leave, debug_return): Macros removed. (debug_check): Inline function removed. (debug_set_state): Declaration updated. (debug_restore_state): Declaration removed. (debug_frame, debug_end): Macros removed. * eval.c (do_eval, me_interp_macro): Debugging support scrubbed. * lisplib.c (lisplib_try_load): Adapt to debug_set_state interface change. * match.c (h_fun, do_match_line, v_fun, match_files, match_fun): Debugging support scrubbed. * parser.y (parse_once): Adapt to debug_set_state interface change. * protsym.c: Regenerated. * signal.h (debug_depth): Declaration removed. (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST): Macros removed. (EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): Reduced to unconditionally empty definitions for future use. * unwind.c (uw_push_debug): Function removed. * unwind.h (uw_frtype_t): UW_DBG enum member removed. (struct uw_debug): struct declaration removed. (union uw_frame): db member removed. (uw_push_debug): Declaration removed. * txr.1: Debugger doc removed.