summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Version 77txr-77Kaz Kylheku2014-01-296-64/+130
|
* * regex.c (match_regex_right): Fix not returning value.Kaz Kylheku2014-01-292-0/+6
|
* Default argument initializer scoping rule change, allowingKaz Kylheku2014-01-293-13/+50
| | | | | | | | | | | | | things like (defun foo (s : (l (length s))) ...). Default arguments can be initialized by expressions that refer to the arguments. * eval.c (bind_args): By means of a local array, defer the evaluation of optional argument init forms until the lexical environment, including all the parameters, is captured. Then valuates the forms in the array, and set the variable values. * txr.1: Clarify the new scoping rules.
* * eval.c (eval_init): Registered existing make_catenated_stream asKaz Kylheku2014-01-284-5/+95
| | | | | | | | | | | | | | intrinsic. * stream.c (cat_get_line, cat_get_char, cat_get_byte): Do not remove the last stream from the stream list, so that there is some stream object there which can take the unget-char or unget-byte operations. (cat_unget_byte, cat_unget_char): New static functions. (cat_stream_ops): unget_char and unget_byte function pointers filled in. * txr.1: Documented catenated-streams.
* * stream.c (struct stdio_handle): New member, is_rotated.Kaz Kylheku2014-01-282-17/+89
| | | | | | | | | | Moved mode member down. (make_stdio_stream_common): Initialize is_rotated. (tail_strategy): Substantially rewritten in order to address a possible race condition, when a file is rotated. The issue is that even when the file disappears, or when the file has been replaced, we must continue reading from the old stream until the end, and only then can we switch to the newly rotated file.
* * stream.c (remove_path, rename_path): New functions.Kaz Kylheku2014-01-286-1/+54
| | | | | | | | | | | * stream.h (remove_path, rename_path): Declared. * utf8.c (w_remove, w_rename): New functions. * utf8.h (w_remove, w_rename): Declared. * eval.c (eval_init): Registered remove_path and rename_path as intrinsics.
* * eval.c (meta_meta_p, meta_meta_strip): New static functions.Kaz Kylheku2014-01-287-104/+175
| | | | | | | | | | | | | | | (transform_op): Recognize compounded metas, and strip one level off. (eval_init): Intern sys:expand function so we have access to the form expander from TXR Lisp. * lib.c (obj_print, obj_pprint): Fix: wasn't rendering metanumbers. * parser.y (list): Support @ in front of anything. If it's an atom, treat it similarly to a metasymbol or metanumber. * txr.1: Documented meta-meta arguments in nested op. * genvim.txr, txr.vim: Support coloring for compounded meta syntax.
* * txr.vim, genvim.txr: There can now be whitespace in TXR LispKaz Kylheku2014-01-273-80/+84
| | | | like @ (a b c) and @ [1 2 3].
* Lexing and parsing improvements, leaving things less hacky than before,Kaz Kylheku2014-01-273-61/+60
| | | | | | | | | | | | | | | | | | | | | | | albeit hacky. * parser.l (BSYM, NSYM): Regex definitions gone. (BT0, BT1, BT2, NT0, NT1, NT2): New regex definitions. (BTREG, BTKEY, NTREG, NTKEY): Rewritten, so that they cannot match a lone @ character as a symbol name. (grammar): Rules for returning METAPAR, METABKT and METAQUO are gone. Instead, we just recognize a @ in the NESTED and BRACED states and return it as a token. * parser.y (METAPAR, METABKT, METAQUO): Token types removed. (meta_expr): Nonterminal symbol removed. ('@'): New token type. (list): Quotes and splices handling removed from this rule. The new token '@' is handled here, on the other hand, because there are places that reference the list rule that need to support @ expressions. (n_expr): Reference to meta_expr removed. Quote, unquote and splice added here. (yybadtoken): Removed references to METAPAR, METABKT and METAQUO.
* * parser.y (yybadtoken): Handle METAQUO in switch.Kaz Kylheku2014-01-272-0/+5
|
* * lib.c (reduce_left, reduce_right): changing the behavior so thatKaz Kylheku2014-01-273-22/+84
| | | | | | | | | the initial value is optional. this creates the possibility that the effective list of operands is empty, in which case the function must support a call with no arguments, just like in the common lisp reduce. * txr.1: rewrote reduce-left and reduce-right documentation.
* * regex.c (match_regex_right): Fix semantics of second argumentKaz Kylheku2014-01-273-11/+74
| | | | | | | | to something more useful. * regex.h (match_regex_right): Change name of parameter. * txr.1: Documented match-regex-right.
* * lib.c (obj_print, obj_pprint): Bugfix: there may beKaz Kylheku2014-01-272-2/+9
| | | | | | additional expressions forms in (sys:var <sym>) after the sym. These were not being printed. Such syntax occurs often in the TXR pattern language.
* * regex.c (match_regex_right): New function.Kaz Kylheku2014-01-264-0/+31
| | | | | | * regex.h (match_regex_right): Declared. * eval.c (eval_init): Register match_regex_right as instrinsic.
* Implementing more correct treatment of meta formsKaz Kylheku2014-01-262-36/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | like @[...] and @(...) occurring in the TXR pattern language. The previous behavior is that the parser always expands the interior of these forms when they occur. This is wrong. These forms only denote TXR Lisp (and so require expansion) when they occur in a directive, inside a sub-expression that is not already known to be Lisp. For instance in @(do @(op foo)), the inner @(op foo) should not be subject to expansion. The reason that the argument forms of @(do) are TXR Lisp. The @(op foo) form denotes (sys:expr foo), and that operator currently has no meaning; and so we should not expand it. The previous, buggy behavior would turn the @(op ..) into a @(lambda ...). Another example is @(bind a @(list @(op foo))) where @(list ...) denotes TXR Lisp and so the interior of the form should be expanded. However, the @(op foo) should not be expanded into @(lambda ...) Expanding @(...) forms is not currently harmful, but it interferes with code that wants to use the @(...) syntax for its own use, The solution involves adding shims in the parser so that the expansion is only applied when expressions are reduced to the top level within a directive, and then to walk the expressions, looking for the @ syntax and expanding only the outermost occurrence thereof. * parser.y (expand_meta): New static function. (n_exprs n_expr): New nonterminal symbols. (elem): The arguments of the list elem (representing a generic directive) now need to be put through expand_meta when it is not @(do ...) or @(require ...). (list): Use n_exprs instead of exprs. (meta_expr): Do not call expand, and use n_expr(s) instead of expr(s). (exprs, expr): These rules no become just a shim which expands the outer-most metas. The actual parsing is represented by n_expr and n_exprs ("n" stands for nested), which behave just like the old expr and exprs.
* Sigh; more lexical-syntactic hacks. This adds handlingKaz Kylheku2014-01-263-10/+41
| | | | | | | | | | for the @' combination, as in @(bind a @'(foo ,bar)) * parser.l: Handle the new METAQUO token. * parser.y (METAQUO): New token. (meta_expr): New "METAQUO expr" case. Added missing METABKT error handling case.
* * hash.c (hash_update): New function.Kaz Kylheku2014-01-247-0/+95
| | | | | | | | | | | | * hash.h (hash_update): Declared. * lib.c (update): New function. * lib.h (update): Declared. * eval.c (eval_init): Register hash_update and update as intrinsics. * txr.1: Documented.
* * eval.c (expand): Bugfix in expansion of dohash: neglectedKaz Kylheku2014-01-232-1/+8
| | | | to insert result form into the expanded output.
* Version 76txr-76Kaz Kylheku2014-01-238-92/+144
|
* * eval.c (expand_op): Takes sym argument to distinguish op and do.Kaz Kylheku2014-01-233-4/+38
| | | | | | | | The dwim operator is deleted when the symbol is do. (expand): Expand do_s form with expand_op, not only op_s. Pass down symbol. * txr.1: Document do operator.
* * eval.c (do_eval): Fix incorrect, recently introduced codeKaz Kylheku2014-01-232-10/+16
| | | | | rearrangement that gives precedence to operator lookup over function lookup.
* Bugfix: @(require ...) not expanding forms.Kaz Kylheku2014-01-234-10/+19
| | | | | | | | | | * eval.c (expand_forms): Static function becomes external. (expand_form): Remove case which handles do_s. * eval.h (expand_forms): Declared. * parser.y (elem): Expand both do_s and require_s forms by using expand_forms.
* * lib.c (conses, lazy_conses, func_set_env): New functions.Kaz Kylheku2014-01-235-1/+102
| | | | | | | | | | | (lazy_conses_func): New static function. * lib.h (conses, lazy_conses, func_set_env): Declared. * eval.c (eval_init): conses, lazy_conses and func_set_env registered as intrinsics. * txr.1: Documented.
* Changes to the list collection mechanism to improveKaz Kylheku2014-01-228-140/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the extension of list operations over vectors and strings. * eval.c (do_eval_args, bindings_helper, op_each, subst_vars, supplement_op_syms, mapcarv, mappendv): Switch from list_collect_* macros to functions. * lib.c (copy_list): Switch from list_collect* macros to functions. Use list_collect_nconc for the final terminator. Doing a copy there with list_collect_append was actually wasteful, and now that list_collect_append calls copy_list in places, it triggered runaway recursion. (make_like): Bugfix: list_vector was used instead of vector_list. (to_seq, list_collect, list_collect_nconc, list_collect_append): New functions. (append2, appendv, nappend2, sub_list, replace_list, ldiff, remq, remql, remqual, remove_if, keep_if, proper_plist_to_alist, improper_plist_to_alist, split_str, split_str_set, tok_str, list_str, chain, andf, orf, lis_vector, mapcar, mapcon, mappend, merge, set_diff, env): Switch from list_collect* macros to functions. (replace_str, replace_vec): Allow single item replacement sequence. * lib.h (to_seq): Declared. (list_collect, list_collect_nconc, list_collect_append): Macros removed, replaced by function declarations of the same name. These functions return the new ptail since they cannot assign to it, requiring all uses to be updated to do the assignment of the returned value. (list_collect_decl): Use val rather than obj_t *. * match.c (vars_to_bindings, h_coll, subst_vars, extract_vars, extract_bindings, do_output_line, do_output, v_gather, v_collect): Switch from list_collect* macros to functions. * parser.y (o_elems_transform): Likewise. * regex.c (dv_compile_regex, regsub): Likewise. * txr.c (txr_main): Likewise.
* Support function versions of if, and, or so that partialKaz Kylheku2014-01-223-13/+91
| | | | | | | | | | | | | | evaluation like (op or @1 42) or (op if (eq @1 foo) bar xyzzy) is possible. * eval.c (do_eval): Change precedence between operator and function lookup to favor operators. This is important since there are several operators now which are also functions. (if_fun, or_fun, and_fun): New static functions. (eval_init): New functions registered as intrinsics. * txr.1: Documented that if, and, or exist as both functions and operators.
* * eval.c (eval_instrinsic): Changed to external linkage.Kaz Kylheku2014-01-225-16/+55
| | | | | | | | | * eval.h (eval_intrinsic): Declared. * txr.c (spec_file): Global variable removed. (txr_main): Support for -e and -p options. Minor code cleanup. * txr.1: Documented new options.
* * eval.c (mapcarv, mappendv): Convert output to type of leftmostKaz Kylheku2014-01-215-12/+69
| | | | | | | | | | | | | input sequence. * lib.c (make_like): New function. (reverse, remq, remql, remqual, remove_if, keep_if, mapcar, mapcon, mappend, set_diff): Convert output list to type of leftmost input sequence. * lib.h (make_like): Declared. * txr.1: Documented.
* * lib.c (car, cdr, ldiff): Extend to handle vectors and strings.Kaz Kylheku2014-01-213-3/+75
| | | | | | | Thereby, numerous previously list-only operations in TXR Lisp now magically handle strings and vectors. * txr.1: Documented.
* * lib.c (broken_down_time_list): New static function.Kaz Kylheku2014-01-205-0/+75
| | | | | | | | | | | (time_fields_local, time_fields_utc): New functions. * lib.h (time_fields_local, time_fields_utc): Declared. * eval.c (eval_init): Intern time_fields_local and time_fields_utc as intrinsic functions. * txr.1: Documented.
* * hash.c (group_by): New function.Kaz Kylheku2014-01-165-0/+72
| | | | | | | | * hash.h (group_by): Declared. * eval.c (eval_init): group_by registered as group-by intrinsic. * txr.1: Documented.
* Version 75.txr-75Kaz Kylheku2014-01-166-110/+159
|
* * lib.c (obj_print, obj_pprint): Convert the internal representationKaz Kylheku2014-01-152-0/+18
| | | | | of @sym and @(expr ...) syntax back to these notations instead of leaving them as (sys:var sym) and (sys:expr expr ...).
* * arith.c: Revised error messages to refer to Lisp names insteadKaz Kylheku2014-01-154-26/+28
| | | | | | | | | | of C names of functions, or otherwise clarified them. * filter.c: Likewise. * lib.c: Likewise. * match.c: Likewise.
* * eval.c (append_each_s, append_each_star_s): New symbol variables.Kaz Kylheku2014-01-153-15/+45
| | | | | | | | (op_each, expand): Support append-each and append-each*. (eval_init): Initialize new symbol variables, and register new operators. * txr.1: Document append-each and append-each*.
* * arith.c (atang2): New function.Kaz Kylheku2014-01-154-2/+12
| | | | | | | | * eval.c (eval_init): Register as atang2 as a atan2 intrinsic. * lib.h (atang2): Declared. * txr.1: Documented atan2.
* * txr.1: Wrote missing documentation for throw, throwf and error.Kaz Kylheku2014-01-142-0/+27
|
* Clarifications about unget-char and unget-byte.Kaz Kylheku2014-01-141-0/+15
|
* * stream.c (stdio_seek): After a successful seek, discard the characterKaz Kylheku2014-01-142-0/+6
| | | | that may have been put back with unget_char.
* * eval.c (bind_args): Implemented default values for optionalKaz Kylheku2014-01-143-3/+29
| | | | | | | arguments. (op_defun): Permit the syntax. * txr.1: Documented.
* Support for pushing back bytes and characters into streams.Kaz Kylheku2014-01-136-1/+185
| | | | | | | | | | | | | | | | | | | | | | | | * stream.c (null_ops, stdio_ops, tail_ops, pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops, cat_stream_ops): Structure definition updated with new initializers for two new virtuals. (stdio_handle): New member, unget_c. (snarf_line, stdio_get_char): Handle pushed-back character in h->unget_c. (stdio_unget_char, stdio_unget_byte, string_in_unget_char, byte_in_unget_byte): New static functions. (make_stdio_stream_common): Initialize unget_c member. (unget_char, unget_byte): New functions. * stream.h (struct strm_ops): New virtuals: unget_char and unget_byte. (unget_char, unget_byte): New functions declared. * syslog.c (syslog_strm_ops): Two new initializers. * eval.c (eval_init): Registered unget_char and unget_byte as intrinsics. * txr.1: Documented.
* * stream.c (put_byte): Bugfix: was checking whether the put_charKaz Kylheku2014-01-132-1/+6
| | | | virtual function is not null, rather than put_byte.
* Bugfix in regex char ranges affecting ranges whose upper endKaz Kylheku2014-01-132-4/+21
| | | | | | | | | | | | | corresponds to the high bit of a bitmap cell: for instance the character \x7f when the cell size is 32 bits. * regex.c (BITCELL_ALL1): Unused macro removed. (BITCELL_BIT): New macro to replace occurrences of a repeated expression. (CHAR_SET_INDEX, CHAR_SET_BIT): Updated to use BITCELL_BIT. (L0_fill_range): Bugfix: the mask1 calculation was producing all-zero in the condition bt1 == BITCELL_BIT; it should produce an all-ones mask.
* Version 74txr-74Kaz Kylheku2014-01-137-59/+98
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES, txr.vim, dep.mk: Updated.
* * debug.h (debug_check): Fix broken build when debugger is disabled:Kaz Kylheku2014-01-132-1/+7
| | | | the debug-disabled stub function needs six arguments.
* Mac OSX Upkeep.Kaz Kylheku2014-01-132-9/+23
| | | | | | | | | * configure: (need_svid_source, need_bsd_source): Variables removed. (need_darwin_c_source): New variable. Detect Apple environment and add -D_DARWIN_C_SOURCE, which is needed to reveal some functions in headers. * signal.c (sig_init): Wrap #ifdefs around SIGPOLL; it is not defined on Darwin.
* Some bignum-related optimizationsKaz Kylheku2014-01-122-0/+23
| | | | | * arith.c (plus, minus, mul, trunc): Optimize cases where bignum is opposite 1 or 0.
* * arith.c (rising_product): New static function.Kaz Kylheku2014-01-115-0/+83
| | | | | | | | | | (n_choose_k, n_perm_k): New functions. * arith.h (n_choose_k, n_perm_k): Declared. * eval.c (eval_init): New functions interned. * txr.1: Documented.
* * arith.c (to_float): Print function name as ~a rather than ~s,Kaz Kylheku2014-01-115-1/+85
| | | | | | | | | | | | so it doesn't have quotes around it. (cum_norm_dist): New function. * arith.h (cum_norm_dist): Declared. * eval.c: Include arith.h. (eval_init): Register cum_norm_dist as intrinsic. * txr.1: Documented cum-norm-dist.
* * configure: Detect platforms which don't reveal declarationsKaz Kylheku2014-01-106-18/+38
| | | | | | | | | | | | | | in C headers which are extensions to standard C, like popen or fileno, in response to standard feature selection macros like -D_POSIX_SOURCE. MinGW and Cygwin are offenders. These platforms hide the declarations when gcc is in -ansi mode, by testing for __STRICT_ANSI__. Turns out, however, that -U__STRICT_ANSI__ on the gcc command line strips this away, causing the declarations to be revealed. * lib.c, parser.l, stream.c, utf8.c: Removed the declarations which compensated for the above problem. Yippee! Fuck you, stupid Cygwin troglodytes, and the MinGW horse you rode in on. http://cygwin.com/ml/cygwin/2011-10/msg00131.html
* * eval.c (eval_init): Renaming lisp-parse to read; lisp-parseKaz Kylheku2014-01-104-10/+24
| | | | | | | | is retained as an obsolescent synonym. All arguments become optional. * parser.l (lisp_parse): Handle nil source. * txr.1: Updated.