summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* rlet cleanup: replace safe with let or slet.Kaz Kylheku2016-09-113-71/+71
| | | | | | | | | | | | | * gencadr.txr: Use let instead of useless rlet that will just reduce to let. * share/txr/stdlib/cadr.tl: Regenerated. * share/txr/stdlib/place.tl (sys:var, car, cdr, errno): Replace rlet with slet where safe. (nthcdr): Replace useless let* with let. Replace one safe-looking rlet with slet. (dwim): Replace useless rlet with let.
* doc: Fix issue of missing collapse UI on Awk section.Kaz Kylheku2016-09-111-0/+3
| | | | | * genman.txr: Recognize the form of the table-of-contents line with the extra blank line generated by the .coSS macro.
* 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-102-48/+135
| | | | | | | | | | | | | | | | | | * 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.
* doc: awk macroKaz Kylheku2016-09-101-0/+696
| | | | * txr.1: New section on the awk macro.
* doc html: TOC indentation issue on Chrome.Kaz Kylheku2016-09-091-1/+1
| | | | | | | | * genman.txr: Hack: put <dd> before nested <dl> element in table of contents. Without this, the nested lists are rendered flush left by Google Chrome. With this, they are indented. Chrome adds ugly whitespace around the embedded definition lists, but it's better than no identation.
* 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-082-17/+11
| | | | | | | | | | | * 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-083-12/+40
| | | | | | | | | | | | | | | | * 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-082-0/+277
| | | | | | | * 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.
* Fix poorly chosen :postinit order.Kaz Kylheku2016-09-072-14/+29
| | | | | | | | | * struct.c (call_postinitfun_chain): call base handlers before derived ones, except in backward compatibility mode. * txr.1: Updated documentation of :postinit, and added compatibility note.
* Awk comes to TXR via a macro.Kaz Kylheku2016-09-072-0/+166
| | | | | | | | | * 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-072-1/+28
| | | | | | | | | | | | 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-072-4/+10
| | | | | | | | | | | | | | | | | | | 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.
* Regression: @(rep) wrongly diagnoses empty clause.Kaz Kylheku2016-09-061-2/+2
| | | | | | | Introduced on 2016-04-27 in 7afbcc19. * parser.y (elem): Check $4 phrase position for empty clauses, rather than $2. That's where they are.
* Version 148.txr-148Kaz Kylheku2016-09-016-72/+99
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* doc: revised merge directive description.Kaz Kylheku2016-09-011-38/+73
| | | | | * txr.1: Substantially rewrote incorrect and incomplete description of merge directive.
* Address -c not working with --lisp.Kaz Kylheku2016-09-011-0/+6
| | | | | | | | | | | * txr.c (txr_main): the --lisp option causes the parse stream to be processed as Lisp, which is fine if it is a file stream. If it is a byte string input stream created by the -c option, it won't work due to missing character operations on the stream, resulting in a strange error message and termination. That issue isn't being fixed here; just providing a more meaningful error message when --lisp is combined with -c.
* installer: don't package man page.Kaz Kylheku2016-08-311-2/+1
| | | | | | | | * inst.nsi: Windows has no man page reading tools, and the PDF and HTML are packaged already, so don't bundle the txr.1 man page source. Furthermore, we need to remove this when updating over existing installations, else they will forever have a stale txr.1 file hanging around.
* installer: lower case txr dir.Kaz Kylheku2016-08-311-6/+6
| | | | | * inst.nsi: consistently specify installation directory with lower-case "txr" path component.
* doc: wording changes regarding usage of "query".Kaz Kylheku2016-08-311-41/+64
| | | | | | | | | | | | * txr.1: The term "query language" is retired; "pattern language" is used everywhere. The script argument can be TXR Lisp or TXR, so is referred to as "script-file" in all contexts where it could be either. Clarifications are added in a few places that the script could be Lisp or that some wording only applies when the script is TXR. Removing incorrect, obsolescent wording which specifies that the leading exclamation mark convention is honored in a file name argument.
* doc: warn about exit methods not saving history.Kaz Kylheku2016-08-301-0/+5
| | | | | | * txr.1: Under INTERACTIVE LISTENER, add remarks that using the exit function, or raising a fatal signal, will prevent the history from being saved.
* doc: revise synopsis; document listener invocation.Kaz Kylheku2016-08-301-2/+11
| | | | | | | | | | | * txr.1: Revise the synopsis so that it doesn't insinuate that the query-file or data-file arguments are mandatory. A formatting issue with the brackets around options is fixed. Under ARGUMENTS AND OPTIONS document that if no arguments are present, the interactive listener is launched. Under INTERACTIVE LISTENER, mention that not only does the -i option run the listener, but so does txr invocation with no arguments.
* doc: verb number agreement in Undo Editing.Kaz Kylheku2016-08-301-1/+1
| | | | | * txr.1: Fix plural subject "lines" paired with singular verb "has".
* doc: bad wording in path-private-to-me-pKaz Kylheku2016-08-301-1/+3
| | | | | * txr.1: Fix sentence talking about two functions, respectively, but just one function as its subject.
* Fix emulation of TXR 135 @(if) semantics.Kaz Kylheku2016-08-291-2/+4
| | | | | | | | | * parser.y (if_clause, elif_clauses_opt): The previous commit changes the emulation of old @(if) behavior, since expressions obtained via the n_exprs_opt grammar phrase are not subject to expand_meta. We can counteract this by calling expand_meta in the compatibility code.
* Fix broken expansion in @(if) and output @(repeat).Kaz Kylheku2016-08-291-5/+5
| | | | | | | | | * parser.y (if_clause, elif_clauses_opt, repeat_clause, rep_elem): Recognize argument expressions as n_exprs_opt rather than exprs_opt, so that expand_meta is not applied. They are Lisp expressions, which are broken by expand_meta. A failing test case is op syntax with @num metanum variables, e.g. @(if (foo (op bar @1.slot))).
* Fix bugs in new quasiquote optimization.Kaz Kylheku2016-08-281-2/+4
| | | | | | | | | | | * eval.c (qquote_init): Stricter quote_form_p_f test function: reject the quote form if it isn't a proper list of two elements. (optimize_qquote_form): Extract all arguments of list forms and catenate them with mapcan, rather than assuming that they have one argument. This wrong assumption breaks ,,*(list ...) interpolation, for instance.
* Precompute functions used by quasiquote optimizer.Kaz Kylheku2016-08-281-35/+46
| | | | | | | | | | | | * eval.c (consp_f, second_f, list_form_p_f, quote_form_p_f, xform_listed_quote_f): New static variables. (qquote_init): New function. (optimize_qquote_form): Use list_form_p_f, quote_form_p_f, and second_f instead of constructing functions locally. (optimize_qquote_args): Use xform_listed_quote_f instead of locally constructed function. (eval_init): Call qquote_init. Register second function to second_f.
* Fix runaway recursion in lazy struct initialization.Kaz Kylheku2016-08-282-2/+9
| | | | | | | | | | | | | | | | | | | | | Staci-blowing test case: (defstruct foo nil bar) (mlet ((f (lnew foo bar (not f.bar)))) (prinl f.bar)) * struct.c (lazy_struct_init): Do not flip the lazy flag to zero here. The problem is that it's being done after the funcall(so->slot[0]), and so the struct is still marked for lazy initialization while that function is running. We could detect the circularity (as done in the force function) but that would create inflexibilities in lazy struct initialization. (check_init_lazy_struct): Flip the lazy flag to zero in this function before calling lazy_struct_init. * txr.1: Document behavior of struct being freely accessible during lazy initialization.
* Optimize quasiquote code generation.Kaz Kylheku2016-08-271-9/+98
| | | | | | | | | | | | | | | | | The surface motive here is to get better code than forms like (append (list 'a) (list 'b) ...). The ulterior motive is to suppress the memory explosion when heavily nested forms like ^^^^^^^^^^^x are expanded. This problem was uncovered by AFL (fast). * eval.c (optimize_qquote_form, optimize_qquote_args, optimize_qquote): New static functions. (expand_qquote_rec): New function. (expand_qquote): Contents moved into expand_qquote_rec. This function now optimizes the results of calling expand_qquote_rec.
* Introduce symbol variable for list*.Kaz Kylheku2016-08-271-2/+3
| | | | | | * eval.c (list_star_s): New symbol variable. (eval_init): Initialize list_star_s and use it for the list* function registration.
* Fix formatting of list* syntax.Kaz Kylheku2016-08-261-1/+1
| | | | * txr.1: list* symbol was typeset as meta.
* Adding time-parse method.Kaz Kylheku2016-08-252-17/+117
| | | | | | | | | | | | | | | | | | | | * lib.c (time_parse_s): New symbol variable. (tm_to_time_struct): New static function, based on code moved out of broken_time_struct. (broken_time_struct): Bulk of code replaced with call to tm_to_time_struct. (time_struct_to_tm): New parameter, strict. Indicates whether nils in time struct are converted to zeros, or whether they trigger errors. (time_string_meth): Specify strict conversion of argument time struct to to struct tm when calling time_struct_to_tm. (time_parse_meth): New static function. (time_init): Initialize time_parse_s symbol variable; add time-parse static slot to time struct; initialize slot with new method. * txr.1: Document time-parse method.
* Put cap on @<digits> value in op/do syntax.Kaz Kylheku2016-08-241-0/+4
| | | | | | | | | | | | | | | | The op transformer generates a lambda which has as many arguments as the highest-valued metanumber (@<digits> syntax) occurring in the form. If this is a huge integer, it obligingly tries to construct the argument list, running out of memory. In this commit, we cap the value to 1024. This issue was uncovered by the fuzzing utility AFL (fast) 2.30b. * eval.c (me_op): Throw error if max exceeds 1024, preventing the call to supplement_op_syms to actually generate an a formal parameter list of max symbols.
* Error on non-bindable sym in defvar and defparm.Kaz Kylheku2016-08-241-0/+3
| | | | | | * eval.c (me_def_variable): Check for sym not being a bindable symbol. Otherwise we might call mark_special on nil, which triggers an assertion.
* Fix bug: global lexicals marked special anyway.Kaz Kylheku2016-08-241-9/+4
| | | | | | | | | | | | | | Variables defined with defvarl or defparml are being marked special, due to a mark_special call in the macro expander which existed before they were introduced. * eval.c (me_def_variable): We have to call mark_special at macro-expansion-time for defparm and defvar, rather than arrange for it to be called later, for the same reasons that the (now incorrect) mark_special call had been introduced in do_expand function for handling defvar. (do_expand): Do not call mark_special, because the symbol being handled here is defvarl: define lexical variable.
* Check arg count when expanding defsymacro.Kaz Kylheku2016-08-241-0/+3
| | | | | | * eval.c (do_expand): Throw error if defsymacro form isn't a list of three elements, just like defparm and defparml do.
* Misleading error message in defvarl and defsymacro.Kaz Kylheku2016-08-241-2/+2
| | | | | | * eval.c (op_defvarl, op_defsymacro): Report correct symbol in not-bindable-symbol error message rather than reporting as let.
* New time-string method on time struct.Kaz Kylheku2016-08-222-16/+74
| | | | | | | | | | | | | * lib.c (time_string_s): New symbol variable. (time_fields_to_tm, time_struct_to_tm): New static functions. (make_time_impl): Replace bunch of code with call to time_fields_to_tm. (time_string_meth): New static function. (time_init): Initialize time_string_s. Add time-string static slot to time struct. Register time-string method. * txr.1: Documented.