summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* awk macro: bind *stdin* to current input stream.Kaz Kylheku2017-01-262-5/+16
| | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Instead of using the lexical variable stin, use *stdin*, so that the standard input stream is re-bound. * txr.1: Documented binding and scope of *stdin*.
* Registering tentative def must purge warning.Kaz Kylheku2017-01-252-1/+1
| | | | | | | | * match.c (match_reg_var): No need to call uw_purge_deferred_warning here any more. * unwind.c (uw_register_tentative_def): Purge any deferred warnings for the tag.
* doc: update compat notes: new 165 value.Kaz Kylheku2017-01-251-0/+16
| | | | | * txr.1: Describe the Lisp expansion neglect in the pattern language that is fixed for 166, reversible with -C.
* Local macrolets in build become functions.Kaz Kylheku2017-01-252-6/+11
| | | | | | | | | | * share/txr/stdlib/build.tl (sys:list-builder-macrolets): Function renamed to sys:list-builder-flets. Builds local functions instead of macrolets. (build): Follow rename of sys:list-builder-macrolets. * txr.1: Documentation updated and example added of use of add as a higher order function.
* New handle* macro, analogous to catch*.Kaz Kylheku2017-01-252-5/+27
| | | | | | | | | | | * share/txr/stdlib/except.tl (sys:expand-handle): New function. (handle): Use sys:expand-handle to expand arguments. The previously unused :whole form argument is now put to use, and correctly captured using :form rather than :whole. (handle*): New macro. * txr.1: Documented.
* New catch*, giving access to exception symbol.Kaz Kylheku2017-01-254-17/+41
| | | | | | | | | | | | | | | | | | * eval.c (op_catch): The sys:catch operator now passes the exception symbol as the first argument of each clause. This means the catch macro must be adjusted. * share/txr/stdlib/except.tl (catch): Macro now inserts a gensym dummy first argument into each clause to take the symbol passed by the sys:catch operator. (catch*): New macro, which is identical to the previous catch macro, and thus exposes the symbol passed as the first argument. * txr.1: Documented catch*. * tests/012/struct.tl: Some gensym numbers need adjusting in one test case.
* bugfix: wrong context form in mac-param-bind.Kaz Kylheku2017-01-251-1/+1
| | | | | | | * eval.c (do_expand): Expander for mac-param-bind is redundantly expanding the main expression and taking that as the epanded context form, rather than expanding the context form.
* Remove unused args_init function.Kaz Kylheku2017-01-251-5/+0
| | | | * args.h (args_init): Inline function removed.
* bugfix: take-while, take-until termination condition.Kaz Kylheku2017-01-241-2/+2
| | | | | | | * lib.c (take_while_list_fun, take_until_list_fun): We must terminate the output list when the output list is empty, and not try to apply the predicate to car(list) in that case.
* Expose plist to alist functions.Kaz Kylheku2017-01-242-1/+69
| | | | | | | | * eval.c (eval_init): Register plist-to-alist and improper-plist-to-alist intrinsics. * txr.1: Documented improper plist concept and new functions.
* Rename proper_plist_to_alist function.Kaz Kylheku2017-01-242-2/+2
| | | | | | | * lib.c (proper_plist_to_alist): Renamed to plist_to_alist. * lib.h (proper_plist_to_alist): Declaration replaced. (plist_to_alist): Declared.
* bugfix: use proper plist lookup in new :key macro.Kaz Kylheku2017-01-241-2/+2
| | | | | | | | * share/txr/stdlib/keyparams.tl (sys:extract-keys, sys:extract-keys-p): Use the brand new memp function rather than memq. memq is not correct for plist lookup because of ambiguities like (:foo :bar :bar 3) where memq retrieves (:bar :bar 3) for :bar rather than (:bar 3).
* New memp function for searching a plist.Kaz Kylheku2017-01-244-5/+54
| | | | | | | | | | * eval.c (eval_init): Register memp intrinsic. * lib.c (memp): New function. * lib.h (memp): Declared. * txr.1: Documented.
* bugfix: wrong macro env across param expansion.Kaz Kylheku2017-01-241-10/+22
| | | | | | | | | | | | | | | | The issue is that optional argument init forms have visibility to prior arguments. However, they are being expanded in the original macro environment which doesn't take into account any preceding variable bindings. This is wrong: the preceding variables must shadow any symbol macros in the outer environment. * eval.c (expand_opt_params_rec, expand_params_rec): Create a var shadowing macro environment for every parameter name (or destructuring parameter list) that is traversed, and use that macro environment to process the remaining parameters. (make_var_shadowing_env): Allow the function to take a single symbol instead of a list of symbols.
* Support keyword params via :key param list macro.Kaz Kylheku2017-01-235-4/+277
| | | | | | | | | | | | | | | | | | * eval.c (expand_param_macro): Use lisplib_try_load to retry failed parameter macro lookup, thereby supporting auto-loading of modules that define parameter macros. * lisplib.c (keyparams_set_entries, keyparams_instantiate): New static functions. (lisplib_init): Support autoloading of keyparams.tl via new functions. * share/txr/stdlib/keyparams.tl: New file. * txr.1: Documented :key param list macro. * checkman.txr: Support "Parameter list macro" documentation section type.
* diagnose (:whole . blah) as dangling :whole.Kaz Kylheku2017-01-231-1/+1
| | | | | * eval.c (bind_macro_params): Test that the rest of the param list after the keyword is consp, not just non-nil.
* bugfix: :whole and :form allow destructuring.Kaz Kylheku2017-01-231-13/+13
| | | | | | | | | | | | | | In bind_macro_params allow the argument of :whole and :form to be a destructuring pattern. Yet, in expand_params, we are wrongly requiring it to be a bindable symbol, thus blocking the feature. * eval.c (expand_opt_params_rec): Only require the argument of a keyword to be a bindable symbol if that keyword is :env. (expand_params_rec): Some refactoring here not to recursively expand keyword as parameters, removing a hacky test in the atom case. Also car_ex is renamed to param_ex. Other than that, same fix as in expand_opt_params_rec.
* bugfix: catch arguments not registered properly.Kaz Kylheku2017-01-231-1/+1
| | | | | | | | Symptom: variables appearing in a @(catch) are reported as unbound variables anyway. * parser.y (process_catch_exprs); The parameters are the second element of the catch form, not its rest.
* Bump copyright year to 2017.Kaz Kylheku2017-01-2382-84/+84
| | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, 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, ftw.c, ftw.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, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.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: Add 2017 to all copyright headers and strings.
* Fix wrong copyright year and add 2017.Kaz Kylheku2017-01-232-2/+2
| | | | | * sock.c, sock.h: This module was not introduced in 2010, but in 2016.
* bugfix: expansion order in face of param macros.Kaz Kylheku2017-01-221-27/+33
| | | | | | | | | | | | | | | | | | | | | | | We are following an incorrect expansion order for parameters and bodies in the face of parameter macros. We are expanding the body first, using the raw, untransformed parameters, which is wrong. Secondly, we then neglect to expand the body which emerges from param expansion. The fix is to pass the unexpanded body to expand_params. Then expand the body which emerges. This also fixes another bug: the macro env passed to param expanders is documented as excluding the parameters. This is now actually true. * eval.c (expand_macrolet, expand_tree_cases, expand_catch_clause): Rearrange expansion logic surrounding call to expand_params. (do_expand): Likewise, and also introduce expansion for the sys:with-dyn-rebinds operator. This is now needed because under the new order, with-dyn-rebinds is now introduced into unexpanded code. If it isn't expanded, then it then wrongly protects its enclosed forms from expansion.
* Don't expand arg in @{var :filter arg}.Kaz Kylheku2017-01-221-1/+27
| | | | | | | * eval.c (expand_var_mods): New static function. (expand_quasi): Use expand_var_mods to expand variable modifies, rather than expand_forms. The new expand_var_mods avoids expanding the argument of the :filter keyword.
* Dynamically rebind *package* in @(load).Kaz Kylheku2017-01-221-0/+1
| | | | | | | * match.c (v_load): Re-bind the *package* variable in the new dynamic scope to its current value, so that any modifications to it by the loaded code are thrown away, just like in the Lisp load function.
* Dump deferred warnings in @(load).Kaz Kylheku2017-01-221-0/+4
| | | | | | * match.c (v_load): Bind *load-recursive* to t around the loading, and dump deferred warnings afterward if the previous value of *load-recursive* is nil.
* parser bugfix: expand used instead of expand_forms.Kaz Kylheku2017-01-221-1/+1
| | | | | * parser.y (o_var): fix expand wrongly being called on a list of forms.
* Enable unbound warnings when expanding TXR code.Kaz Kylheku2017-01-224-17/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this change, Lisp expansion-time warnings are no longer suppressed during the parsing of the TXR pattern language. Embedded Lisp expressions can refer to TXR pattern variables, which generates spurious warnings that must be suppressed. Since TXR pattern variables are dynamically introduced in a very flexible way, it's hard to do an exact job of this. We take the crude approach that warnings are suppressed for all pattern variables that appear anywhere in the TXR code. To do that, we identify, at parse time, all directives which can bind new variables, and register those variables as if they were tentative global defs, purging all pending warnings for them. * match.c (binding_directive_table): New static hash table. (match_reg_var, match_reg_params, match_reg_elem): New functions. (match_reg_var_rec): New static function. (dir_tables_init): gc-protect binding_directive_table, and populate its entries. * match.h (into_k, named_k): Declared. (match_reg_var, match_reg_params, match_reg_elem): Declared. * parser.y (process_catch_exprs): New static function. (elem): Call match_reg_elem for each basic directive, to process the variables in that directive according to its operator symbol. Do this for each compound form elem and variable elem. Te horizontal @(define) eleme has its own grammar production here, and we handle its parameter list in that rule. (define_clause): Handle the parameters of a vertical @(define). It binds pattern variables, and so we must suppress unbound warnings for those. (catch_clauses_opt): Process the parameters bound by @(catch) clauses. (output_clause): Suppress warnings for the variables nominated by any :into or :named argument. (expand_repeat_rep_args): Suppress warnings for :counter variable, and for :vars variables. (parse_once): Remove the warning-muffling handler frame set up around the yyparse call. * txr.c (txr_main): Suppress warnings for TXR variables defined using -D syntax on the command line. Dump deferred warnings after parsing a .txr file.
* Improve accuracy of expansion of repeat/rep args.Kaz Kylheku2017-01-221-8/+10
| | | | | | | * parser.y (expand_repeat_rep_args): Correctly handle situation when :counter or :vars appears as an argument to another keyword. (A warning might be generated here, since this situation is wrong.)
* Strengthen :filter test.Kaz Kylheku2017-01-222-2/+2
| | | | | | | | | * tests/008/filtenv.txr (f): Don't just copy the input to the output but transform it by upcase-str. Otherwise the test will pass even if the :filter syntax is not processed at all! * tests/08/filtenv.expected: Updated.
* Streamline repeated intern call in txr_main.Kaz Kylheku2017-01-221-3/+4
| | | | | * txr.c (txr_main): Reduce three repetitions of the same call to intern to one call.
* doc: grammar under kfs variable.Kaz Kylheku2017-01-211-1/+1
| | | | * txr.1: "when they empty" -> "when they are empty".
* doc: missing :var documented.Kaz Kylheku2017-01-211-0/+25
| | | | | txr.1: the @(next) directive has a :var argument which was added in 2011 but never documented.
* bugfix: expand macros in a number of directives.Kaz Kylheku2017-01-214-13/+76
| | | | | | | | | | | | | | | | | | | | | | | | | This is the last round of changes on this topic, bringing proper macro expansion to the arguments to @(skip), @(fuzz), @(next), @(call), @(cat), @(load) and @(close). * match.c (match_expand_keyword_args): Only process the keyword arguments if they are followed by an argument. Process @(next) arguments here too: :list and :string take a Lisp expression, but :tlist and :var take an argument which is not a Lisp expression and must be handled properly. Also, expand any non-keyword expression. This handles the <source> argument of @(next). (match_expand_elem): New function. * match.h (match_expand_elem): Declared. * parser.h (expand_meta): Declared. * parser.y (expand_meta): Static function becomes external. (elem): Expand elem other than require or do using match_expand_elem. We don't fold require and do into this because match_expand_elem has a backward compat switch in it that doesn't apply to these.
* bugfix: expand dest arg of @(output).Kaz Kylheku2017-01-211-1/+12
| | | | | * parser.y (expand_form_ver): New inline function. (output_clause): If exprs are present, expand first one.
* Consolidate unbound var errors in pattern language.Kaz Kylheku2017-01-201-33/+22
| | | | | | | | | | * match.c (sem_error): Add noreturn attribute to function. (tx_lookup_var_ubc): New static function. (dest_set, v_next, v_flatten, v_cat, v_filter): Use new function to for checked variable lookup. (v_set): Pass first_spec to dest_set, since tx_lookup_var_ubc needs to extract the directive symbol from the context from.
* Expand lisp forms in @(mod) and @(modlast) args.Kaz Kylheku2017-01-191-4/+15
| | | | | | * parser.y (expand_forms_ver): New function. (repeat_parts_opt, rep_parts_opt): Expand the exprs_opt that follow MOD or MODLAST.
* Bugfix: expand macros in collect, coll, gather.Kaz Kylheku2017-01-193-16/+77
| | | | | | | | | | | | | | | In the argument lists of @(collect)/@(repeat), @(coll)/@(rep) and @(gather), Lisp expressions can appear as arguments to keywords or for supplying default values for variables. These are not being macro-expanded. * match.c (match_expand_vars): New static function. (match_expand_keyword_args): New function. * match.h (match_expand_keyword_args): Declared. * parser.y (gather_clause, collect_clause, elem): Use new function in match.c to expand the argument lists.
* Test cases for macros in quasiliterals.Kaz Kylheku2017-01-181-0/+11
| | | | * tests/012/quasi.tl: New tests added.
* Muffle expansion warning in op macro.Kaz Kylheku2017-01-181-2/+6
| | | | | * eval.c (me_op): Install handler to intercept warnings and route them to uw_muffle_warning.
* Bugfix: macros not expanded in quasiliterals.Kaz Kylheku2017-01-181-0/+2
| | | | | | * eval.c (expand_quasi): Add all-important missing case which expands compound forms. This looks like a txr-160 regression.
* Document new diagnostic functions.Kaz Kylheku2017-01-161-0/+235
| | | | | | | | * txr.1: New section Static Error Diagnosis describing error handling and warnings. Documented functions tentative-def-exists, register-tentative-def, purge-deferred-warning, compile-defr-warning, compile-error and compile-warning
* bugfix: supertype check in make-struct-type.Kaz Kylheku2017-01-161-1/+1
| | | | | | * struct.c (make_struct_type): Fix test of incorrect variable which renders the supertype test useless, causing the type to be created with no supertype.
* defstruct: use warning for bad baseKaz Kylheku2017-01-161-4/+4
| | | | | * share/txr/stdlib/struct.tl (defstruct): Making nonexistent base type a deferrable warning.
* defstruct uses new error reporting functions.Kaz Kylheku2017-01-161-35/+32
| | | | | | | * share/txr/stdlib/struct.tl (sys:bad-slot-syntax): Takes form argument. Uses compile-error function. (defstruct): Use modified form of sys:bad-slot-syntax and compile-error instead of throw.
* defmeth uses new error reporting.Kaz Kylheku2017-01-161-6/+9
| | | | | | | * share/txr/stdlib/struct.tl (sys:defmeth): Removing checks from here. (defmeth): Add checks here with new functions which provide location info and warning deferral/supression.
* defstruct registers tentative definition.Kaz Kylheku2017-01-161-0/+1
| | | | | * share/txr/stdlib/struct.tl (defstruct): Register the struct ame as a tentative definition.
* Use tentative def mechanism for functions and vars.Kaz Kylheku2017-01-151-0/+6
| | | | | | * eval.c (do_expand): When walking a defun or defvarl, register them as tentative defs. Thus warnings are nicely supressed in code like (progn (defun foo ()) (foo)).
* Extend deferred warnings system with tentative defs.Kaz Kylheku2017-01-152-3/+21
| | | | | | | | | | | | | | | | | | | | Tentative defs record the fact that some definition has been seen at expansion time, even though that definition has not been put into effect. They suppress warnings. * unwind.c (tentative_defs): New static variable. (uw_defer_warning): Throw away the warning if it matches a tentative def. (uw_register_tentative_def, uw_tentative_def_exists): New functions. (uw_dump_deferred_warnings): Purge the tag from the list of deferred defs also. (uw_init): gc-protect tentative_defs. Register intrinsics register-tentative-def and tentative-def-exists. * unwind.h (uw_register_tentative_def, uw_tentative_def_exists): Declared.
* Dump deferred warnings in eval_intrinsic.Kaz Kylheku2017-01-152-3/+12
| | | | | | | | | | | | * eval.c (eval_intrinsic): Dump deferred warnings after expansion, unless in the middle of a load. * parser.c (read_eval_ret_last): Bind *load-recursive* around all evaluations to t, then dump warnings if prior value of *load-recursive* is nil. Thus the repl's :read feature behaves like load. (repl_warning): We can now unconditionally defer deferrable warnings here now, whether or not in a load.
* Rebind *stderr* on entry into repl.Kaz Kylheku2017-01-151-0/+4
| | | | | * parser.c (repl): Create a new dynamic env and rebind *stderr* variable to the repl's output stream.
* Functions for error reporting out of macros.Kaz Kylheku2017-01-155-0/+70
| | | | | | | | | | | | | | | | | * eval.c (eval_init): Register sys:ctx-form and sys:ctx-name intrinsics. * lisplib.c (error_set_entries, error_instantiate): New static functions. (lisplib_init): Register autoloading of error.tl via new functions. * share/txr/stdlib/error.tl: New file. * struct.c (make_struct_type): Purge deferred warnings. * unwind.c (uw_late_init): Register purge-deferred-warning intrinsic.