summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Cycle detection in sys:cp-origin.Kaz Kylheku2016-10-191-9/+13
| | | | | | | | | | | | | | | Tree-walking code in the place expander runs into trouble if the expression contains cycles. Test case: (defparm a '(#1=(a . #1#))). * share/txr/stdlib/place.tl (sys:cp-origin): Take list of symbols as a single argument instead of trailing arguments. Support an optional argument that gives serves as a cycle-detecting stack. Bail if a cycle is detected. (call-udpate-expander, call-clobber-expander, call-delete-expander): Update sys:cp-origin calls to follow interface change.
* reduce-left bugfix: bad init val with key-func.Kaz Kylheku2016-10-181-1/+1
| | | | | * lib.c (reduce_left): init value pulled from list itself must be passed through the key function.
* Adding notation for cycles and shared structure.Kaz Kylheku2016-10-184-5/+213
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit implements the parse-side support for handling a notation that exists in ANSI Common Lisp for specifying objects with cycles and shared substructure. * parser.h (struct parser): New members, circ_ref_hash and circ_count. (circref_s, parser_resolve_circ, parser_circ_def, parser_circ_ref): Declared. * parser.c (circref_s): New symbol variable. (parser_mark): Visit the new circ_ref_hash member of the parser structure. (parser_common_init): Initialize new members circ_ref_hash and circ_count of parser structure. (patch_ref, circ_backpatch): New static functions. (parser_resolve_circ, parser_circ_def, parser_circ_ref): New functions. (circref): New static function. (parse_init): Initialize circref_s as sys:circref symbol. Register sys:circref function. * parser.l (grammar): Scan #<num>= and #<num># notation as tokens, extracting their numeric value. * parser.y (HASH_N_EQUALS, HASH_N_HASH): New token types. (i_expr, n_expr): Adding phrases for hash-equalsign and hash-hash syntax. (yybadtoken): Handle new token types in switch. (parse_once): Call parser_resolve_circ after parsing to rewrite any remaining #<num># references in the structure to the objects they denote. (parse): Reset new struct parse members to initial state. Call parser_resolve_circ after parsing to rewrite any remaining #<num># references.
* Detect cycles in rlcp_tree.Kaz Kylheku2016-10-183-3/+34
| | | | | | | | | | | | | This will be required when the parser becomes capable of creating object graphs with cycles. * parser.c (parser_callgraph_circ_check): New function. * parser.h (struct circ_stack): New struct. (parser_callgraph_circ_check): Declared. * parser.y (rlcp_tree_rec): New static function. (rlcp_tree): Reduced to wrapper for rlcp_tree_rec.
* New function to access slot list of struct type.Kaz Kylheku2016-10-182-0/+7
| | | | | | * struct.c (slots): New function. * struct.h (slots): Declared.
* Provide functions to alter range objects.Kaz Kylheku2016-10-172-0/+16
| | | | | | | | | | Ranges continue to be immutable; but a backdoor is needed for upcoming support for circular notation. * lib.c (set_from, set_to): New functions. * lib.h (set_from, set_to): Declared.
* Bugfix: unable to assign to x.y.z place.Kaz Kylheku2016-10-151-4/+1
| | | | | | | | | | | | | | | | | | | This regression was caused by commit 957f80f "Bugfix: issue with expansion of place macros" on Sep 7, 2016. The commit itself is sound, but exposes a hidden problem in nearby code. * share/txr/stdlib/place.tl (sys:pl-expand): The conditions for terminating the loop and returning the expansion are too weak, due to the inclusion of an incorrect test. We must not bail when the expansion of a compound form is a compound form with the same symbol. This is because some macros behave that way, such as, oh: qref! The expansion of (qref a b c) is (qref (slot a 'b) 'c): another qref form. To fully expand, we must keep iterating until the returned form is eq to the input form. The original macroexpand (which was replaced by macroexpand-1 in 957f80f) hid this problem because macroexpand doesn't use this broken termination test.
* Support nil env in env-fbind and env-vbind.Kaz Kylheku2016-10-152-10/+30
| | | | | | | | * eval.c (env_fbind, env_vbind): Allow env to be nil, indicating that the binding is to take place in the global environment. * txr.1: Documented.
* Version 154.txr-154Kaz Kylheku2016-10-156-662/+710
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Fix wrong memset in new args handling function.Kaz Kylheku2016-10-151-1/+1
| | | | | | | * args.c (args_cat_zap_from): Clear the area that was copied, starting at the index offset, rather than from argument zero. This bug could result in spurious retention due to failing to zap some arguments.
* doc: defsymacro: runaway recursion.Kaz Kylheku2016-10-141-1/+1
| | | | | * txr.1: If a symbol macro expands to itself indirectly, the result isn't a loop but runaway recursion.
* doc: defsymacro rewording.Kaz Kylheku2016-10-141-8/+12
| | | | | * txr.1: Updating awkward wording, beginning with clumsy two-clause sentence joined by a colon.
* doc: small fix under format ~s directive.Kaz Kylheku2016-10-141-1/+3
| | | | | * txr.1: typeset print function name with .code so it turns to typewriter font and hyperlink.
* Adding family slot to socket addresses.Kaz Kylheku2016-10-133-9/+37
| | | | | | | | | | | | | | | A static slot indicating the address family simplifies code which wants to map a socket address to its family. * lisplib.c (sock_instantiate): Call sock_load_init before loading socket.tl rather than after, because socket.tl now references variables defined inside sock_load_init. * share/txr/stdlib/socket.tl (sockaddr, sockaddr-in, sockaddr-in6, sockaddr-un): New static slot, family. * txr.1: Documented family slots.
* Bugfix: sub and length on abstract sequences.Kaz Kylheku2016-10-133-1/+45
| | | | | | | | | | * lib.c (length_proper_list): New static function. (length): Use length_proper_list for objects. (sub): Call nullify on COBJ object before passing to sub_list. * tests/012/aseq.tl, tests/012/aseq.expected: New files.
* Overhaul where funtion.Kaz Kylheku2016-10-131-14/+43
| | | | | * lib.c (where): Implement faster ref-based access for vectors and strings. Support abstract sequence structs.
* doc: clarification under nullify method.Kaz Kylheku2016-10-131-1/+2
| | | | | | * txr.1: the nullify method need not return the object itself in the non-empty case; it may also return a sequence.
* Let some sequence functions work on structs.Kaz Kylheku2016-10-131-28/+32
| | | | | | * lib.c (in, sub, ref, search, rsearch, sel): These functions now accept struct objects that have the nullify, car and cdr methods.
* find-max and find-min support hashes.Kaz Kylheku2016-10-122-15/+76
| | | | | | | * lib.c (find_max): Restructured to implement separately for vectors and lists. Support hash tables. * txr.1: Document find-min and find-max for hashes.
* New accessor: hash-userdata.Kaz Kylheku2016-10-123-9/+51
| | | | | | | | | | | | | | The get-hash-userdata function is now deprecated in favor of hash-userdata, which is an accessor. * hash.c (hash_init): Register hash-userdata as a synonym for the same function as get-hash-userdata. * share/txr/stdlib/place.tl (hash-userdata): New defplace. * txr.1: Document new accessor, marking get-hash-userdata as a deprecated synonym. Replace references to get-hash-userdata with references to hash-userdata.
* listener: put each result into linenoise.Kaz Kylheku2016-10-121-0/+1
| | | | | | | | * parser.c (repl): After each successful command that produces a value, not only print the value but also call lino_set_result to install its string representation into the linenoise object, so it is available for insertion via Ctrl-X Ctrl-P.
* linenoise: Ctrl-X Ctrl-P edits result of command.Kaz Kylheku2016-10-122-0/+21
| | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New member, result. (edit): Ctrl-P or p in extended mode cause result string to be inserted into the buffer. (lino_copy): Ensure result string in copy is null. (lino_cleanup): Free result string and set to null. (lino_set_result): New function. * linenoise/linenoise.h (lino_set_result): Declared.
* Include user data in hash read syntax.Kaz Kylheku2016-10-122-8/+40
| | | | | | | | | | | | | * hash.c (userdata_k): New keyword symbol variable. (hash_print_op): Print the userdata together with the hash flags as :userdata obj. (hashv): Parse out :userdata obj syntax from the argument list. This takes care of supporting it in the read notation and in the hash function. (hash_init): Initialize userdata_k. * txr.1: Documenting :userdata in hash read notation and hash function.
* Support gmtoff and zone in time struct.Kaz Kylheku2016-10-122-4/+52
| | | | | | | | | | | | | | * lib.c (gmtoff_s, zone_s): New symbol variables. (tm_to_time_struct): Copy tm_gmtoff and tm_zone into Lisp struct from struct tm, if the platform has these. (time_fields_to_tm): Zero/null-out the tm_gmtoff and tm_zone fields of the target structure, if the platform has them. (time_init): Intern the gmtoff and zone symbols, initializing the gmtoff_s and zone_s variables. Add the gmtoff and zone slots to the time struct. * txr.1: Documented new slots.
* doc: typo under html-encode*Kaz Kylheku2016-10-121-1/+1
| | | | * txr.1: necessary -> necessarily
* linenoise: bug in resubmit historic line when dupe.Kaz Kylheku2016-10-121-2/+4
| | | | | | | | | | | When Ctrl-X Enter is used to resubmit a line from the history, and it is a duplicate, it is not entered into the history. The position then doesn't advance to the next historic line. * linenoise/linenoise.c (lino_hist_add): Do add the line even if it is duplicate if the last submitted line was from the middle of the history.
* New function regex-from-trie.Kaz Kylheku2016-10-122-0/+78
| | | | | | | * filter.c (regex_from_trie): New static function. (filter_init): Register regex-from-trie intrinsic. * txr.1: Documented regex-from-trie.
* Support n-ary and and or operators in regex.Kaz Kylheku2016-10-101-1/+63
| | | | | | | | | | | Since much regex code assumes these are binary, the easiest and briefest approach is to implement a code transformation pass which rewrites n-ary forms into binary. * regex.c (reg_nary_unfold, reg_nary_to_bin): New functions. (regex_compile): Put raw sexp through reg_nary_to_bin to expand the nary syntax.
* Simplify some regex tree walking code.Kaz Kylheku2016-10-101-18/+10
| | | | | | | | | | * regex.c (reg_expand_nongreedy, reg_compile_csets): Generalize the compound_s case slightly by referring to sym rather than hard-coded compound_s. Then handle most of the regex operators under this same case. Their semantics are not relevant to the expansions being performed in these functions: all their arguments are regexes to be recursed over.
* Support curried args in method and meth.Kaz Kylheku2016-10-096-18/+115
| | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (meth): Take trailing arguments and pass them down to method, which now accepts them. * struct.c (struct_init): Register method intrinsic to the function method_args instead of the method function. (method_args_fun): New static function. (method_args): New function. Behaves like method function if args is empty, otherwise creates a function by means of method_args_fun. * struct.h (method_args_fun): Declared. * tests/012/oop.tl: New test case. * tests/012/oop.expected: Updated. * txr.1: Documented new features in method and meth, revising the documentation in the process.
* Support curried arguments in umethod and umeth.Kaz Kylheku2016-10-096-14/+71
| | | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (umeth): accept variadic arguments. Evaluate them using the dwim brackets and pass to umethod. The (fun umethod) trick is used to refer to the umethod in the function namespace even if it is shadowed by a variable. * struct.c (struct_init): Update registration of umethod to reflect its new variadic argument signature. (umethod_args_fun): New static function. (umethod): Return a function based on umethod_fun, as before, if there are no variadic args. Otherwise, use umethod_args_fun which deals with them. * struct.h (umethod): Declaration updated. * tests/012/oop.tl: Modest testcase for umeth with curried argument. * tests/012/oop.expected: Updated. * txr.1: Updated documentation of umeth and umethod.
* New function: args_cat_zap_from.Kaz Kylheku2016-10-092-0/+11
| | | | | | * args.c (args_cat_zap): New function. * args.c (args_cat_zap): Declared.
* Bugfix: wrong memset size in args_cat_zap.Kaz Kylheku2016-10-091-4/+5
| | | | | | | | | | | | | | | * args.c (args_copy): Use from->arg and from->fill in calculating the memcpy size. It doesn't matter in this function because the to and from are the same; however, this may be the origin of the copy and paste error that led to args_cat_zap problem. (args_copy_zap): Similar change to args_copy: be consistent in using the from side expressions. (args_cat_zap): Bugfix: the total size of the to arguments was used to zap the from side. This writes zeros past the end of the from arguments. Fixing by calculating the size in one place and using the calculated size.
* Version 153.txr-153Kaz Kylheku2016-10-074-4/+19
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* gc issues in clear_struct and replace_struct.Kaz Kylheku2016-10-071-0/+3
| | | | | | | * struct.c (clear_struct, reset_struct): Inform the garbage collector that the structure has been mutate, using the mut macro. This is required for correctness because the structure may be a mature object receiving young generation values.
* Check for self-assignment in replace_struct.Kaz Kylheku2016-10-072-12/+27
| | | | | | | | | * struct.c (replace_struct): If target and source are the same object, just do nothing and return target. * txr.1: Document self-assignment and return value of replace-struct.
* doc: mistakes in introduction of do operator.Kaz Kylheku2016-10-071-3/+3
| | | | | | * txr.1: Where do is being introduced, fix a statement that about op, which should be about do. Plus fix verb agreement.
* nuke trailing newlines from exception messages.Kaz Kylheku2016-10-073-8/+8
| | | | | | | | | * signal.c (set_signal_handler, get_sign_handler): Eliminate newline in exception messages. * stream.c (unimpl, formatv): Likewise. * unwind.c (uw_block_abscond): Likewise.
* small bug in format: handle missing format char.Kaz Kylheku2016-10-071-0/+2
| | | | | | | | * stream.c (formatv): When the format string ends at the point where the format character is expected to occur, do not emit an error about #\nul being an unknown format directive character; emit an error that the character is missing.
* bug: heap backpointer assignment in static-slot-ensure.Kaz Kylheku2016-10-071-1/+1
| | | | | | | | * struct.c (static_slot_ens_rec): Neglected use of set macro to store newval in freshly allocated slot, which means we corrupt garbage collection if this causes an old generation objet to point to a new generation object.
* bug: wrong way assert in static slot gc marking.Kaz Kylheku2016-10-071-1/+1
| | | | | | * struct.c (struct_type_mark): We must assert that sl->store is nil if we are not marking it, not that it is non-nil.
* Version 152.txr-152Kaz Kylheku2016-10-046-458/+498
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: ranges are immutable.Kaz Kylheku2016-10-041-2/+5
| | | | | * txr.1: document that ranges are immutable and expand the surrounding wording a bit.
* doc: small change under defstruct.Kaz Kylheku2016-10-041-1/+1
| | | | | * txr.1: describe slot specifier as (name init-form) rather than (symbol init-form).
* length and empty functions support ranges.Kaz Kylheku2016-10-042-11/+64
| | | | | | * lib.c (length, empty): Handle RNG in switch. * txr.1: Documented.
* New awk clauses :set and :set-file.Kaz Kylheku2016-10-042-3/+22
| | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-expander): Recognize :set and :set-file cases. * txr.1: Documented :set and :set-file, replacing some :begin uses with :set in the examples.
* New function rra.Kaz Kylheku2016-10-033-0/+113
| | | | | | | | | * regex.c (range_regex_all, regex_range_all): New functions. (regex_init): Register rra intrinsic function. * regex.c (range_regex_all, regex_range_all): Declared. * txr.1: Documented rra.
* Coding convention fix in plus function.Kaz Kylheku2016-10-031-3/+1
| | | | | * arith.c (plus): Eliminate compound statement braces around case that consists of one return statement.
* New rr function.Kaz Kylheku2016-10-033-5/+62
| | | | | | | | | | * regex.c (regex_range_search): New function. (regex_init): Register regex_range_search as rr intrinsic. * regex.h (regex_range_search): Declared. * txr.1: Documented rr, and added reference to it in description of regex-range.
* search-regex improvement: negative start and more.Kaz Kylheku2016-10-032-48/+110
| | | | | | | | | | | | * regex.c (search_regex): Handle negative starting positions according to the convention elsewhere and fail excessively negative ones. Consistently fail on starting positions exceeding the length of the string. Handle zero length matches by reporting them against the start position or position one past the last character, based on the value of from-end. * txr.1: search-regex documentation updated.