summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Document previously undocumented command line options.Kaz Kylheku2015-08-242-0/+24
| | | | | | * txr.1: Documented --gc-debug, --vg-debug and --dv-regex. * txr.c (help): Cover above options.
* Compatibility <= 107 allows redefinition of builtins.Kaz Kylheku2015-08-242-1/+8
| | | | | | | | * eval.c (builtin_reject_test): Suppress the diagnostic against redefinition of built-in macros and operators if the compatibility is 107 or lower. The rejection appeared in 108. * txr.1: Document this compatibility behavior.
* Add maze generation to test suite.Kaz Kylheku2015-08-243-0/+154
| | | | | | | | | * Makefile (tst/tests/013/maze.out): Add TXR_ARGS. Disable gc-debugging for tests in new directory. * tests/013/maze.expected: New file. * tests/013/maze.tl: New file.
* New --yydebug option.Kaz Kylheku2015-08-243-0/+25
| | | | | | | | | | | * parser.y (have_yydebug): New global constant. (yydebug_onoff): New function. * parser.h (have_yydebug, yydebug_onof): Declared. (yydebug_onoff): New function. * txr.c (help): List --yydebug option. (txr_main): --yydebug option implemented.
* New function: shuffle.Kaz Kylheku2015-08-244-0/+66
| | | | | | | | * eval.c (eval_init): Register shuffle as intrinsic. * lib.c (shuffle): New function. * lib.h (shuffle): Declared.
* Regression: assignment to [hash x..y] not working.Kaz Kylheku2015-08-231-9/+7
| | | | | | | | | | In this case, x..y should just be treated as a cons cell key, not as a range. * lib.c (dwim_set): If range argument is a cons, only delegate to the replace function if the object isn't a hash. (dwim_del): Likewise.
* Remove unused args_limit.Kaz Kylheku2015-08-232-10/+0
| | | | | | * args.c (args_limit): Function removed. * args.h (args_limit): Declaration removed.
* Use of new args for function calls in interpreter.Kaz Kylheku2015-08-238-38/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * args.c (args_copy_to_list): New function. * args.h (ARGS_MIN): New preprocessor symbol. (args_add_list): New inline function. (args_copy_to_list): Declared. * debug.c (debug): Args in debug frame are now struct args *. Pull them out nondestructively for printing using args_copy_to_list. * eval.c (do_eval_args): Fill struct args argument list rather than returning evaluated list. Dot position evaluation is handled by installing the dot position value as args->list. (do_eval): Allocate args of at least ARGS_MAX for the call to do_eval_args. Then use generic_funcall to invoke the function rather than apply. (eval_args_lisp1): Modified similarly to do_eval_args. (eval_lisp1): New static function. (expand_macro): Construct struct args argument list for the sake of debug_frame. (op_dwim): Allocate args which are filled by eval_args_lisp1, and applied to the function/object with generic_funcall. The object expression is separately evaluated with eval_lisp1. * match.c (h_fun, v_fun): Construct struct args arglist for the sake of debug_frame call. * unwind.c (uw_push_debug): args argument becomes struct args *. * unwind.h (struct uw_debug): args member becomes struct args *. (uw_push_debug): Declaration updated. * txr.1: Update documentation about dot position argument in function calls. (list . a) now works, which previously didn't.
* Large scale conversion to new way of handling arguments.Kaz Kylheku2015-08-2315-574/+775
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Function arguments are now allocated on the stack using alloca, in conjunction with the struct alloc header structure. The generic_funcall and apply functions are refactored for this, as are most functions that take variadic arguments. * args.c (args_add_list, args_cons_list): Functions removed. (args_normalize, args_normalize_fill): New functions. (args_get_checked): Draw arguments from list when array runs out. (args_copy, args_copy_zap): New functions. * args.h (ARGS_MAX): Reduced to 32. (ARGS_MIN): New preprocessor symbol. (args_init): Call args_init_list. (args_add2, args_add3, args_add4): New inline functions. (args_more): Take into account list, which may hold additional arguments. (args_two_more): New inline function. (args_normalize, args_normalize_fill): Declared. (args_get_list): Normalize all arguments into one list and return it. (args_get_rest, args_at, args_atz): New inline functions. (args_get): Draw arguments from list when array runs out. (args_clear): New inline function. * arith.c (maskv): Convert to new args. * eval.c (APPLY_ARGS): Preprocessor symbol removed. (bind_args): Converted to accept struct args. (apply): Function reduced down to trivial adapter which converts a list of arguments to args, and calls the new generic_funcall. (applyv): New static function: struct args wrapper around apply_intrinsic. (iapply): Converted to struct args. (call): Static function removed. The call intrinsic function binding now goes directly to generic_funcall. (list_star_intrinsic, interp_fun): Converted to struct args. (op_catch): Adjustments for bind_args, which requires a struct args arglist. (me_op): Must use the new minl and maxl, since minv and maxv don't take lists any more. (mapcarv, mappendv, lazy_mapcarv, lazy_mappendv, mapdov, weavev, or_fun, and_fun, tf, nilf, do_retf, do_apf, do_ipf, callf, do_mapf, mapf): Converted. (mapcarl): New function, like the old mapcarv. (eval_init): call_f initialized from generic_funcall rather than call. apply registered to applyv rather than apply_intrinsic. Registrations for zip, hash_from_pairs, vec, alist-remove, alist-nremove, and throw similarly updated to new or renamed functions. * eval.h (interp_fun, mapcarv): Declarations updated. (mapcarl): Declard. * hash.c (hashv): Converted to struct args. (hashl): New function. (hash_construct): Use hashl, not hashv. (hash_from_pairs, hash_list, group_by): Converted. * hash.h (hashv, hash_construct, hash_from_pairs, hash_list, group_by): Declarations updated. (hashl): Declared. * lib.c (appendv, nconcv, lazy_appendv): Converted to struct args. (lazy_appendl): New function. (multi): Converted. (listv): New function. (nary_op, plusv, mulv, logandv, logiorv, gtv, ltv, gev, lev, numeqv, numneqv, maxv, minv): Converted. (maxl, minl): New functions, like old maxv and minv. (exptv, gcdv, lcmv, lessv, greaterv, lequalv, gequalv): Converted. (func_f0v, func_f1v, func_f2v, func_f3v, func_f4v): Converted. (func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted. (func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted. (func_n1ov, func_n2ov, func_n3ov): Converted. (generic_funcall): Converted to take struct args. (funcall, funcall1, funcall2, funcall4): Pass stack-allocated struct args as trailing arguments to variadic functions, and to generic_funcall. (do_curry_12_1_v): New struct-args-based static function, needed to implement curry_12_1_v now. (curry_12_1_v): Converted. (transposev): New function based on previous tranpose. (transpose): Now a wrapper for transposev. (do_chain, chainv, do_chand, chandv, do_juxt, juxtv, do_and, andv, do_or, orv, do_not, do_iff): Converted. (vectorv): New function. Implementation basis for vec intrinsic function. (alist_removev, alist_nremovev): New functions. (multi_sort): Switch from mapcarv to mapcarl. (unique): Converted. (uniq): Allocate struct args for calling unique. (obj_init): list_f function now based on new listv, rather than identity. * list.h (varg): New typedef. (struct func): All variadic function pointers converted to use struct args. (appendv, nconcv, lazy_appendv, multi, nary_op, plusv, minusv, mulv, gtv, ltv, gev, lev, numeqv, numneqv, maxv, minv, exptv, gcdv, lcmv, logadnv, logiorv, maskv, lessv, greaterv, lequalv, gequalv, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n1ov, func_n2ov, func_n3ov, generic_funcall, chainv, chandv, juxtv, adnv, orv, unique): Declarations updated. (lazy_appendl, listv, maxl, minl, transposev, vectorv, alist_removev, alist_nremovev): Declared. * stream.c (make_catenated_stream_v): New function. (aformat): Renamed to formatv. The recognition of the nil and t streams (standard output and string) is done here now. (vformat): Follow rename of aformat to formatv. (formatv): Function removed. Nobody calls this anymore. (stream_init): make-catenated-stream re-registered to new make_catenated_stream_v function. * stream.h (formatv): Declaration updated. (make_catenated_v): Declared. * syslog.c (syslog_init): syslog registred to syslog_wrapv. (syslog_wrapv): New function based on syslog_wrap converted to struct args. (syslog_wrap): Now wrapper for syslog_wrapv. * syslog.h (syslog_wrapv): Declared. * unwind.h (uw_throwv): New function. (uw_throwfv, uw_errorfv): Converted to struct args. * unwind.h (uw_throwv): Declared. (uw_throwfv, uw_errorfv): Declarations updated.
* Clarification about @rest in do/op syntax.Kaz Kylheku2015-08-231-9/+20
| | | | | | * txr.1: Make it clear that @rest is not inserted if meta-numbers or @rest is present. Move example to the end.
* Remove silly use of apply from open-files.Kaz Kylheku2015-08-211-5/+2
| | | | * stream.c (open_files, open_files_star): Refactored.
* Don't implement range and range* with variadic functions.Kaz Kylheku2015-08-211-15/+14
| | | | | | | | | * eval.c (rangev, range_star_v): Functions renamed to range and rangev, and take three arguments instead of an argument list. (rangev_func, range_star_v_func): Static functions renamed to range_func and range_star_func. (eval_init): Register of range and rangev as three-argument functions with all arguments optional.
* Missing notes about global lexical variables.Kaz Kylheku2015-08-201-8/+43
| | | | | | * txr.1: Note that TXR Lisp has global lexicals, and that some library variables are examples of such, and that defparm is defparameter in CL.
* Wording in description of quasiquote.Kaz Kylheku2015-08-201-2/+2
| | | | | * txr.1: An unquote's evaluation should be contrasted with the quasiquote's suppression of it, not with the quote.
* Version 113.txr-113Kaz Kylheku2015-08-144-4/+44
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Remove useless member from parser structure.Kaz Kylheku2015-08-192-3/+3
| | | | | | | * parser.c (parser_common_init): Use local variable to capture output of yylex_init, rather than yyscan structure member. * parser.h (struct parser): Member yyscan removed.
* Fix parser bug caused by wrong kind of weak hash table.Kaz Kylheku2015-08-191-1/+1
| | | | | | | | | | | | | | This bug causes the parser associated with a stream to suddenly disappear while reading forms from the stream. Parsing continues, but with a new parser which does not carry the lookahead token from the previous parse. So for instance, we miss the opening parenthesis of the next form. * parser.c (parse_init): The stream_parser_hash must be a hash table with weak keys, but not weak values. We want the association to go away only if the stream becomes unreachable, not if the parser becomes unreachable while the stream is still reachable.
* Provide conservative marking interface.Kaz Kylheku2015-08-193-29/+28
| | | | | | | | | | | | | | | | | | | GC now exports a function for marking something that might not be an object, instead of a function for testing. The previous way wasn't integrated with Valgrind properly, and didn't observe the FREE flag. * gc.c (gc_is_heap_obj): Function removed. (mark_obj_maybe): New static function, with body consisting of code moved from mark_mem_region. (mark_mem_region): Moved code replaced by call to mark_obj_maybe. (gc_conservative_mark): New function, wraps mark_obj_maybe. * gc.h (gc_conservative_mark): Declared. (gc_is_heap_obj): Declaration removed. * parser.c (yy_tok_mark): Use gc_conservative_mark instead of gc_is_heap_obj check and gc_mark.
* Fix broken @@@<n>/@@@rest references in quasiliterals.Kaz Kylheku2015-08-192-2/+6
| | | | | | | | * parser.y (quasi_meta_helper): When obj is a sys:var, leave it alone; don't add another layer of var. Also, do the same if it is a sys:expr. * tests/012/quasi.tl: Added test case.
* Quasiquote regression from 110.Kaz Kylheku2015-08-192-5/+13
| | | | | | | | | | | | | | | | The problem is that one-argument function calls like @(whatever arg) in a quasiliteral being turned into sys:var items. * parser.y (quasi_meta_helper): Remove bogus check on length. The default case is now var, so the var_s check actually matters. The integerp check for the argument of a var form didn't do anything because the entire if statment conditionally selected a useless goto. Removing it for consistent treatment of var items. * tests/012/quasi.tl: Some new test cases involving @rest. These new tests pass whether or not we have that integerp(second(obj)) test in the quasi_meta_helper function. Either way @rest and @@rest produce the same thing.
* Troff formatting macros must not generate control sequences.Kaz Kylheku2015-08-191-4/+4
| | | | | | | | Reported by Dave Love. * txr.1 (cod1, cod2, meti, TP*): When inserting material at the start of a line, add the \& zero width character, so the line isn't interpreted as a control sequence.
* Fix man page markup errors.Dave Love2015-08-171-22/+22
| | | | | * txr.1: Numerous misspellings of macro names are repaired.
* Better error reporting for some indirect calls.Kaz Kylheku2015-08-181-18/+24
| | | | | | | * lib.c (callerror): New static function. (generic_funcall): Use callerror to report errors against the function rather than the uninformative call: prefix. (wrongargs): Implement in terms of callerror.
* Bugfix: forgotten zaps could lead to spurious retention.Kaz Kylheku2015-08-171-3/+3
| | | | | * lib.c (generic_funcall): Added forgotten z() calls to zap arguments in some variadic cases.
* Streamlining format with new args module.Kaz Kylheku2015-08-171-66/+48
| | | | | | | | | | | * stream.c (vformat): split into a new function called aformat, and a small wrapper which retains the vformat name. (aformat): New function formed from most of vformat. Takes struct args * instead of va_list. (formatv): Big switch statement hack gone. Now the function fills in a struct args, allocated on the stack, with an accurate size based on the args list. This is passed directly to aformat.
* Start of new way of handling variable arguments.Kaz Kylheku2015-08-173-1/+162
| | | | | | | | * Makefile (OBJS): Add args.o object. * args.c: New file. * args.h: New file.
* Improved wording about auto-loading.Kaz Kylheku2015-08-161-5/+6
| | | | | * txr.1: In the stdlib variable description, rewrote the text describing the macro-time autoloading scenario.
* Detect alloca.Kaz Kylheku2015-08-151-0/+27
|
* Minor dependency fix in Makefile.Kaz Kylheku2015-08-151-3/+6
| | | | | | * Makefile (y.tab.c, y.tab.h, lex.yy.c): Express dependency of these on the configuration material via the DEP macro rather than directly. That way ABBREV can reflect over the dependency.
* Whitespace.Kaz Kylheku2015-08-151-1/+1
|
* Remove include guards from MPI headers.Kaz Kylheku2015-08-152-12/+0
| | | | | * mpi/mpi-config.h, mpi/mpi.h: These headers do not require include guards. They included only once.
* Allow slashes in regex passed to regex-parse.Kaz Kylheku2015-08-152-19/+47
| | | | | | | | | | | * parser.l (SREGEX): New start state, for stand-alone regex parsing. (grammar): All REGEX state rules are active in the SREGEX state also. The rule for the / character returns a REGCHAR if in the SREGEX state, so it is treated as an ordinary character. * txr.1: Updated regex-parse documentation about the treatment of the slash. Also added notes about double escaping when a string literal is passed to regex-parse.
* Regenerate parser and scanner if config changes.Kaz Kylheku2015-08-151-3/+3
| | | | | | * Makefile (lex.yy.c, y.tab.c, y.tab.h): Add missing dependencies on config.h and config.make so that these files are regenerated if we touch the configuration (for instance change the YACC variable).
* Get Berkeley Yacc port of the parser working again.Kaz Kylheku2015-08-141-0/+7
| | | | | | | | | | | | | * parser.y (byacc_fool): New grammar nonterminal symbol and dummy rule set. (spec): Use dummy byacc_fool to create a fake continuation in the grammar, so the Berkeley-Yacc-generated parser doesn't throw a syntax error. Our YYACCEPT prevents the byacc_fool part from consuming more than one token of lookahead. Bison doesn't need this because it has $default actions which reduce regardless of the lookahead token. BYacc insists on reducing only if it can match $end (end of input), and not other tokens, which constitute syntax errors.
* Formatting fix under clamp function.Kaz Kylheku2015-08-141-1/+1
| | | | * txr.1: .meta -> .metn
* Version 112.txr-112Kaz Kylheku2015-08-146-370/+423
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * tl.vim, txr.vim: Regenerated.
* Fix TEXT macro clash on Windows.Kaz Kylheku2015-08-141-0/+1
| | | | | * txr.c (TEXT): Undefined this macro after including <windows.h>. It clashes with a TEXT macro in y.tab.h.
* Remove unwanted yyparse declaration from y.tab.h.Kaz Kylheku2015-08-142-1/+9
| | | | | | | | | | * Makefile (y.tab.c): Putting in an ugly workaround for an obnoxious new behavior introduced in Bison 3.x, which breaks our build on platforms that have a newer Bison. After generating y.tab.h, we remove the unwanted declaration with sed. * parser.y (yyparse): Declare, since y.tab.h doesn't any more, and the newer Bison's parse skeletons expect it.
* Word splices not quite on board with consing dot handling.Kaz Kylheku2015-08-141-2/+2
| | | | | | | * parser.y (r_exprs): The WSPLICE and QWSPLICE syntax at the front of a list must now initialize the terminating atom to unique_s, not to nil. Without this we get mysterious "misplaced consing dot" errors (even though no consing dot occurs).
* New function, clamp.Kaz Kylheku2015-08-134-0/+45
| | | | | | | | | | * eval.c (eval_init): Register clamp as intrinsic function. * lib.c (clamp): New function. * lib.h (clamp): Declared. * txr.1: Documented.
* Observe display width in format.Kaz Kylheku2015-08-132-9/+59
| | | | | | | | | | | | | Take into account string display width in field trimming and padding calculations, including situations where only half a character fits. * stream.c (calc_fitlen): New function. (vformat_str): Revised to use calc_fitlen. If calc_fitlen indicates that there is no trimming or padding, then use put_string rather than put_char. * txr.1: Update description of format with regard to use of dispaly width in field calculations.
* Print object readably in class mismatch error.Kaz Kylheku2015-08-131-1/+1
| | | | * lib.c (class_check): Use ~s to print offending object.
* New display-width function.Kaz Kylheku2015-08-134-0/+51
| | | | | | | | | | * eval.c (eval_init): Register display-width intrinsic. * lib.c (display_width): New function. * lib.h (display_width): Declared. * txr.1: Documented display-width.
* Floating-point constant tightening.Kaz Kylheku2015-08-122-11/+12
| | | | | | | | | | | | | * parser.l (grammar): Change order of rule which recognizes FLODOT with a one-character trailing context other than a dot, and the rule which diagnoses trailing junk. The issue is that this order gives the wrong interpretation to 123.E, treating it as 123. followed by E rather than trailing junk, like in the case of 123.0E or 123.B. * txr.1: Adding the valid example 1.E5. Removing references to dot as consing dot. Fixed documentation which says that 1.E is 1 followed by a consing dot and E. The wrong behavior in fact produced 1.0 followed by E. No consing dot semantics.
* Improvement in hash bang code.Kaz Kylheku2015-08-121-6/+3
| | | | | * parser.c (read_eval_stream): Simplify hash bang code and avoid creating a string that might not end up being used.
* Use new pushback token priming for single regex parse.Kaz Kylheku2015-08-124-21/+38
| | | | | | | | | | | | | | | | | | | | | | | * parser.h (enum prime_parser): New enum. (prime_parser, prime_scanner, parse): Declarations updated with new argument. * parser.c (prime_parser): New argument of enum prime_parser type Select appropriate secret token for regex and Lisp case. Pass prime selector down to prime_scanner. (regex_parse): Do not prepend secret escape to string. Do not use parse_once function; instead do the parser init and cleanup here and use the parse function. (lisp_parse): Pass new argument to parse, configuring the parser to be primed for Lisp parsing. * parser.l (grammar): Rule producing SECRET_ESCAPE_R removed. (prime_scanner): New argument. Pop the scanner state down to INITIAL. Then unconditionally switch to appopriate state based on priming configuration. * parser.y (parse): New argument for priming selection, passed down to prime parser.
* Fix regression in string field formatting.Kaz Kylheku2015-08-121-4/+0
| | | | | * stream.c (vformat_str): Remove stray bogus code that unconditionally outputs extra left padding.
* Revision to .. syntax.Kaz Kylheku2015-08-122-31/+18
| | | | | | | | | | | | | * parser.y (r_exprs, n_expr): Move the DOTDOT syntactic sugar rule from r_exprs to n_expr, where it is much simpler. This also means that the a..b syntax is now an expression by itself; it need not be enclosed in a list. The DOTDOT operator is made right associative; or rather its existing %right declaration is now activated. * txr.1: Remove documentation stating that the .. notation must be used in a list, and not in the dotted position of an improper list. Document the behavior in the dotted position, and document right associativity.
* Crafting a better parser-priming hack.Kaz Kylheku2015-08-129-41/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The method of inserting a character sequence which generates a SECRET_TOKEN_E token is being replaced with a purely token based method. Because we don't manipulate the input stream, the lexer is not involved. We don't have to flush its state and deal with the carry-over of the yy_hold_char. This comes about because recent changes expose a weakness in the old scheme. Now that a top-level expression can have the form expr.expr, it means that the Yacc parser reads one token ahead, to see whether there is a dot or something else. This lookahead token is discarded. We must re-create it when we call yyparse again. This re-creation is done by creating a custom yylex function, which can maintain pushback tokens. We can prime this array of pushback tokens to generate the SECRET_TOKEN_E, as well as to re-inject the lookahead symbol that was thrown away by the previous yyparse. To know which lookahead symbol to re-inject is simple: the scanner just keeps a copy of the most recent token that it returns to the parser. When the parser returns, that token must be the lookahead one. The tokens we keep now in the parser structure are subject to garbage collection, and so we must mark them. Since the YYSTYPE union has no type field, a new API is opened up into the garbage collector to help implement a conservative GC technique. * gc.c (gc_is_heap_obj): New function. * gc.h (gc_is_heap_obj): Declared. * match.c: Include y.tab.h. This is now needed by any module that needs to instantiate a parser_t structure, because members of type YYSTYPE occur in the structure. (parser.h can still be included without y.tab.h, but only an incomplete declaration for the parser strucure is then given, and a few functions are not declared.) * parser.c (yy_tok_mark): New static function. (parser_mark): Mark the recent token and the pushback tokens. (parser_common_init): Initialize the recent token, the pushback tokens, and the pushback stack index. (pushback_token): New static function. (prime_parser): hold_byte argument removed. Body considerably simplified. The catenated stream trick is no longer required. All we do here is set up two pushback tokens and prime the scanner, if necessary, so it is in the right start state for Lisp. * parser.l (YY_DECL): Take over definition of scanning function, renaming to yylex_impl, so we can implement yylex. (grammar): Rule which produces SECRET_ESCAPE_E token removed. (reset_scanner): Function removed. (yylex): New function. * parser.h (struct parser): Now only forward-declared unless y.tab.h has been included. New members, recent_tok, tok_pushback and tok_idx. (yyset_hold_char): Declared. (reset_scanner): Declaration removed. (yylex): Declared (if y.tab.h included). (prime_parser): Declaration updated. (prime_scanner): Declared. * Makefile: express new dependency on existence of y.tab.h of txr.o, match.o and parser.o.
* Catenated stream reads must not close last stream.Kaz Kylheku2015-08-121-6/+9
| | | | | | * stream.c (cat_get_line, cat_get_char, cat_get_byte) Only close the head stream when popping it off the list.