summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* * eval.c (eval_init): Register sort-group.Kaz Kylheku2014-11-215-1/+53
| | | | | | | | * lib.c (sort_group): New function. * lib.h (sort_group): Declared. * txr.1: Documented.
* * lib.c (partition_star_func): Bugfix: doing rplaca(env, seq)Kaz Kylheku2014-11-212-8/+14
| | | | | | too early, before the loop which adjusts its value. Restructuring this slightly to avoid duplicated code, by moving the !first check later.
* * lib.c (partition_by_func): Rename one local variable for clarity.Kaz Kylheku2014-11-212-9/+14
| | | | | Remove unessential variable last, and move the next variable into loop scope.
* * arith.c (wrap_star, wrap): New functions.Kaz Kylheku2014-11-205-0/+86
| | | | | | | | * 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-205-0/+84
| | | | | | | | * eval.c (eval_init): Register new functions as intrinsics. * lib.h (succ, ssucc, sssucc, pred, ppred, pppred): Declared. * txr.1: Documented.
* * lib.c (where): Argument order reversed, with compat support.Kaz Kylheku2014-11-204-3/+21
| | | | | | * lib.h (where): Declaration updated. * txr.1: Documented.
* * lib.c (sel): Accept a function in place of the index list.Kaz Kylheku2014-11-203-2/+23
| | | | * txr.1: Documented.
* * txr.1: Random fixes.Kaz Kylheku2014-11-171-3/+3
|
* * lib.c (split_str): If the separator string is empty,Kaz Kylheku2014-11-174-2/+67
| | | | | | | | | | then unless opt_compat is 100 or less, provide a more consistent behavior, rather than splitting the string into characters. This latter behavior was never documented. * txr.1: Documented. * dep.mk: Updated.
* * lib.c (max2, min2): Use the less comparison functionKaz Kylheku2014-11-154-10/+23
| | | | | | | | | for generic semantics. * lib.h (max2, min2): Parameter names changed to avoid suggesting that the operands are numbers. * txr.1: Documentation for min and max updated.
* * eval.c (opip_s, oand_s, chain_s, chand_s): New global variables.Kaz Kylheku2014-11-105-186/+332
| | | | | | | | | | | | (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.
* * lib.c (sub, ref, refset, replace, update, search_list):Kaz Kylheku2014-11-062-6/+13
| | | | | | Fix cut and paste problem: type_mismatch argument expression referring to the C function cons rather than the intended object seq.
* * eval.c (eval_init): Register chand intrinsic.Kaz Kylheku2014-11-065-1/+54
| | | | | | | | | * 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-064-18/+51
| | | | | | | | | * 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.
* * lib.c (iff): Bugfix: forgotten handling of defaultKaz Kylheku2014-11-053-9/+11
| | | | | | | | argument, resulting in : symbol being called as a function. * txr.1: Removing description of situation when the then-function argument of iff or iffi is specified as nil. This is deprecated behavior which can be obtained by using the false function.
* New macros tb and tc.Kaz Kylheku2014-10-313-0/+111
| | | | | | | * eval.c (me_tb, me_tc): New static functions. (eval_init): Registered tb and tc macros. * txr.1: Documented tb and tc.
* * lib.c (chk_grow_vec): New function.Kaz Kylheku2014-10-304-13/+46
| | | | | | | | | (string_extend): Use chk_grow_vec. (vec_set_length): Avoid subtractions for comparing numbers. * lib.h (chk_grow_vec): Declared. * stream.c (snarf_line, string_out_put_string): Use chk_grow_vec.
* Implementing finalization hooks.Kaz Kylheku2014-10-304-51/+341
| | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (struct fin_reg): New struct type. (final_list, final_tail, mark_makefresh): New static variables. (mark_obj): Under generational GC, if make_makefresh is in effect, set the generation to -1 on all marked objects. (sweep_one): In an EXTRA_DEBUGGING build, call breakpt if the object being swept is the one in break_obj. Under generational GC, place reachable objects that are in generation -1 the freshobj nursery and assign them to generation 0, rather than sticking them into the mature generation 1. (sweep): Under generational gc, reset the freshobj_idx variable here, so that sweep_one has an empty nursery in which to place the generation -1 objects. (prepare_finals, call_finals): New static functions. (gc): Call prepare_finals before sweep, and call call_finals just before re-enabling GC and returning. Do not reset freshobj_idx to zero; this was done in sweep, which may have added entries into it. (gc_finalize): New function. (gc_late_init): Register gc_finalize as intrinsic function finalize. * txr.1: Documented finalize. * HACKING: Documented finalization, described the additional meaning of the -1 generation, and added a section on debugging with break_obj and breakpt.
* * gc.h (break_obj): Missing extern added on declaration.Kaz Kylheku2014-10-302-1/+6
| | | | This broke C++ compilation with -DEXTRA_DEBUGGING turned on.
* Vim syntax coloring for standalone TXR Lisp (*.tl) files.Kaz Kylheku2014-10-294-54/+336
| | | | | | | | | * genvim.txr (generate): New pattern function, contains generation logic so we can do it twice. * txr.vim: Regenerated. * tl.vim: New file.
* * lib.c (type_check): Function moved to header file inline.Kaz Kylheku2014-10-263-5/+17
| | | | | | | (throw_mismatch): New function. * lib.h (throw_mismatch): Declared. (type_mismatch): Declaration turned into inline function.
* * hash.c (hash_begin): Use coerce macro instead of raw C cast.Kaz Kylheku2014-10-253-4/+10
| | | | | | Use cobj_handle so hash argument is validated. * parser.l (YY_INPUT): Use convert macro instead of raw C cast.
* GNU Flex's libfl library provides nothing. Let us not refer to it. ItKaz Kylheku2014-10-244-7/+23
| | | | | | | | | | | | only causes build issues on some systems where it is not provided in the standard location, or is not cross-compiled properly. * Makefile (LEXLIB): Reference to variable removed. * configure (lexlib): Variable removed. (LEXLIB): config.make variable not generated. * parser.l (yywrap): Provide this trivial function as inline.
* * Makefile: Removing trailing spaces.Kaz Kylheku2014-10-2423-194/+210
| | | | | | | | | | (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-222-1/+6
| | | | repeat; it must have one optional argument.
* Version 100.txr-100Kaz Kylheku2014-10-225-4/+79
|
* Ensure that a hash reorganization doesn't take placeKaz Kylheku2014-10-225-7/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | during a traversal, which could cause items to be visited twice or skipped. * gc.c (full_gc): Changed from static to exter (full_gc): Changed to internal linkage. * gc.h (full_gc): Declared. * hash.c (struct hash): New member, usecount. (struct hash_iter): New member, next. (reachable_iters): New static variable. (hash_mark): Reset the usecount of every reachable hash table. (hash_iter_mark): Add every reachable iterator to reachable_iters list. (make_hash, make_similar_hash, copy_hash): Initialize usecount. (gethash_c): Do not call hash_grow if usecount is nonzero. (hash_begin): Initialize next field of hash_iter to null. Increment use count on hash table. (hash_next): When traversal ends, release use count, and null out the hash table reference. (do_weak_tables): New static function. (do_iters): New static function. (hash_process_weak): Weak hash processing logic moved to do_weak_tables. Also calls do_iters. * txr.1: Describe hash table traversal, and the assurances and caveats about inserting and deleting items.
* * eval.c (interp_fun): If the function doesn't haveKaz Kylheku2014-10-212-5/+19
| | | | | 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-217-78/+117
| | | | | | | | | | | | | | * 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.
* * share/txr/stdlib/txr-case.txr: New file.Kaz Kylheku2014-10-217-8/+299
| | | | | | | | | | | | * txr.1: Document txr-if, txr-when and txr-case. * genvim.txr: Added new macro names. * tests/011/txr-case.expected: New file. * tests/011/txr-case.txr: New file. * txr.vim: Regenerated.
* Source file inclusion implemented: needed for macros.Kaz Kylheku2014-10-207-24/+119
| | | | | | | | | | | | | | | | | | | | | * match.c (include_s): New symbol variable. (v_load): Function extended to handle include semantics. (include): External wrapper function for doing inclusion via v_load. (syms_init): include_s initialized. * match.h (include_s): Declared. (include): Declared. * parser.y (check_for_include): New static function. (clauses_rev): Use check_for_include to replace @(include ..) directive. * txr.1: Documented include. * genvim.txr: Added include symbol. * txr.vim: Regenerated.
* * match.c (match_fun): Bugfix: replace incorrect plain returnKaz Kylheku2014-10-192-1/+11
| | | | | | | | | with debug_return. This causes a stray debug frame to be left on the environment stack which turns to garbage, leading to an invalid longjmp in another debug_return elsewhere which tries to use that frame. This was diagnosed by valgrind indicating accesses below the stack frame, and also by glibc "longjmp causes uninitialized stack frame" abort.
* * parser.l (lisp_parse): Bugfix: the error_stream argumentKaz Kylheku2014-10-193-4/+23
| | | | | | | | | must be checked to be a stream before we plant it in place of std_error, otherwise we will get a type exception thrown lower down, which leads to runaway recursion as TXR tries to print the error messages on std_error. * dep.mk: Regenerated.
* * parser.y (r_exprs): New grammar symbol. r_exprs usesKaz Kylheku2014-10-192-16/+56
| | | | | | | | | left-recursive rules to avoid filling the yacc stack, and returns the items in reverse order. The output of each r_exprs-generating rule consists of a list which gives the terminating atom, and then the list contents in reverse order. (n_exprs): Becomes wrapper for r_exprs which deals with the terminating atom, and reversed items.
* * parser.y: Allow TXR to support large programs, and efficiently so.Kaz Kylheku2014-10-182-5/+19
| | | | | | | | | | | (clauses_rev): New grammar symbol. Uses a left-recursive rule that does not consume an amount of parser stack proportional to the number of clauses, and sticks to efficient consing, which means that the list is built up in reverse. (clauses): Now just a wrapper rule for clauses_rev which nreverses its output. (clauses_opt): Retargetted to use clauses_rev instead of clauses, and reverse its output.
* Deal with situation when GC is disabled and the freshobj array runs outKaz Kylheku2014-10-182-3/+22
| | | | | | | | | | | | | | | | of room. This could happen when parsing a really large TXR program, since gc is disabled during parsing. Currently it asserts, which is not acceptable. * gc.c (make_obj): If after gc, the freshobj array has not been emptied (obviously because gc is disabled), do not assert. Rather, set the full_gc flag to request a full garbage collection when gc is re-enabled. Furthermore, only place newly allocated objects into freshobj if full_gc has not been set. Thus, if we exhaust the freshobj array while gc is off, the full_gc flag is set, and we discontinue use of that array. When gc is re-enabled, we will do a full gc pass. A full gc pass ignores freshobj array, so it doesn't matter that its use was discontinued.
* * match.c (mf_all): Drop data_lineno parameter. InitializeKaz Kylheku2014-10-182-26/+36
| | | | | | | | | | | the corresponding member based on whether or not data is nil. (do_match_line, mf_from_ml, match_filter, match_fun, extract): Do not pass starting line number argument to mf_all. This fixes a bug when the line number at @(eof) for an empty file comes out as zero. (mf_args, v_skip, v_fuzz, v_next, v_gather, v_collect, open_data_source, match_files): Use zero and one instead of num(0) and num(1).
* * match.c (v_eof): Bugfix: we are at EOF not only whenKaz Kylheku2014-10-172-1/+7
| | | | | the remaining data is nil but when it is (nil). This happens for interactive streams.
* * match.c (dest_bind): Remove the restriction of not allowingKaz Kylheku2014-10-173-2/+81
| | | | | | | | | | | @(expr ...) and @var on the left side of a bind. This is useful, and necessary for @(line @(lisp expr)) to work: matching computed line numbers and character positions. * txr.1: Document use of Lisp on left hand side of bind, that there is a restriction on the left hand side of a set, and that Lisp can be used in a line or chr directive for computed matches.
* * HACKING: New section Type Safety.Kaz Kylheku2014-10-173-35/+113
| | | | | | Table of contents regenerated with line numbers. * HACKING-toc.txr: New file.
* Converting cast expressions to macros that are retargettedKaz Kylheku2014-10-1722-411/+529
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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,
* Purge stray occurrences of "void *" from code base.Kaz Kylheku2014-10-1710-33/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (cobj_print_op): In the format call, cast the C pointer to val, since the ~p conversion now takes a val rather than void *. (cptr_equal_op, obj_print, obj_pprint): Remove cast to void *, since obj now already has the type that ~p expects. * lib.h (struct any): Use mem_t * instead of void *. * parser.h (yyscan_t): Repeat the definition from inside the Flex-generated lex.yy.c. (yylex_init, yylex_destroy, yyget_extra, yyset_extra): Re-declare using yyscan_t typedef in place of void *. * parser.l (yyget_column, yyerrprepf): Re-declare using yyscan_t. (grammar): Use yyg in place of yyscanner in calls to yyerrprepf. * parser.y (yylex, %lex-param): Use yyscan_t instead of void *. (parse): Use yyscan_t for local variable. * signal.c (stack): Change type from void * to mem_t *. * stream.c (vformat): Conversion specifier p extracts val instead of void *. (run): Use casts that only remove const, not all the way to void *. * txr.1: Documented p conversion specifier of format. * Makefile (OBJS-y): Initialize with := to make sure it is a simple variable, and not a macro. (SRCS): New variable, listing source files. (enforce): New rule for enforcing coding conventions. Currently checks for void * occurrences.
* * arith.c (gcd): Fix semantics. If either operand isKaz Kylheku2014-10-167-123/+201
| | | | | | | | | | | | | | | | 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.
* * arith.c (gcd, lognot): Bugfix: bignum resultsKaz Kylheku2014-10-162-2/+7
| | | | in fixnum range not normalized.
* * match.c (dest_bind): More detailed log message for variableKaz Kylheku2014-10-162-1/+7
| | | | mismatch.
* New @(line) and @(chr) directives.Kaz Kylheku2014-10-165-14/+143
| | | | | | | | | | | | | * match.c (line_s): New variable. (h_chr, v_line): New static functions. (syms_init): line_s initialized. (dir_tables_init): Register v_line and h_chr. * match.h (line_s): Declared. * txr.1: Document @(line) and @(chr) directives. * txr.vim: Regenerated.
* * match.c (subst_vars): Fix buggy rendering of TXR Lisp expressionsKaz Kylheku2014-10-153-5/+57
| | | | | | | | | | | | | | | | | that evaluate to lists. For instance `@(list)` renders to the string "nil", and `@(list 1 2)` renders as "(1 2)". The desired behavior is "" and "1 2", respectively. (do_output_line): In output directives, there is a similar problem. A @(list) in the middle of an output block turns to nil, and a @(list 1 2) renders in parentheses as (1 2). Furthermore, there is the additional problem that no filtering is applied to the interpolated value. These behaviors are subject to the compatibility option, since they change the externally visible behavior of TXR programs. * txr.1: Document that empty lists in @(output) variable substitutions turn into nothing. Document value of 100 for -C option, describing the above issue.
* More type safety, with help from C++ compiler.Kaz Kylheku2014-10-144-34/+61
| | | | | | | | | | | | | | | | | | | | | | | | | * parser.h (scanner_t): New typedef. Cleverly, we use yyguts_t as the basis for this, which pays off in a few places, getting rid of conversions. (parser_t): scanner member redeclared to scanner_t *. (yyerror, yyerr, yyerrof, end_of_regex, end_of_char): Declarations updated. * parser.l (yyerror, yyerrorf, num_esc): scanner argument becomes scanner_t * instead of void *. (yyscanner): Occurrences replaced by yyg: why should we refer to the type-unsafe void *yyscanner, when we know that in the middle of the yylex function we have the properly typed yyguts_t *yyg. (end_of_regex, end_of_char): Argument changes to scanner_t * and name strategically changes to yyg, eliminating the local variable and cast. * parser.y (sym_helper): scanner argument becomes scanner_t * instead of void *. (%parse-param}: void *scnr becomes scanner_t *scnr. (define-transform, yybadtoken): Use scanner_t * instead of void *. (parse): Since yylex_init takes a void **, we use it to initialize a local void *, and then assign it to the structure member.
* C++ upkeep.Kaz Kylheku2014-10-146-9/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR's support for compiling as C++ pays off: C++ compiler finds serious bugs introduced in August 2 ("Big switch to reentrant lexing and parsing"). The yyerror function was being misused; some of the calls reversed the scanner and parser arguments. Since one of the two parameters is void *, this reversal wasn't caught. * parser.l (yyerror): Fix first two arguments being reversed. (num_esc): Change previously correct call to yyerror to follow reversed arguments, so that it stays correct. * parser.y (%parse-param): Change order of these directives so that the scnr parameter is before the parser parameter. This causes the yacc-generated calls to yyerror to have the arguments in the correct order. It also has the effect of changing the signature of yyparse, reversing its parameters. (parse): Update call to yyparse to new argument order. * parser.h (yyparse): Declaration removed. (yyerror): Declaration updated. * regex.c (regex_kind_t): New enum typedef. (struct regex): Use regex_kind_t rather than an enum inside the struct, which has different scoping rules under C++. * txr.c (get_self_path): Fix signed/unsigned warning.
* * txr.1: Round of fixes.Kaz Kylheku2014-10-132-77/+144
|