summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* @(load) and @(include) now load Lisp code.Kaz Kylheku2015-06-124-29/+82
| | | | | | | | | | | * match.c (v_load): Check txr_lisp_p flag coming out of open_txr_file and handle the Lisp case usin read_eval_stream. * parser.c (read_eval_stream, get_parser, parser_errors): New functions. * parser.h (read_eval_stream, get_parser, parser_errors): Declared.
* Preparing for lisp loading.Kaz Kylheku2015-06-105-11/+79
| | | | | | | | | | | | | * parser.c (open_txr_file): Rewritten to take new argument which indicates whether to treat an unsuffixed file as TXR or TXR Lisp, and is updated to indicate which is the case by looking at the suffix. * parser.h (open_txr_file): Declaration updated. * match.c (v_load): Follow change in open_txr_file. * txr.c (txr_main): Likewise.
* Error handling improvement in read.Kaz Kylheku2015-06-103-4/+25
| | | | | | | | | | * parser.y (spec): New grammar production to handle the cases that SECRET_ESCAPE_E is not followed by anything (the input ends before any object is scanned, or there is no input token which starts an object). * parser.c (lisp_parse): Deal with EOF indication from parser (the syntax_tree member of parser_t set to nao).
* * parser.y (yybadtoken): Print unexpected characterKaz Kylheku2015-06-102-1/+6
| | | | literally rather than as a Lisp character literal.
* Code simplification.Kaz Kylheku2015-06-082-10/+9
| | | | | * txr.c (txr_main): Replacing two code blocks with single call to existing open_txr_file function.
* Critical bugfix for weak hashes.Kaz Kylheku2015-06-072-0/+11
| | | | | | | * hash.c (hash_mark): Hash tables which have both weak keys and values were not added to the reachable_weak_hashes list, and thus not subject to complete hash processing, leading to corruption.
* * lib.h (mkloc): Rename misleading argument from fun to obj.Kaz Kylheku2015-06-072-1/+5
|
* * parser.c (stream_parser_hash): New static variable.Kaz Kylheku2015-06-074-8/+71
| | | | | | | | | | | | | | | | | | (parser_mark): Mark parser and primer members. (parser, ensure_parser): new argument: primer. (get_parser_impl, ensure_parser): New static functions. (prime_parser): New function. (lisp_parse): Multiple calls to this function on the same stream now logically continue the parse, not resetting the line number to 1. (parse_init): Initialize and gc-protect stream_parser_hash. * parser.h (parser_t): New members, primer and parser. (prime_parser): Declared. (parser): Declaration updated. * parser.y (parse): Now responsible for calling prime_parser.
* * match.c (v_load): Call parse_once rater than parse.Kaz Kylheku2015-06-076-6/+42
| | | | | | | | | | | | | * parser.c (regex_parse): Likewise. * txr.c (txr_main): Likewise. * parser.h (parse): Declaration updated. (parse_once): Declared. * parser.y (parse_once): New function, same as old parse implementation. (parse): Becomes one argument function which works with a previously initialized parser and continues the parse.
* * stream.c (catenated_stream_p, catenated_stream_push): New functions.Kaz Kylheku2015-06-074-0/+76
| | | | * stream.h (catenated_stream_p, catenated_stream_push): Declared.
* * txr.1: Document new syntactic places framework and place-mutating macros.Kaz Kylheku2015-05-252-285/+2320
|
* Fix mismanaged dyn_env variable.Kaz Kylheku2015-05-252-3/+16
| | | | | | | | | | * eval.c (bindings_helper): In the parallel binding case, only allocate a new dynamic env when it is needed (because a special variable is being bound), rather than unconditionally. Consequently, only modify dyn_env when the dynamic environment actually needs to be extended. Constructs that use bindings_helper are only wrapped in the dynamic environment save/restore form sys:with-saved-vars if they bind special variables.
* Ligher weight debug instrumentation.Kaz Kylheku2015-05-226-26/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This speeds up the TXR Lisp interpreter, because do_eval sets up a debug frame and uses debug_return. * debug.c (debug_block_s): Symbol removed. (debug_init): Remove initialization of debug_block_s. * debug.h (debug_block_s): Declaration removed. (debug_enter): Do not establish a named block or a catch block; no time-wasting unwind stack manipulation at all. The debug_depth variable is managed by the extended setjmp context now. Provide a return value variable, and a well-defined name to branch to to exit from the debug block. (debug_return): Do not use heavy-weight uw_block_return; simply set the return variable and branch to debug_return_out label. * signal.h (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST, EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): New macros. (extended_jmp_buf): Define optional global state variables using EJ_OPT_MEMB. (extended_setjmp): Save and restore optional globals using EJ_OPT_SAVE and EJ_OPT_RESTORE. Now debug_depth is saved and restored if debugging support is compiled in. * match.c (open_data_source): Remove bogus debug_return invocations which were uncovered here by changes to the macro. * eval.c (do_eval, expand_macro): debug_return must now be after debug_end, because it won't dynamically clean up frames that it doesn't know about. The set_dyn_env is no longer unreachable in expand_macro; it is now necessary because debug_return isn't doing the longjmp that previously restored dyn_env.
* Adding pushnew.Kaz Kylheku2015-05-223-1/+19
| | | | | | * place.tl (pushnew): New macro. * lisplib.c (set_place_dlt_entries): Add pushnew.
* symbol-function, symbol-value and fun become places.Kaz Kylheku2015-05-223-0/+77
| | | | | | | | | * eval.c (op_setqf): New function. (eval_init): Register sys:setqf operator. Also expose global variable hash tables via sys:top-vb and sys:top-fb. * place.tl (sys:get-fb, sys:get-vb): New functions. (fun, symbol-function, symbol-value): New places defined.
* Introduce defparm operator.Kaz Kylheku2015-05-213-6/+74
| | | | | | | | * eval.c (me_defparm): New function. (eval_init): Register defparm. * txr.1: Documented defparm together with defvar. defvar documentation is revised.
* Represent place.tl more compactly in image.Kaz Kylheku2015-05-193-3/+14
| | | | | | | | | The contents of place.tl are now stored as a UTF-8 ordinary literal instead of a wide char literal. * Makefile (LISP_TO_C_STRING): Generate plain literal. * lisplib.c: Convert plain literal to string.
* Variables are now deletable places, if they are global.Kaz Kylheku2015-05-153-5/+25
| | | | | | * place.tl (sys:sym-delete-expander): New function. (get-delete-expander): Retrieve delete expander for symbols.
* * eval.c (symbol_value): Retrieve the binding of a symbolKaz Kylheku2015-05-153-12/+122
| | | | | | | | | | macro also. (boundp): Return t for symbol macros. (makunbound, fmakunbound): New functions. (eval_init): Register makunbound and fmakunbound. * txr.1: Document changes to symbol-value and boundp, and add dialect notes about the different semantics of binding.
* * txr.1: Round of spelling fixes.Kaz Kylheku2015-05-151-46/+46
|
* * lib.c (replace_list, replace_str, replace_vec): HandleKaz Kylheku2015-05-143-2/+74
| | | | | | | | the case when from is a vector, for consistency with the sel function and the dwim operator. * txr.1: Document that the third argument of select and replace may be a vector.
* Recursive lcons force bug (keep-if*, remove-if*).Kaz Kylheku2015-05-132-1/+10
| | | | | * lib.c (rem_lazy_func): Do not access the cdr field of the lcons that we are in the middle of forcing!
* * place.tl (define-modify-macro): New macro.Kaz Kylheku2015-05-133-1/+16
| | | | * lisplib.c (set_place_dlt_entries): Add define-modify-macro.
* * place.tl (push): Ensure left-to-right eval order.Kaz Kylheku2015-05-132-2/+8
|
* * place.tl (rlet): For the sake of sane evaluation orderKaz Kylheku2015-05-122-2/+8
| | | | | in the face of unknown side effects, do not thread symbolic references; only propagate constants.
* * eval.c (env_vb_to_fb): Allow null env argument. ThisKaz Kylheku2015-05-122-3/+10
| | | | case occurs when (flet () ...) is expanded.
* DWIM places must use Lisp-1 semantics.Kaz Kylheku2015-05-123-48/+138
| | | | | | | | | | | | | | | | | | | | This really only affects code which does something like (set [f x] y) and f resolves as a function. (The TXR Program bent over backwards to install a mutable object into a function binding.) In this situation, we need to update the function binding f, rather than some variable f. * eval.c (op_lisp1_setq, op_lisp1_value): New static functions. (eval_init): Register sys:lisp1-setq and sys:lisp1-value special forms. * place.tl (sys:*lisp1*): New special variable. (sys:sym-place-update-expander, sys:sym-place-clobber-expander): React to sys:*lisp1* variable by doing symbol access using Lisp-1 semantics, with help of newly introduced special forms. (dwim): Bind sys:*lisp1* to true, if main argument is a symbolic place, so that the update is done using Lisp-1 semantics. Use the sys:lisp1-value operator when evaluating arguments.
* * eval.c (lookup_var_l): Gut this function of its sillyKaz Kylheku2015-05-122-30/+14
| | | | | | | reimplementation of lookup_var. (op_setq): Use lookup_var instead of lookup_var_l. Now only outside modules use the lookup_var_l interface. Error message fix: sys:setq, not setvar.
* Handle vectors and strings in rplaca and rplacd.Kaz Kylheku2015-05-112-2/+20
| | | | | | * lib.c (rplaca, rplacd): Use refset and replace respectively to handle vectors and strings. Adjust type mismatch error message.
* * lib.c (chr_str_set): Check for literal strings.Kaz Kylheku2015-05-112-0/+9
|
* Fix argument count checking regression.Kaz Kylheku2015-05-112-4/+14
| | | | | | * eval.c (apply): Revert some changes from 2015-03-13 which cause the too many arguments case not to be diagnosed.
* Spelling in car/cdr doc.Kaz Kylheku2015-05-101-1/+1
|
* * place.tl (errno): Support (errno) form as place.Kaz Kylheku2015-05-101-0/+4
|
* Improve error message related to splice misuse.Kaz Kylheku2015-05-092-2/+9
| | | | | * eval.c (expand_qquote): Corrected awkward error message text which was saying that a splice "cannot occur as an atom".
* Minor formatting fix in ret macro description.Kaz Kylheku2015-05-091-1/+1
|
* Adding pset operator.Kaz Kylheku2015-05-093-1/+29
| | | | | | * place.tl (pset): New macro. * lisplib.c (set_place_dlt_entries): Add pset.
* * place.tl (set): Take multiple place/value pairs. Allow zeroKaz Kylheku2015-05-092-3/+15
| | | | arguments.
* Crack down on redefinitions of built-ins.Kaz Kylheku2015-05-087-23/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (builtin, eval_initing): New global variable. (op_defun, op_defmacro): During initialization, record functions and macros in builtin hash. (builtin_reject_test): New static function. (expand_macrolet): Perform builtin reject test for fbind, lbind, and macrolet. (regfun, reg_mac): Add symbol to builtin hash. (eval_init): GC-protect new hash table variable and initialize it. Set eval_initing to true over eval initialization. The flip function is renamed fo flipargs. (eval_compat_fixup): New function, for dealing with the operator/function conflict over flip. * eval.h (eval_compat_fixup): Declared. * lib.c (compat_fixup): Call eval_compat_fixup. * tests/011/macros-2.txr: This test was defining a macro called while which is now illegal. Renamed to whilst. * tests/011/macros-2.expected: Regenerated. * txr.1: Function flip renamed to flipargs and documented in Compatibility section.
* * Makefile (LISP_TO_C_STRING): Strip comments, but not comment lines,Kaz Kylheku2015-05-078-13/+45
| | | | | | | | | | | | | | | | | | so line numbers don't change. * eval.c (eval_init): Fix registrations of lisp-parse and read. * lisplib.c (place_instantiate): Give name to parsed string stream using new lisp_parse argument. * parser.c (lisp_parse): Takes new argument to override name. * parser.h (lisp_parse): Declaration updated. * txr.c (txr_main): Call lisp_parse with four args, defaulting the new one. * txr.1: Documented new argument.
* single-body-form-fixupKaz Kylheku2015-05-261-48/+48
|
* New macro-based framework for assignment places.Kaz Kylheku2015-05-0614-318/+715
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The operators set, inc, dec, pop and others are now macros which generate code, rather than built-in special forms that use "C magic". Moreover, new such macros are easy to write, and several new ones are already available. Moreover, new kinds of assignable places are easy to create. * place.tl: New file. * lisplib.c, lisplib.h: New files. * Makefile (OBJS): New target, lisplib.o. (GEN_HDRS): New variable. (LISP_TO_C_STRING): New recipe macro, with rule. (clean): Remove generated headers named in $(GEN_HDRS). * eval.c (dec_s, push_s, pop_s, flip_s, del_s): Variables removed. (setq_s): New variable. (lookup_var, lokup_sym_lisp_1, lookup_var_l, lookup_fun, lookup_mac, lookup_symac, lookup_symac_lisp1): Trigger the delayed loading of libraries for undefined global symbols, and re-try the lookup. (op_modplace, dwim_loc, force_l): Static functions removed. (op_setq): New static function. (eval_init): Initialize setq_s; remove initializations of removed variables; remove registrations for op_modplace; add registration for sys:setq, sys:rplaca, sys:rplacd, sys:dwim-set and sys:dwim-del intrinsics. Call lisplib_init to initialize the dynamic library loading module. * lib.c (sys_rplaca, sys_rplacd): New functions, differing in return value from rplaca and rplacd. (ref, refset): Handle hash table. (dwim_set, dwim_del): New functions. * lib.h (sys_rplaca, sys_rplacd, dwim_set, dwim_del): Declared. * genvim.txr: Include place.tl in scan. * tests/010/seq.txr: The del operator test case no longer throws at run-time but at macro-expansion time, so the test case is simply removed. * tests/010/seq.expected: Updated output. * tests/011/macros-2.txr: Reset *gensym-counter* to zero, because the textual output of the test case includes gensyms, whose numberings fluctuate with the content of the new Lisp library material. * tests/011/macros-2.expected: Updated output.
* * gc.c (make_obj, gc): Move resetting of prev_malloc_bytesKaz Kylheku2015-05-062-2/+6
| | | | out of make_obj into gc.
* Do some cleanup in progn-like form sequences.Kaz Kylheku2015-05-052-9/+53
| | | | | | * eval.c (expand_progn): New function. (do_expand): Use expand_progn for constructs which have an implicit progn body.
* Deal with bad quote syntax.Kaz Kylheku2015-05-033-2/+15
| | | | | | | * eval.c (op_quote): Throw error on bad syntax. * lib.c (obj_print, obj_pprint): Do not hide bad quote syntax using ' notation; print it using ordinary notation.
* Move initialization calls to more suitable place.Kaz Kylheku2015-05-013-9/+20
| | | | | | | | * lib.c (init): Initialize parser, syslog and glob modules here. * txr.c (main): Remove initialization of parser, syslog and glob modules from here.
* * signal.h (sig_save_disable): Bugfix: macro enablingKaz Kylheku2015-05-012-1/+6
| | | | rather than disabling async signals.
* Fix corruption triggered by extended gc disabling.Kaz Kylheku2015-05-013-39/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue is that when gc is disabled, the gc function does nothing. But various code depends on calls to gc() doing something, like making space available in various static arrays. When gc is disabled for long periods, there are issues, like array overruns. * gc.c (gc): Must no longer be called at all if gc_enabled is false, and asserts that it is true. Callers must check the gc_enabled flag and implement appropriate cases. (make_obj): Only call gc when gc_enabled is true. If there is no space in the freshobj array after trying gc, or gc couldn't be tried because it is disabled, then schedule a full gc. (gc_set): If the checkobj array is full, only call gc if gc is enabled, otherwise schedule a full_gc. (gc_mutated): Do not assume that the mutobj array has room for another object; only set the object's generation to -1 and put it into the array if there is room. Similarly to gc_set, do a gc if there is no room, but if gc is not enabled, then schedule a full gc. (gc_wrap): Only call gc if gc_enabled is true, and return t in that case rathe than nil. * txr.1: Document return value of sys:gc function.
* Fix source location for dangling unquotes and splices.Kaz Kylheku2015-04-302-10/+34
| | | | | | | | | | * parser.y (grammar): Propagate the parser line number to the unquote or splice form, if it has not received location info from its operand (because its operand is an atom). In the quasi_item case, we also use rlcp_tree to make sure the info is propagated through the list being consed up. (rlcp_tree): Bugfix: propagate the source location info to every cons in the list itself, not just into their cars.
* Improved syntax checking: defun, flet, labels, lambda.Kaz Kylheku2015-04-292-48/+91
| | | | | | | | | | | | | | * eval.c (check_lambda_list): New static function. (op_defun): Argument list checking moved into check_lambda_list, which is called for defun out of do_expand. Name checks moved into do_expand. Thus, defun is checked earlier, at expansion time. (me_flet_labels): Check the lambda list of each lexical function with check_lambda_list. (do_expand): Check the syntax of the lambda form, and the validity of its argument list. Check the name of a defun or defmacro for validity. Check the validity of the defun argument list.
* Bugfix: cannot print (lambda . 42) structure.Kaz Kylheku2015-04-292-2/+9
| | | | | * lib.c (obj_print, obj_pprint): Fix mistake in the test for properly formed lambda syntax whcih is printed specially.