summaryrefslogtreecommitdiffstats
path: root/share
Commit message (Collapse)AuthorAgeFilesLines
* awk macro: don't use record stream if rs is "\n".Kaz Kylheku2016-09-111-6/+7
| | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Take input stream directly without a record adapter, if the record separator is the string "\n".
* awk macro: implement :begin-file and :end-file.Kaz Kylheku2016-09-101-32/+53
| | | | | | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slots, begin-file-actions and end-file-actions. (sys:awk-state loop): Take two additional functional arguments for the begin file and end file actions, and do the calls in the right places. unwind-protect triggers the end file function. (sys:awk-expander): Parse out :begin-file and :end-file actions. (awk): Generate lambdas for begin-file and end-file actions, if they are defined. Pass these to the loop method. The code is refactored here to do one big sys:awk-let around everything. * txr.1: Documented :begin-file and :end-file, revising the :begin and :end documentation in the process.
* awk macro: move expander values into compile-time struct.Kaz Kylheku2016-09-101-26/+25
| | | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slots: inputs, output, name, lets, begin-actions, end-actions, cond-actions. (sys:awk-expander): Use just one local variable, an awk compile time. Instead of the previous local variables, use the slots of this structure and return just that structure. Note that pattern-actions has been renamed cond-actions. This is per the terminology used in the newly-written documentation. (awk): Adjust to sys:awk-expander returning just the awk compile-time structure. No need to set up numerous locals; just refer to struct.
* awk macro: don't use zap.Kaz Kylheku2016-09-091-1/+1
| | | | | * share/txr/stdlib/awk.tl (sys:awk-state rec-to-f): Don't use zap macro when the return value is not used.
* awk macro: fix buggy range semantics.Kaz Kylheku2016-09-091-5/+9
| | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-let): The closing expression of an awk range only applies when the range is active. Refactor generated code with local flags to eliminate duplicating the end range expression. Avoid evaluating the start range expression if the range is already active.
* awk macro: better code for rng with placelet.Kaz Kylheku2016-09-091-1/+1
| | | | | | | * share/txr/stdlib/awk.tl (sys:awk-let): Use our wonderful placelet macro instead of symacrolet for binding the flag alias to the flag place. This removes the duplicate evaluations of the slot access.
* awk macro: revise rng eval strategy.Kaz Kylheku2016-09-081-24/+43
| | | | | | | | | | | | | | | | | | | | | | | | | awk ranges must evaluate out-of-band after the record is read, before the patterns and actions are evaluated. * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slots, rng-expr-temps and rng-exprs. (sys:awk-let): Stash the code for evaluating a range into the compile-time info into the rng-exprs list, and associate it with a gensym in the parallel rng-expr-temps list. Then emit that gensym as the expansion for the rng form. (awk): Process the pattern code in two steps. First, expand it, to get it to drop the rng-exprs into the awk compile-time info structure. Then when generating the final lambda, wrap an let* around the generated code which binds the rng-temps with the rng-exprs. This resolves the gensym references that replaced the ranges. let* is is used and its bindings are reversed into discovery order because this supports nested rng syntax. Given (rng x (rng y z)), the (rng y z) is expanded first, and so its code and temp gensym are pushed onto their respective lists firsts. The outer rng's code will thus contain a temp referring to the code of the inner one.
* awk macro: handle string typed output.Kaz Kylheku2016-09-081-1/+3
| | | | | * share/txr/stdlib/awk.tl (sys:awk-state): if output is a string, open file.
* awk macro: support ors (output record separator).Kaz Kylheku2016-09-081-2/+4
| | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slot, ors. (sys:awk-state prn): Use put-string to output the record rather than put-line, and stick the ors at the end. (sys:awk-let): Provide ors local symbol macro.
* Optimize qref and sys:rslot using slet.Kaz Kylheku2016-09-081-3/+3
| | | | | | | | | | | * share/txr/stdlib/struct.tl (qref): Use slet instead of let in expansion so that in the common case of var.(method ...) the expansion simply produces a form with var evaluated in two places. (sys:rslot): Use slet instead of rlet. * tests/012/struct.tl: Update qref expansion test-cases to test for the now simpler expansions.
* New slet macro.Kaz Kylheku2016-09-081-5/+12
| | | | | | | | | | | | | | | | * lisplib.c (place_set_entries): Add slet symbol to autoload list for place.tl. * share/txr/stdlib/place.tl (sys:r-s-let-expander): New function. (rlet): Replace body with call to sys:r-s-let-expander. (slet): New macro. * txr.1: Clarification and corrections in rlet description and example. rlet will in fact handle the three-variable rotation case because, since a is not a constant expression, (rlet ((temp a)) ...) reduces to let. Documented new slet.
* Range operators for awk macro.Kaz Kylheku2016-09-081-11/+26
| | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slot, rng-vec: holds boolean flags for ranges. New slot, rng-n, holds size for rng-vec. New :postinit handler for creating vector for rng-vec. (sys:awk-compile-time): New struct. (sys:awk-expander): Construct an awk compile time, and return that as one of the values. (sys:awk-let): Provide (rng) local macro: the two argument range operator. Generates code and keeps track of number of ranges and their association to a position in rng-vec using the compile-time info structure. (awk): Capture awk compile-time object from expander. Initialize rng-n slot of awk state with number of ranges indicated in compile time info. Pass compile-time info to awk:let macro. Binding of lambda and of awk state had to be reordered because macro-expansion of the lambda fills in the compile time info which is then used in the expansion of the constructing expression for the awk state.
* New place-mutating operators.Kaz Kylheku2016-09-081-0/+43
| | | | | | | * share/txr/stdlib/place.tl (pinc, pdec, test-set, test-clear, compare-swap, test-inc, test-dec): New macros. * txr.1: Documented.
* No-op expansion for (inc 0) and (dec 0).Kaz Kylheku2016-09-081-2/+2
| | | | | | | * share/txr/stdlib/place.tl (inc, dec): If the delta is zero, don't generate code which calls getter and setter; just generate the place form as the output.
* Awk comes to TXR via a macro.Kaz Kylheku2016-09-071-0/+148
| | | | | | | | | * lisplib.c (awk_set_entries, awk_instantiate): New static functions. (lisplib_init): Register auto-loading for awk module via new functions. * share/txr/stdlib/awk.tl: New file.
* New rslot macro to suport upcoming awk macro.Kaz Kylheku2016-09-071-0/+27
| | | | | | | | | | | | This provides a way to create lexical macros denoting slots, such that method are invoked when they are updated. * lisplib.c (struct_set_entries): Add rslot to list of auto-load symbols for struct.tl module. * share/txr/stdlib/struct.tl (sys:rslotset): New function. (rslot, rslot): New macro and place macro. (sys:rslot): New place kind.
* Bugfix: issue with expansion of place macros.Kaz Kylheku2016-09-071-1/+1
| | | | | | | | | | | | | | | | | | | The expansion of a place macro form should not be subject to a complete macro-expansion (as a regular macro form). Only one round of expansion should be performed, and the results should be re-tried as a place macro. Otherwise an opportunity to expland a place macro will be missed. * share/txr/stdlib/place.tl (sys:pl-expand): Use macroexpand-1 rather than macroexpand. * txr.1: Documentation updated to make the new behavior clear. It's unlikely that anything in the world depends on this, so no backward compatibility switch is being provded to the old behavior. In situations where this makes a difference, the old behavior is likely too wrong to be useful.
* Bugfix: x not macro-expanded in (set [x i] y).Kaz Kylheku2016-09-071-10/+13
| | | | | | | | | * share/txr/stdlib/place.tl (sys:l1-setq): Expand sym, because it might not be a symbol. If it isn't a symbol, just generate a set. (dwim): Unconditionally bind sys:*lisp1* to t, whether or not the unexpanded place is a symbol. It could expand to a symbol. The context is lisp-1 if it does that.
* Bugfix: nthcdr place not obtaining macro env.Kaz Kylheku2016-09-071-5/+9
| | | | | | | | | | | | * share/txr/stdlib/place.tl (sys:*pl-env*): New special variable for passing macro-expansion environment to expanders. (call-update-expander, call-clobber-expander, call-delete-expander): bind sys:*pl-env* with passed-in env argument, so if the expander needs to itself recursively expand a macro, it has the macro-time env. (nthcdr): Do not try to capture :env parameter, because this will always be nil. Refer to sys:*pl-env* instead.
* Version 148.txr-148Kaz Kylheku2016-09-011-1/+1
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Version 146.txr-146Kaz Kylheku2016-07-201-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 145.txr-145Kaz Kylheku2016-07-031-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 144.txr-144Kaz Kylheku2016-06-291-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Fix broken place delete semantics of symbol-value.Kaz Kylheku2016-06-081-1/+1
| | | | | * share/txr/stdlib/place.tl (defplace symbol-value): Don't splice body into deleter syntax; must use plain unquote.
* Version 143.txr-143Kaz Kylheku2016-06-041-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 142.txr-142Kaz Kylheku2016-05-291-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 141.txr-141Kaz Kylheku2016-05-201-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Adding termios support.Kaz Kylheku2016-05-181-0/+78
| | | | | | | | | | | | | | | | * Makefile (termios.o): New object file. * lib.c (init): Call termios_init. * lisplib.c (termios_set_entries, termios_instantiate): New functions. (lisplib_init): Register new functions in autoload table. * share/txr/stdlib/termios.tl: New file. * termios.c, termios.h: New files. * txr.1: Documented termios.
* Version 140.txr-140Kaz Kylheku2016-05-071-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Somew new path access testing functions.Kaz Kylheku2016-05-041-3/+26
| | | | | | | | | | | | | | * lisplib.c (path_test_set_entries): New elements in the list for path-readable-to-me-p, path-read-writable-to-me-p, and path-strictly-private-to-me-p. * share/txr/stdlib/path-test.pl (sys:path-access): Test bitwise combinations of permissions, so read+write can be tested in one call. (path-readable-to-me-p, path-read-writable-to-me-p, path-strictly-private-to-me-p): New functions. * txr.1: Documented.
* Fix: path-writable-to-me bug, for root.Kaz Kylheku2016-05-041-1/+2
| | | | | | | | * share/txr/stdlib/path-test.tl (sys:path-access): Comment added to note use restriction to identical permissions for all three scopes. Fixed incorrect use of logior instead of logand which causes strict permission test to be applied to user even when testing for non-execute permisisons.
* Version 139.txr-139Kaz Kylheku2016-04-221-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Optimization in path-private-to-me-p.Kaz Kylheku2016-04-221-8/+8
| | | | | | | | | * share/txr/stdlib/path-test.tl (path-private-to-me-p): Use mlet to initialize the g variable lazily, so that getgrgid is only called when g is used. getgrid is a fairly heavy-weight function, and it's only used to resolve the case when a file is writable to the group owner (is the user the only member of that group?)
* Put notes into cadr sources that they are generated.Kaz Kylheku2016-04-161-0/+2
| | | | | | * gencadr.txr: Insert notice about generation. * cadr.c, cadr.h, share/txr/stdlib/cadr.tl: Regenerated.
* Version 138.txr-138Kaz Kylheku2016-04-161-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Macros obtain* and obtain*-block.Kaz Kylheku2016-04-151-0/+12
| | | | | | | | | | * lisplib.c (yield_set_entries): Add obtain* and obtain*-block to autoload list. * share/txr/stdlib/yield.tl (obtain*, obtain*-block): New macros. * txr.1: Documented.
* Don't expand replacements of symbol macros.Kaz Kylheku2016-04-121-2/+2
| | | | | | | | | * eval.c (expand_symacrolet, do_expand): Don't expand the replacement form of a global or lexical symbol macro at the time it is bound to its symbol. This is almost certainly wrong in situations where it makes a difference. * txr.1: Noted in compatibility section.
* Fix throw used instead of throwf in defstruct.Kaz Kylheku2016-04-061-9/+9
| | | | | | * share/txr/stdlib/struct.tl (defstruct): Errors about duplicate :init, :postinit or :fini were incorrectly thrown using throw rather than throwf.
* Diagnose bad supertype in defstruct.Kaz Kylheku2016-04-061-1/+6
| | | | | | | * share/txr/stdlib/struct.tl (defstruct): If super isn't nil, it must name an existing struct type, or an exception is thrown. Previously, a nonexistent struct was silently treated as if nil had been specified.
* Define a sock-peer syntactic place.Kaz Kylheku2016-03-311-0/+6
| | | | | | | * share/txr/stdlib/socket.tl (sock-peer): Syntactic place defined, allowing (set (sock-peer sock) addr). * txr.1: Documented sock-peer as accessor and sock-set-peer.
* Version 137.txr-137Kaz Kylheku2016-03-301-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* New macro: lset.Kaz Kylheku2016-03-281-0/+13
| | | | | | | | | * lisplib.c (place_set_entries): Added "lset" to autoload list. * share/txr/stdlib/place.tl (lset): New macro. * txr.1: Documented lset.
* Version 136.txr-136Kaz Kylheku2016-03-201-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 135.txr-135Kaz Kylheku2016-03-101-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 134.txr-134Kaz Kylheku2016-03-011-1/+1
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * inst.nsi: include .tl files in installer
* Prefix override in IP prefix functions.Kaz Kylheku2016-03-011-12/+13
| | | | | | | | | | | * share/txr/stdlib/socket.tl (sys:str-inaddr-net-impl): New argument weff. Overrides prefix. Bugfix here: we must base the number of octets on the calculated width before wextra is added to it. (str-inaddr-net, str-inaddr6-net): New optional width argument. * txr.1: Documented.
* Fix triple-colon in ipv6 text representation.Kaz Kylheku2016-03-011-18/+17
| | | | | | | | | * share/txr/stdlib/socket.tl (sys:in6addr-condensed-text): New function containing common code. Uses window-mappend to selectively convert a compressed range of zeros to either colon or empty string based on whether it is in the middle or end. (str-in6addr, str-in6addr-net): Use new function.
* Functions for address prefixes to slash notation.Kaz Kylheku2016-02-291-0/+60
| | | | | | | | | | | * lisplib.c (sock_set_entries): Autload entries for str-inaddr-net and str-in6addr-net. * share/txr/stdlib/socket.tl (str-inaddr-net, str-in6addr-net): New functions. * txr.1: Documented str-inaddr, str-in6-addr, str-inaddr-net and str-in6addr-net.
* IP address to string functions.Kaz Kylheku2016-02-291-0/+38
| | | | | | | | * lisplib.c (sock_set_entries): Add str-inaddr and str-in6addr to list of autoload identifiers. * share/txr/stdlib/socket.tl (str-inaddr, str-in6addr): New functions.
* Adding socket support: unix, ipv4, ipv6.Kaz Kylheku2016-02-261-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * socket.c, socket.h: New files. * Makefile: include new socket.o among objects if have_objects variable is defined to 'y'. * configure (have_sockets): New variable. New configure test for socket-related functionality. (HAVE_SOCKETS, HAVE_GETADDRINFO): New configuration preprocessor symbols. Also, reordering the shell probing so that /usr/xpg4/bin/sh is the last fallback. On Solaris, it chokes on some code that is needed for Solaris. * lisplib.c (sock_set_entries, sock_instantiate): New static functions. (lisplib_init): Register new functions as autoload hooks. * share/txr/stdlib/socket.tl: New file. * stream.c (socket_error_s): New symbol variable. (struct stdio_handle): New members, family and type, helping stdio streams represent sockets too. (stdio_stream_mark): Mark new members of struct stdio_handle. (make_stdio_stream_common): Initialize new members. (make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): New functions. (stream_init): Initialize socket_error_s variable. Register sock-family, sock-type and open-socket intrinsic functions. Register socket-error subtype. * stream.h (socket_error_s, make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): Declared.