summaryrefslogtreecommitdiffstats
path: root/eval.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Update copyright notices from 2014 to 2015.Kaz Kylheku2015-02-011-1/+1
| | | | | | | | | | | * arith.c, arith.h, combi.c, combi.h, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Update. * LICENSE, METALICENSE: Likewise.
* * arith.c (make_ubignum): New static function.Kaz Kylheku2015-01-291-0/+1
| | | | | | | | | | | | (sign_extend): New function. * eval.c (eval_init): Register sign-extend intrinsic. * lib.h (sign_extend): Declared. * txr.1: Documented sign-extend. * tl.vim, txr.vim: Updated.
* * eval.c (get_opt_param_syms): Fix broken function. ThisKaz Kylheku2015-01-281-9/+8
| | | | | | was choking on keywords like :env in the lambda list, and failing to handle the nested patterns of macro lambda lists. Failing case: (defmacro x (: opt :env foo)).
* * eval.c (bind_macro_params): Bugfix: the colon argument's specialKaz Kylheku2015-01-281-1/+1
| | | | | meaning "treat the argument as missing" must apply only to optional parameters.
* * arith.c (width): New function.Kaz Kylheku2015-01-271-0/+1
| | | | | | | | * arith.h (width): Declared. * eval.c (eval_init): Width registered as intrisinc. * txr.1: Documented width.
* * eval.c (call_f): new global variable.Kaz Kylheku2015-01-251-2/+19
| | | | | | | | | (do_mapf, mapf): new static functions. (eval_init): protect call_f from gc, and initialize it. re-register call function using call_f. register mapf intrinsic. * txr.1: Documented mapf.
* * eval.c (eval_init): Register dupl and swap_12_21 asKaz Kylheku2015-01-251-0/+2
| | | | | | | | | | | the dup and flip intrinsics. * lib.c (do_dup): New static function. (dupl): New function. * lib.h (dupl): Declared. * txr.1: Documented dup and flip.
* * eval.c (callf): New static function.Kaz Kylheku2015-01-241-0/+8
| | | | | | (eval_init): callf registered. * txr.1: Documented callf.
* Basic implementation of constantp. Does notKaz Kylheku2015-01-211-0/+37
| | | | | | | | | | | recognize forms like (+ 2 2) as constant. * eval.c (constantp_noex, constantp): New functions. (eval_init): Registered constantp as intrinsic. * tl.vim, txr.vim: Updated. * txr.1: Documented constantp.
* Allow macros to tell what symbols have lexical functionKaz Kylheku2015-01-211-0/+36
| | | | | | | | | | | or variable bindings. * eval.c (lexical_var_p, lexical_fun_p): New local functions. (eval_init): Registered as intrinsics. * txr.1: Documented lexical-var-p and lexical-fun-p. * tl.vim, txr.vim: Updated.
* * arith.c (zerop): Handle character arguments.Kaz Kylheku2015-01-121-0/+2
| | | | | | | | | | | (plusp, minusp): New functions. * eval.c (eval_init): Register plusp and minusp. * lib.h (plusp, minusp): Declared. * txr.1: Documented plusp and minusp, and the handling of characters by zerop.
* * eval.c (merge_wrap): Make generic over sequences.Kaz Kylheku2015-01-111-5/+18
| | | | * txr.1: Update documentation for merge function.
* * eval.c (ap_s, ret_s, aret_s): New symbol variables.Kaz Kylheku2014-12-231-7/+13
| | | | | | | | | | | | (me_ret): Static function renamed to me_ret_aret. Handles ret and aret macro expansion. (eval_init): Initialize ap_s, ret_s and aret_s. Re-register ret macro using ret_s and bind to me_ret_aret. Register aret macro. * txr.1: Documented aret. * tl.vim, txr.vim: Regenerated.
* * eval.c (eval_init): Registered intrinsic function unique.Kaz Kylheku2014-12-231-0/+1
| | | | | | | | | | | * lib.c (unique): New function. (uniq): Becomes wrapper around unique. * lib.h (unique): Declared. * txr.1: Documented unique, and equivalence between uniq and unique. * tl.vim, txr.vim: Regenerated.
* * eval.c (eval_init): Register in function as intrinsic.Kaz Kylheku2014-12-051-0/+1
| | | | | | | | | | * lib.c (in): New function. * lib.h (in): Declared. * txr.1: Documented in. * txr.vim, tl.vim: Regenerated.
* * eval.c (eval_init): Register lequal and gequal.Kaz Kylheku2014-11-271-0/+2
| | | | | | | | | | * lib.c (lequal, gequal, lequalv, gequalv): New functions. * lib.h (lequal, gequal, lequalv, gequalv): Declared. * txr.1: Documented lequal and gequal. * txr.vim, tl.vim: Regenerated.
* * eval.c (eval_init): Register less and greater toKaz Kylheku2014-11-271-2/+2
| | | | | | | | | | the lessv and greaterv functions instead of less and greater. * lib.c (lessv, greaterv): New functions. * lib.h (lessv, greaterv): Declared. * txr.1: Document variadic nature of less and greater.
* * eval.c (eval_init): Register sort-group.Kaz Kylheku2014-11-211-0/+1
| | | | | | | | * lib.c (sort_group): New function. * lib.h (sort_group): Declared. * txr.1: Documented.
* * arith.c (wrap_star, wrap): New functions.Kaz Kylheku2014-11-201-0/+2
| | | | | | | | * eval.c (eval_init): Registered wrap and wrap* intrinsics. * lib.h (wrap_star, wrap): Declared. * txr.1: wrap and wrap* documented.
* * arith.c (succ, ssucc, sssucc, pred, ppred, pppred): New functions.Kaz Kylheku2014-11-201-0/+6
| | | | | | | | * eval.c (eval_init): Register new functions as intrinsics. * lib.h (succ, ssucc, sssucc, pred, ppred, pppred): Declared. * txr.1: Documented.
* * eval.c (opip_s, oand_s, chain_s, chand_s): New global variables.Kaz Kylheku2014-11-101-2/+41
| | | | | | | | | | | | (macro_form_p): Forward declaration added. (me_opip): New static function. (eval_init): Intern new symbols, register opip and oand macros to me_opip function. Use chain_s and chand_s in registration for chain and chand. * txr.1: Document opip and oand * tl.vim, txr.vim: Regenerated.
* * eval.c (eval_init): Register chand intrinsic.Kaz Kylheku2014-11-061-0/+1
| | | | | | | | | * lib.c (do_chand): New static function. (chandv): New function. * lib.h (chandv): Declared. * txr.1: Documented chand.
* Allow then-func to be omitted in iff. Cleanup.Kaz Kylheku2014-11-061-1/+1
| | | | | | | | | * eval.c (eval_init): Register iff as requiring only one arg. * lib.c (do_iff): Do not check thenfun for nil. Just call it. (iff): Default thenfun to identity. * txr.1: Documentation updated.
* New macros tb and tc.Kaz Kylheku2014-10-311-0/+30
| | | | | | | * eval.c (me_tb, me_tc): New static functions. (eval_init): Registered tb and tc macros. * txr.1: Documented tb and tc.
* * Makefile: Removing trailing spaces.Kaz Kylheku2014-10-241-40/+39
| | | | | | | | | | (GREP_CHECK): New macro. (enforce): Rewritten using GREP_CHECK, with new checks. * arith.c, combi.c, debug.c, eval.c, filter.c, gc.c, hash.c, lib.c, * lib.h, match.c, parser.l, parser.y, rand.c, regex.c, signal.c, * signal.h, stream.c, syslog.c, txr.c, unwind.c, utf8.c: Remove trailing spaces.
* * eval.c (eval_init): Fix incorrect, registration ofKaz Kylheku2014-10-221-1/+1
| | | | repeat; it must have one optional argument.
* * eval.c (interp_fun): If the function doesn't haveKaz Kylheku2014-10-211-5/+13
| | | | | specials, then don't bother saving and restoring dynamic env around the argument binding and evaluation.
* * eval.c (eval_init): Register notf intrinsic function.Kaz Kylheku2014-10-211-0/+1
| | | | | | | | | | | | | | * lib.c (do_not): New static function. (notf): New function. * lib.h (notf): Declared. * txr.1: Documented notf. * share/txr/stdlib/txr-case.txr (bindable): Eliminated. (txr-if): Use functional expression, taking advantage of notf. * txr.vim: Regenerated.
* Converting cast expressions to macros that are retargettedKaz Kylheku2014-10-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to C++ style casts when compiling as C++. * lib.h (strip_qual, convert, coerce): New casting macros. (TAG_MASK, tag, type, wli_noex, auto_str, static_str, litptr, num_fast, chr, lit_noex, nil, nao): Use cast macros. * arith.c (mul, isqrt_fixnum, bit): Use cast macros. * configure (INT_PTR_MAX): Define using cast macro. * debug.c (debug_init): Use cast macro. * eval.c (do_eval, expand_macro, reg_op, reg_mac, eval_init): Use cast macros. * filter.c (filter_init): Use cast macro. * gc.c (more, mark_obj, in_heap, mark, sweep_one, unmark): Use cast macros. * hash.c (hash_double, equal_hash, eql_hash, hash_equal_op, hash_hash_op, hash_print_op, hash_mark, make_hash, make_similar_hash, copy_hash, gethash_c, gethash, gethash_f, gethash_n, remhash, hash_count, get_hash_userdata, set_hash_userdata, hash_iter_destroy, hash_iter_mark, hash_begin, hash_uni, hash_diff, hash_isec): Use cast macros. * lib.c (code2type, chk_malloc, chk_malloc_gc_more, chk_calloc, chk_realloc, chk_strdup, num, c_num, string, mkstring, mkustring, upcase_str, downcase_str, string_extend, sub_str, cat_str, trim_str, c_chr, vector, vec_set_length, copy_vec, sub_vec, cat_vec, cobj_print_op, obj_init): Likewise. * match.c (do_match_line, hv_trampoline, match_files, dir_tables_init): Likewise. * parser.l (grammar): Likewise. * parser.y (parse): Likewise. * rand.c (make_state, make_random_state, random_fixnum, random): Likewise. * regex.c (CHAR_SET_L2_LO, CHAR_SET_L2_HI, CHAR_SET_L1_LO, CHAR_SET_L1_HI, CHAR_SET_L0_LO, CHAR_SET_L0_HI, L0_full, L0_fill_range, L1_full, L1_fill_range, L1_contains, L1_free, L2_full, L2_fill_range, L2_contains, L2_free, L3_fill_range, L3_contains, L3_free, char_set_create, char_set_cobj_destroy, nfa_state_accept, nfa_state_empty, nfa_state_single, nfa_state_wild, nfa_state_set,
* * arith.c (gcd): Fix semantics. If either operand isKaz Kylheku2014-10-161-1/+2
| | | | | | | | | | | | | | | | zero, return the other operand. (lcm): New function. * eval.c (eval_init): Retarget registration of gcd to variable argument gcdv function. Register lcm. * lib.c (gcdv, lcmv): New functions. * lib.h (gcdv, lcm, lcmv): Declared. * txr.1: Re-document gcd with coverage of lcm. * txr.vim: Regenerated.
* * eval.c (eval_init): Register greater function as intrinsic.Kaz Kylheku2014-10-131-0/+1
| | | | | | | | | | | | | | | | | | | | * lib.c (gt_f, lt_f): Global variables removed. (greater_f): New variable. (greater): New function. (find_max, pos_max): Use greater_f as default for testfun, rather than gt_f. (find_min, pos_min): Use less_f as default for testfun, rather than lt_f. (obj_init): Remove references to gt_f and lt_f. GC-protect and initialize greater_f. * lib.h (greater_f): Declared. (gt_f, lt_f): Declarations removed. * txr.1: Documented greater, and use of less and greater in pos-min, pos-max, find-min and find-max. * txr.vim: Regenerated.
* * eval.c (merge_wrap): New static functionKaz Kylheku2014-10-121-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | (eval_init): Register less as intrinsic. Retarget merge intrinsic to merge_wrap for proper argument defaulting which is missing from merge, and which we don't want to introduce there since internal calls to merge don't erquire it. Change registration of sort so it has only one required argument, not two. * lib.c (less_f): New global variable. (less_tab): New static array. (less_tab_init): New static function. (less): New function. (sort): Default lessfun argument to the less function. (obj_init): GC-protect the less_f variable. Initialize it with a function object made from the less function. (init): Call less_tab_init. * lib.h (enum type): New enumeration member MAX_TYPE, an alias for the largest type. (less_f, less): Declared. * txr.1: Documented new less function, and that the lessfun argument in sort and merge is optional, defaulting to less. * txr.vim: Regenerated.
* * eval.c (eval_init): Register chr_isblank and chr_isunisp asKaz Kylheku2014-10-111-0/+2
| | | | | | | | | | | | | | | | intrinsics. * lib.c (chr_isblank, chr_isunisp): New functions. * lib.h (chr_isblank, chr_isunisp): Declared. * regex.h (spaces): Declaration for existing variable added. * txr.1: Documented chr-isblank and chr-isunisp. * genvim.txr: Add missing sysif.c. * txr.vim: Regenerated.
* Moving system interface functions to separate module out ofKaz Kylheku2014-10-081-134/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the eval and stream modules. * Makefile (OBJS): Add sysif.o. * dep.mk: Regenerated. * eval.c (errno_wrap, daemon_wrap, exit_wrap, usleep_wrap, getpid_wrap, getppid_wrap, env_hash): Functions moved to sysif.c and changed to static functions. (eval_init): Registrations of functions moved to sysif.c. * lib.c (init): Call sysif_init. * stream.c (w_stat, statf, mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap): Functions moved to sysif.c and become static functions. (stream_init): Registration of stat moved to sysif.c. (open_files, open_files_star): Bugfix: no longer erroneously included in #ifdef HAVE_UNISTD_H block. * stream.h (mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap, symlink_wrap, link_wrap, readlink_wrap): Declarations removed. * sysif.c: New file. * sysif.h: New file.
* Eliminating the extra list wrapping applied to regularKaz Kylheku2014-10-031-23/+15
| | | | | | | | | | | | | | | | | | | expression objects in the syntax tree. The parser just puts out a #<regex ...> instead of (#<regex ...> regex-syntax). * eval.c (do_eval): We no longer need the hack of treating (#<regex> ...) as a special form which evaluates to #<regex>. (expand): We no longer have to skip over regex syntax, so the case is removed. * match.c (h_var, do_txeval, do_match_line): regexp cases are no longer subcases of consp but stand on their own. In do_match_line, we introduce a COBJ case into the type switch for regexes. * parser.y: regexes are now compiled in the regex and lisp_regex grammar rules instead of the dependent rules, and are not wrapped in extra syntax.
* * eval.c (eval_init): Register intrinsic partition* function.Kaz Kylheku2014-09-091-0/+1
| | | | | | | | | * lib.c (partition_star_func): New static function. (partition_star): New function. * lib.h (partition_star): Declared. * txr.1: Documented partition*.
* * eval.c (eval_init): Register intrinsic partition function.Kaz Kylheku2014-09-091-0/+1
| | | | | | | | | * lib.c (partition_func): New static function. (partition): New function. * lib.h (partition): Declared. * txr.1: Documented partition.
* * eval.c (eval_init): Update registration of lisp-parse and readKaz Kylheku2014-09-021-2/+2
| | | | | | | | | | | | | | | | | | | | to account for new parameter. * lib.c (syntax_error_s): New symbol_variable. (obj_init): New symbol variable initialized. * lib.h (syntax_error_s): Declared. * parser.h (lisp_parse): Declaration updated. * parser.l (lisp_parse): Takes third parameter. * txr.1: Third parameter of read described. * txr.c (txr_main): Pass colon_k to third parameter of lisp_parse to obtain exception throwing behavior. * unwind.c (uw_init): Register syntax-error as subtype of error.
* * eval.c (expand_quasi): Regression: fix broken handlingKaz Kylheku2014-08-291-7/+1
| | | | | | of @{var mod} syntax triggering a bogus assertion. Mods are the third element in the abstract syntax now, not fourth. There is no next link. Removing bogus comment referring to a nonexistent function.
* Uprooting stupidities in handling of output variables.Kaz Kylheku2014-08-131-6/+3
| | | | | | | | | | | | | | | | | | | | * parser.y (o_elems_transform): Remove useless function which was only unwrapping the strange parse of output vars. (o_elems_opt, rep_elem, quasilit, wordsqlit): Eliminate o_elems_transform call. (o_var, q_var): Eliminate the phrase structure rules which match an extra o_elem or quasi_item, and which incorporate them into the var syntax tree element. Place the modifiers into the third position, not fourth. * eval.c (subst_vars): Eliminate handling of "pat" element. Actually that was not even there thanks to o_elems_transform being applied: dead code. Pull modifiers from the third element of the var form now, not fourth. * match.c (subst_vars): Similar changes as in the match.c subst_vars function. Here the pat variable is even more obviously useless; if it is not nil, it is just punted back to the spec.
* Bugfix: ret operator does not generate functionsKaz Kylheku2014-08-081-1/+3
| | | | | | | | | that take any number of arguments. * eval.c (me_ret): Generate (op identity (progn @rest <expr>)) rather than of (op identity <expr>). * txr.1: Update misleading equivalence.
* No getppid on MinGW.Kaz Kylheku2014-08-071-0/+6
| | | | | | * configure: Add test for getppid. * eval.c (getppid_wrap, eval_init): use HAVE_GETPPID
* * eval.c (eval_init): Fix incorrect registration ofKaz Kylheku2014-08-051-1/+1
| | | | | random-fixnum, which doesn't allow it to be called with no arguments.
* * eval.c (getpid_wrap, getppid_wrap): New static functions.Kaz Kylheku2014-07-301-0/+16
| | | | | | | | | (eval_init): Registered getpid and getppid intrinsics. * signal.c (kill_wrap): New static function. (sig-init): Registered kill intrinsic function. * txr.1: Documented getpid, gettpid and kill.
* * eval.c (eval_init): Register uniq function.Kaz Kylheku2014-07-291-0/+1
| | | | | | | | * lib.c (uniq): New function. * lib.h (uniq): Declared. * txr.1: Documented uniq.
* * eval.c (repeatv): Renamed to repeat. Turned into functionKaz Kylheku2014-07-291-6/+6
| | | | | | | | | with one optional argument, reflecting existing behavior. (eval_init): Registration of repeat updated. * txr.1: Fixed incorrect documentation which falsely suggests that repeat takes multiple lists, and doesn't mention the optional count.
* * eval.c (eval_init): Register nconc as intrinsic.Kaz Kylheku2014-07-291-0/+1
| | | | | | | | * lib.c (nconcv): New function. * lib.h (nconcv): Declared. * txr.1: Documented nconc.
* * eval.c (giterate_func, giterate): Adjusting semantics of giterate toKaz Kylheku2014-07-291-7/+3
| | | | | | | | include seed item in the sequence. The while test is applied to each item before it is passed through the function. Also, eliminated useless rplacd operation. * txr.1: Updated documentation of giterate.
* * eval.c (eval_init): Register partition-by intrinsic.Kaz Kylheku2014-07-281-0/+1
| | | | | | | | | * lib.c (partition_by_func): New static function. (partition_by): New function. * lib.h (partition_by): Declared. * txr.1: Documented partition-by.
* * eval.c (giterate_func, giterate): New static functions.Kaz Kylheku2014-07-271-0/+31
| | | | | | (eval_init): Registered giterate as intrinsic. * txr.1: Documented giterate.