summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Adding time-parse function: wrapper for strptime.Kaz Kylheku2016-08-225-0/+68
| | | | | | | | | | | | * configure: Test for strptime. * eval.c (eval_init): register time-parse intrinsic. * lib.c (time_parse): New function. * lib.h (time_parse): Declared. * txr.1: Documented.
* Version 147.txr-147Kaz Kylheku2016-08-123-3/+18
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Fix multi-arch build issue for txr.res.Kaz Kylheku2016-08-062-2/+2
| | | | | | | | | | | | | When building in a separate directory, we can't just symlink the win directory, because the txr.res output file is architecture dependent and cannot be shared between 32 and 64 bit builds. * Makefile (%.res): Convert .rc -> .res rule to use the top_srcdir pattern, so the prerequisite will be found without the aid of the win/ directory symlink. * configure: Do not create win -> $source_dir/win symlink in the build directory.
* Port exception handling to 64 bit Cygwin.Kaz Kylheku2016-08-062-2/+59
| | | | | | | | | | | | | * jmp.S (DEFUN): Separate definition for 64 bit Cygwin, which doesn't use leading underscores and has an unusual prologue. (jmp_save, jmp_restore): Separately defined for 64 bit Cygwin, due to use of Microsoft 64 bit calling conventions. * signal.h (struct jmp): In x86-64 version, only on Cygwin, new members: rsi and rdi. These registers are considered nonvolatile and so are saved and restored by jmp_save and jmp_restore.
* Fix issue in make dependency generation.Kaz Kylheku2016-08-061-1/+2
| | | | | | | * Makefile (DEPGEN): We must fold the backslash continuations before trying to delete the first dependency element, because if the target name is long, that first element may be on the following line, and we delete the backslash.
* Check for Cygnal when deciding where user home is.Kaz Kylheku2016-07-271-19/+9
| | | | | | | * parser.c (get_home_path): Do not try HOME first and then USERPROFILE. If running on Cygnal, use strictly USERPROFILE, and do not fall back on HOME. In all other situations, try the HOME variable only.
* Version 146.txr-146Kaz Kylheku2016-07-206-52/+72
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Print notation for quasi-strings and quasi-word-lists.Kaz Kylheku2016-07-201-0/+64
| | | | | | | * lib.c (out_quasi_str): New static function. (obj_print_impl): Handle sys:quasi and sys:quasilist forms, reproducing a syntax similar to their read notation.
* NFA regex optimization: use just one set array.Kaz Kylheku2016-07-191-48/+31
| | | | | | | | | | | | | | | | | | | | | | We don't have to flip between two arrays, since the nfa_closure and and nfa_move_closure can write the output set into the same array. * regex.c (struct nfa_machine): Replace flip and flop members with a single set. (nfa_closure, nfa_move_closure): out array parameter removed; in renamed to set. References to in and out simply replaced with set. (nfa_run): Allocate one set instead of two, plus the stack. Remove code to swap the two pointers on each iteration. (regex_machine_reset): Prepare initial closure in the one and only set array. (regex_machine_init): Allocate set array, rather than flip an flop. (regex_machine_cleanup): Free set array and null out pointer rather than flip and flop arrays. (regex_machine_feed): Pass just the set ot the nfa_move_closure function. Remove flip/flop pointer swapping
* NFA regex optimization: combine move and closure.Kaz Kylheku2016-07-191-37/+90
| | | | | | | | | | | | | | | | | | | | * regex.c (struct nfa_machine_t): Remove move and clos array pointers, replace with flip and flop. Remove nmove member. (nfa_move): Static function removed. (nfa_move_closure): New static function, based on nfa_move and logic from nfa_closure. (nfa_run): Use nfa_move_closure and flip between two arrays. (regex_machine_reset): Remove reference to nmove member in nfa_machine_t. Prepare initial closure in flip array. (regex_machine_init): Allocate flip and flop arrays, rather than removed move and clos. (regex_machine_cleanup): Free flip and flop arrays and zero out the pointers, rather than removed move and clos. (regex_machine_feed): Replace nfa_move and nfa_closure with combined nfa_move_closure from flip to flop, and exchange of flip and flop arrays.