summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Expander check for macro destination in setq forms.Kaz Kylheku2017-02-031-0/+4
| | | | | * eval.c (do_expand): Throw an error if the destination is a symbol macro which requires expanding.
* When expanding sys:lisp1-value, check for bad form.Kaz Kylheku2017-02-031-1/+5
| | | | | * eval.c (expand_lisp1_value): If the first argument is an object other than a bindable symbol, throw an error.
* More accurate error wording from Lisp-1 operators.Kaz Kylheku2017-02-031-2/+2
| | | | | | | * eval.c (op_lisp1_setq, op_lisp1_value): If a Lisp-1 binding is not found, this is because it is neither a function nor variable, not because it is not a variable. The error message now reflects this.
* Remove sys:*lisp1* hack from place expansion.Kaz Kylheku2017-02-031-24/+32
| | | | | | | | | | | | | | | | | | | | | | | | Instead of using a special variable hack to pass down the request to treat a form as Lisp-1 if it happens to be a symbol, we now wrap the form in ^(sys:l1-val ,form). We define sys:l1-val as a place. In the case when form is a symbol with no lexical binding, requiring the special Lisp-1 treatment, sys:l1-val produces ^(sys:lisp1-value, form). We define that as a place also, and that takes care of everything. * share/txr/stdlib/place.tl (sys:*lisp1*): Special variable removed. (sys:sym-update-expander, sys:sym-clobber-expander): Do not test sys:*lisp1*; just produce a sys:setq form for updating a symbolic place. (call-update-expander, call-clobber-expander, call-delete-expander): Drop the bugfix in the previous commit: re-binding of sys:*lisp1* to nil (defplace sys:l1-val, defplace sys:lisp1-value): New places. (defplace dwim): Do not bind sys:*lisp1*. Wrap obj-place in a sys:l1-val form, thereby annotating it so that it receives the right sort of place expander.
* bugfix: limit depth of Lisp-1 treatment of places.Kaz Kylheku2017-02-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This underscores why sys:*lisp1* is so hacky and should be removed. When we obtain the update, clobber or delete expander of a place which is the argument of a DWIM, requiring Lisp-1 treatment, we bind the sys:*lisp1* special. This alters the behavior of obtaining an expander for a symbolic place. Unfortunately, because call-update-expander (and friends) use sys:expand, all levels of the form are subject to place expansion with sys:*lisp1* bound to t. Example: (set [(car (inc a 2)) 10] "foo") Here, the (car ...) form is the place operand of the DWIM operator, and so sys:*lisp1* is set up around getting its expander. But then, oops, the a in (inc a 2) is also treated as Lisp-1, wrongly. These changes band-aid the situation. * share/txr/stdlib/place.tl (call-udpate-expander, call-clobber-expander, call-delete-expander): After retrieving the expander, bind sys:*lisp1* to nil so that its effect does not spill over into the sys:expand call which we apply to the expansion; i.e. reset sys:*lisp1* to nil around recursive expansion so that the Lisp-1 treatment is confined to depth 1.
* Version 167.txr-167Kaz Kylheku2017-02-026-590/+633
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* parser: diagnose run-on symbols.Kaz Kylheku2017-02-011-0/+14
| | | | | | | | | | * parser.l (grammar): Add rules which capture two symbols glued together, and diagnose as bad token. Of course a legitimate symbol token can be divided into two that are glued together. This rule is placed after the legitimate symbol matching rule, so that if a token can be interpreted as a single symbol token or as two, the first interpretation is taken.
* parser: diagnose more kinds of junk after float.Kaz Kylheku2017-02-011-1/+2
| | | | | | | | | * parser.l (grammar): Add a rule that if a floating-point (of the type that ends in decimal digits with an optional exponent) is immediately followed by a period which is not followed by another period (range syntax), it is trailing junk. For instance 1.0.3 or .2.$, or 1.0. followed by no other input.
* Suppress undef warnings in command line file.Kaz Kylheku2017-01-291-0/+3
| | | | | | * txr.c (txr_main): Bind sys:*load-recursive* to t before reading and evaluating forms, then bind to nil before entering repl.
* Optimize merge a little.Kaz Kylheku2017-01-291-4/+6
| | | | | * lib.c (merge): Eliminate extra call to cdr by keeping the result of cdr_l, and working with the location.
* bugfix: make list sorting stable, as documented.Kaz Kylheku2017-01-291-11/+11
| | | | | | | | | | | | * lib.c (merge): Fix unstable logic here. What we want is that when the item from list1 is *not less* than the item from list2, we take them in that order. Since all we have is a less function, we must test (less item2 item1). If this is false, then preserve the order, because when the keys are identical, the less function yields false. (sort_list): A similar change takes place here when we sort a list of length two (which is essentially an inlined case of merge).
* awk: support list of string as input source.Kaz Kylheku2017-01-292-4/+17
| | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Allow an input source to be a list of strings, which is converted to a stream. * txr.1: Documented.
* bugfix: read print consistency of shadowed symbols.Kaz Kylheku2017-01-291-7/+14
| | | | | | | | | | | | | | Suppose that a program-defined package is current, has usr as its :fallback, and has a :local symbol list. Then if 'usr:list is printed, it must print with the usr: package symbol because it is not visible. It is printing without the prefix. * lib.c (symbol_present): Function renamed to symbol_visible, which is much more descriptive of what its return value means. The bug in this function is that it does not stop searching when, in its search path, it encounters a symbol which has the same name as sym, but which isn't sym. But such a symbol makes sym invisible. This is now fixed.
* Simplify gethash variants using new function.Kaz Kylheku2017-01-292-12/+10
| | | | | | | | | * hash.c (gethash_e): New function. Just returns the entry cell if found, or else nil. This should have been written first. (gethash, gethash_f, gethash_n): Replace body with trivial one-liner based on gethash_e. * hash.h (gethash_e): Declared.
* doc: new package example showing function override.Kaz Kylheku2017-01-291-0/+39
| | | | | | | * txr.1: Example showing + symbol being replaced in a custom package with a local symbol, and a function being bound which overloads + to allow strings and numbers.
* catch: expand param macros before inserting arg.Kaz Kylheku2017-01-291-2/+5
| | | | | | | * share/txr/stdlib/except.tl (catch): Expand the parameters and body of each clause with sys:expand-params to get rid of parameter macros. Then insert the leftmost gensym. This now allows parameter macros to be used in cach clauses.
* Expose expand_params as sys:expand-params.Kaz Kylheku2017-01-291-0/+1
| | | | | * eval.c (eval_init): Register sys:expand-params intrinsic bound to expand_params.
* bugfix: :filter not handled right in output var.Kaz Kylheku2017-01-263-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This issue was fixed in quasiliterals only. Because of the implementation duplicity between output vars and quasiliteral vars, we have to fix it in two places. When the parser handles quasiliterals, it builds vars without expanding the contents. The quasiliteral expander takes care of recognzing (sys:var ...) forms and properly handles them and their attributes, avoiding expanding the argument of a :filter keyword. When the parser handles an o_var that is a braced variable, it calls expand on its contents right there, then builds the (sys:var ...) form from the expanded contents. Why don't we just call expand_quasi in the o_var rule to have a single (sys:var ...) form expanded exactly how it is done in quasiliterals. * eval.c (expand_quasi): Change static function to external. * eval.c (expand_quasi): Declared. * parser.y (o_var): Construct an unexpanded (sys:var ...) form, and then wrap it in a one-element list. This is a de-facto quasi-items list, which can be expanded by expand_quasi. Then we pull the car of the expansion to get our expanded var.
* Expose defer-warning and dump-deferred-warnings.Kaz Kylheku2017-01-262-0/+55
| | | | | | | * unwind.c (uw_late_init): Register defer-warning and dump-deferred-warnings intrinsics. * txr.1: Documented.
* bugfix: forgotten autoload registrations.Kaz Kylheku2017-01-261-1/+2
| | | | * lisplib.c (except_set_entries): Add catch* and handle*.
* Version 166.txr-166Kaz Kylheku2017-01-266-672/+740
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* awk macro: provide name of current input via fname.Kaz Kylheku2017-01-262-0/+29
| | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slot, file-name. (sys:awk-state loop): Set file-name from current input name, or else from the stream name property if the current input is a stream object. (sys:awk-mac-let): New awk macro, fname. * txr.1: Documented fname.
* 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.