summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Better stream name for command line expressions.Kaz Kylheku2015-09-061-2/+3
| | | | | | | * txr.c (txr_main): Pass the name argument to lisp_parse instead of defaulting it, so that errors against expressions passed on the command line are referred to "cmdline-expr" rather than the generic "string".
* Parse errors lose program prefix and parens.Kaz Kylheku2015-09-062-2/+17
| | | | | | | | | | | * parser.l (yyerrorf): Don't print the program prefix and parenthes, except if compatibility to 114 or older is requested. The main motivation for this is the repl, where the program prefix is not informative. The new format is also a de facto standard which is compatible with other parsers. Vim understands it directly. * txr.1: Documented.
* Parenthesis sensitivity for completion.Kaz Kylheku2015-09-063-5/+25
| | | | | | | | | | | | | * eval.c (boundp): Static function becomes extern. * eval.h (boundp): Declared. * parser.c (find_matching_syms): New par parameter lets function determine whether previous character is a an open parenthesis or brace, based on which the set of possible completions is restricted. (provide_completions): Calculate the par parameter and pass to find_matching_syms.
* linenoise completion for txr symbolsKaz Kylheku2015-09-053-0/+134
| | | | | | | | | | | | | | | Implement basic tab completion. * lib.c (package_alist, package_name, package_symbols): New functions. * lib.h (package_alist, package_name, package_symbols): Declared. * parser.c (find_matching_syms, provide_completions): New static functions. (repl): Register provide_completions as completion callback with linenoise.
* linenoise: 27 and 9 to ESC and TAB.Kaz Kylheku2015-09-051-2/+2
| | | | | * linenoise/linenoise.c (complete_line): Use TAB and ESC instead of 9 and 27.
* linenoise: Ctrl-V verbatim insert.Kaz Kylheku2015-09-051-0/+12
| | | | | | * linenoise/linenoise.c (enum key_action): New enum constant, CTRL_V. (edit): Implement Ctrl-V.
* linenoise: remove useless comments, 8 -> CTRL_H.Kaz Kylheku2015-09-051-35/+34
| | | | | | | | | * linenoise/linenoise.c (enum key_action): Unused KEY_NULL removed. Removed uninformative comments next to self-explanatory enum constants. (edit): Removed uninformative comments next to cases based on enum key_action enum constants. Replaced 8 with CTRL_H.
* linenoise: separate display semantics from bufferKaz Kylheku2015-09-051-82/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The linenoise edit buffer now shows a printed representation of underlying data. In this printed representation, multiple characters can denote a single physical character, so that a control code like 15 can be displayed as ^M. In the future, this will help with a Unicode-ization of linenoise. The actual edit routines now operate on the data array rather than buf, and the new function sync_data_to_buf is used to synchronize buf with data for the sake of refreshing the display. * linenoise/linenoise.c (LINENOISE_MAX_DISP): New variable. (struct lino_state): buf member becomes an array, so the display buffer is now in the structure, and not stack allocated in the linenoise function. New members data, dlen and dpos for tracking the underlying data. Also, the buflen member variable is gone. Uses of buflen are replaced with sizeof. (sync_data_to_buf): New static function. (complete_line): Pass ls->data to callback, rather than ls->buf. In the saving and restoring trick used when displaying completions, we must copy in the completion to the data array; we cannot swizzle a buffer pointer like before. The restoration of the state is simplified; just copy back the entire original. Lastly, when a completion is selected, it must go into the data array, and not buf. Here, there is a bugfix; it appears that refresh_line was not called; I had to add that call. (Did that work before this change?) (refresh_line): Call sync_data_to_buf before calling either refresh function. (edit_insert, edit_move_left, edit_move_right, edit_move_home, edit_move_end, edit_history_next, edit_backspace, edit_delete_prev_word): Operate on data array, dlen and dpos rather than buf, len and pos. (edit): Doesn't take buffer and length parameters any more. No need to initialize context structure members buf, or removed member buflen. New members dlen and dpos have to be initialized. Inlined edit operations now work with data array, rather than buf. (go_raw): Buffer and buflen arguments are gone. Non-tty code still allocates buffer on stack, but only in its local block. (linenoise): Do not instantiate local buffer for passing to go_raw, which doesn't take one any more. When finished, duplicate the string in the data array.
* Syntax errors refer to REPL line number.Kaz Kylheku2015-09-056-8/+25
| | | | | | | | | | | | | | | | | | * eval.c (eval_init): Registrations of lisp-parse and read must account for new optional argument. * lib.c (func_n5o): New function. * lib.h (func_n5o): Declared. * parser.c (lisp_parse): New argument for passing in line number. This is punched into the parser object. (read_eval_stream): Call to lisp_parse defaults new argument. (repl): Pass repl line number to lisp_parse. * parser.h (lisp_parse): Declaration updated. * txr.c (txr_main): Call to lisp_parse defaults new argument.
* Numbered prompt with backreferencing.Kaz Kylheku2015-09-051-1/+15
| | | | | | | * parser.c (repl): Implement counter which enumerates REPL lines. Implement *<num> variabls which allow the last 100 results to be referenced, as well as *n, *v, and *r variables to have more flexible access to this value history.
* linenoise: hard-coded stream in generate_beep.Kaz Kylheku2015-09-051-5/+4
| | | | | | | * linenoise/linenoise.c (generate_beep): Take line noise context argument and send BEL character to output file descriptor, rather than hardcoding to stderr. (complete_line): Pass context to generate_beep.
* Basic REPL based on linenoise.Kaz Kylheku2015-09-055-1/+119
| | | | | | | | | | | | | | | | * Makefile (OBJS): Only include linenoise.o if have_termios is y. * configure: Adding test for termios. (have_termios): New configure and config.make variable. (gen_config_make): Generate have_termios variable. * parser.c (repl): New function. * parser.h (repl): Declared. * txr.c (help): Summarize new -i option. (txr_main): Implement -i repl.
* linenoise: get rid of globals; everything in struct.Kaz Kylheku2015-09-043-182/+234
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * linenoise/linenoise.c (completion_callback, orig_termios, rawmode, mlmode, history_max_len, history_len, history): Global variables removed; moved into struct lino_state. (struct lino_state): New members next, prev. New members completion_callback, orig_termios, rawmode, mlmode, history_max_len, history_len, history. (lino_list): New static variable: dummy node for circular list of struct lino_state structures. (lino_set_multiline): Operate on structure rather than global variable. (enable_raw_mode, disable_raw_mode): Operate on structure. Use file descriptors from structures rather than inconsistent hard-coded use of STDIN_FILENO and the argument fd, which is gone. (lino_clear_screen): Obtain file descriptor from structure, rather than global. (complete_line): Operate on structure rather than globals. Pass context to completion callback. (lino_set_completion_cb): Store callback in structure rather than global. Store new context argument also. (reresh_line): Take mode from structure rather than global. (edit_insert, edit_move_end): Operate on struture rather than globals. (edit): Do not accept file descriptor arguments. Do not update ifd and ofd members of structure; just rely on these values to already be there, since the lino_make constructor puts them there. (lino_print_keycodes, go_raw): Operate on structure. (lino_make, lino_free): New functions. (lino_cleanup): New static function. (linenoise, free_hist): Operate on structure. (atexit_handler): Loop over all structures in global list, and clean up each one. (lino_hist_add, lino_list_set_max_len, lino_hist_save, lino_hist_load): Operate on structure. * linenoise/linenoise.h (lino_t): New typedef. (lino_compl_cb_t): Function type takes new context argument. (lino_set_completion_cb, linenoise, lino_hist_add, lino_hist_set_max, lino_his_save, lino_hist_load, lino_clear_screen, lino_set_multiline, lino_print_keycodes): Declarations updated. * linenoise/example.c (completion): Take new context argument, and ignore it. (main): Create linenoise context with lino_make, giving it the input and output file descriptor, and pass it to all functions.
* Bringing in Linenoise example.Kaz Kylheku2015-09-041-0/+75
| | | | * linenoise/example.c: New file.
* linenoise: tty read fix.Kaz Kylheku2015-09-041-1/+2
| | | | | | * linenoise/linenoise.c (edit): If 0 bytes is read from the tty for any reason, return -1 so that the linenoise function will return a null pointer rather than a blank line.
* Null out freed history elements.Kaz Kylheku2015-09-041-7/+15
| | | | | | | | | | * linenoise/linenoise.c (edit): Set freed element of history array to null. (free_hist): Null out all elements, and then the array pointer. (lino_hist_set_max_len): Calculate value of history_len variable in obviously correct way, based on amount of history preserved.
* linenoise: change naming to conform to project.Kaz Kylheku2015-09-042-146/+145
| | | | | | | | linenoise/linenoise.c, linenoise/linenoise.h: Renaming all camel-case identifiers to underscores. The verbose linenoise prefix becomes lino_. All caps enum tag gets lower cased. Static functions with linenoise prefix lose the prefix.
* Eliminate tabs from linenoise source.Kaz Kylheku2015-09-041-19/+19
| | | | | | * linenoise/linenoise.c (enum KEY_ACTION): Remove tabs from declaration. This is the only place in the file which has tabs.
* linenoise: compile as C++ and use checked allocator.Kaz Kylheku2015-09-042-27/+19
| | | | | | | | | | | | | | | | | * linenoise/linenoise.c (mem_t): New typedef, compatible with the one in lib.h, which we don't want to include. (chk_malloc, chk_realloc): External declarations added. (unsupported_term): Make element type const char *. (linenoiseAddCompletion): Use checked allocator, add casts, use the superior "sizeof *dest_pointer_var" expression in size calculations rather than "sizeof (maybe_wrong_type)". (abAppend, linenoiseHistoryAdd, linenoiseHistorySetMaxLen): Likewise. * linenoise/linenoise.h: Remove unnecessary include guards; we don't use them in this project. Remove 'extern "C"'; we don't require C linkage when compiling everything as C++.
* Fix failure of struct.c to compile as C++.Kaz Kylheku2015-09-041-16/+9
| | | | | | | * struct.c (struct_type_ops, struct_inst_ops): Use static_forward and static_macros to handle the forward declarations. Also, cobj_ops_init macro now used for both instead of raw initializer.
* Compile and link linkenoise into txr; fix errors.Kaz Kylheku2015-09-042-9/+10
| | | | | | | | | | | * Makefile (OBJS): Add linenoise/linenoise.o. * linenoise/linenoise.c (linenoiseEditInsert, linenoiseEditMoveLeft, linenoiseEditMoveRight, linenoiseEditMoveEnd, linenoiseEditHistoryNext, linenoiseEditDelete, linenoiseEditBackspace, linenoiseEditDeletePrevWord): These de facto internal functions are switched from external to static.
* No need to point the compiler into the mpi directory.Kaz Kylheku2015-09-042-2/+1
| | | | | | * Makefile (CFLAGS): Remove -iquote $(top_srcdir)mpi * lib.h: include "mpi/mpi.h" instead of "mpi.h".
* Add linenoise library.Kaz Kylheku2015-09-034-1/+1203
| | | | | | | | | | * LICENSE: Add Linenoise authors to the list of copyright holders. * linenoise/LICENSE: New file. * linenoise/linenoise.c: New file. * linenoise/linenoise.h: New file.
* Version 114.txr-114Kaz Kylheku2015-09-027-317/+377
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * genvim.txr: Scan struct.c, path-test.tl and struct.tl files. * txr.vim, tl.vim: Regenerated.
* One-liner to allow @{obj.slot} in quasiliterals.Kaz Kylheku2015-09-022-2/+2
| | | | | | | | * parser.l (grammar): Recognize '.' token in BRACED state also. * genvim.txr: @{obj.slot ...} syntax highlighting support. Include txr_dot and txr_dotdot in txr_bracevar region.
* Adding struct tests.Kaz Kylheku2015-09-023-4/+148
| | | | | | | | | | | | * tests/common.tl (vtest): New macro based on test. Evaluates the expected expression. (test): Becomes a wrapper for vtest which quotes the expected expression. (stest): New macro for string-based comparison of output. * tests/012/struct.expected: New file. * tests/012/struct.tl: New file.
* Slot cache fix: zero is a valid slot index.Kaz Kylheku2015-09-021-2/+2
| | | | | | | struct.c (cacheline_lookup): return -1 when the id is not found in the cacheline, rather than zero. (lookup_slot): Test return value of cacheline_lookup according to the above change.
* Fix broken finalization support.Kaz Kylheku2015-09-021-1/+1
| | | | | | | * gc.c (call_finals): Correct inverted test for reachability. The function was processing entries that are still reachable and calling their finalizers, and retaining unreachable entries in the finalization list.
* Fix incorrect finalization of struct-type.Kaz Kylheku2015-09-023-15/+22
| | | | | | | | | | | | | | | | | | | | | | The issue is that we can't call remhash in the cobj destroy handler, because we are in the middle of gc. The fix is to register a proper finalization hook. This is the first use of finalize from within TXR. * gc.c (gc_finalize): static becomes extern. * gc.h (gc_finalize): Declared. * struct.c (struct_type_finalize_f): New static variable. (struct_init): GC-protect new static variable, and initialize it to point to new struct_type_finalize function. (struct_type_finalize): New function: performs the remhash calls previously done in struct_type_free. (make_struct_type): Register a finalizer hook for every new structure type, which will call struct_type_finalize. (struct_type_free): Static function removed. (struct_type_ops): Use generic cobj_destroy_free_op since all that is left to do is to free the handle.
* Fix incorrect example and add one more approach.Kaz Kylheku2015-09-021-12/+38
| | | | | | | | HACKING: Fix wrong make_foo example which violates Rule One, by registering an uninitialized struct as a cobj handle, thereby making garbage traversable by gc. Also show alternative solution to the problem based on extending variable liveness via gc_hint.
* Unix password database access.Kaz Kylheku2015-09-013-0/+246
| | | | | | | | | | | | | | | * configure: Detect getpwuid, getpwuid_r and others. * sysif.c (passwd_s, name_s, gecos_s, dir_s, shell_s): New symbol variables. (setpwent_wrap, endpwent_wrap, fill_passwd, make_pwstruct, getpwent_wrap, getpwuid_wrap, getpwnam_wrap): New static functions. (sysif_init): Initialize new symbol variables. Create passwd structure type. Register setpwent, endpwent, getpwent, getpwuid and getpwnam intrinsics. * txr.1: Documented passwd structure and functions.
* Fix wrongly named hash_lit_s symbol.Kaz Kylheku2015-09-011-1/+1
| | | | | * eval.c (eval_init): Fix wrong name of hash_lit_s symbol; it should be sys:hash-lit and not sys:hash-construct.
* Document new time structure and functions.Kaz Kylheku2015-09-011-0/+65
| | | | | * txr.1: Document time struct, time-struct-local and time-struct-utc.
* Documenting stat structure.Kaz Kylheku2015-09-011-25/+47
| | | | | | * txr.1: stat structure described; places updated to refer to it rather than the old propertly list. Compatibility note added.
* Fix bad .meta/.metn formatting.Kaz Kylheku2015-09-011-5/+5
| | | | | * txr.1: Fixed incorrect macro use under in, mapdo, set, and getenv.
* equal comparison and hashing for structs.Kaz Kylheku2015-09-011-2/+36
| | | | | * struct.c (struct_inst_equal, struct_inst_hash): New functions. (struct_inst_ops): Wire new functions into operations table.
* Fix wrong description of :wholeKaz Kylheku2015-09-011-2/+32
| | | | | * txr.1: :whole doesn't bind the entire macro form. Added Dialect Note to compare with CL.
* Improve error for uncallable object.Kaz Kylheku2015-09-011-1/+1
| | | | | | * lib.c (generic_funcall): If the object is not callable, the overall message now will be "object <whatever> called as function: object is not callable".
* Remove useless comment that contains two typos.Kaz Kylheku2015-09-011-4/+0
|
* Time structure.Kaz Kylheku2015-08-313-0/+62
| | | | | | | | | | | | | * eval.c (eval_init): Register time-struct-local and time-struct-utc intrinsic funtions. * lib.c (time_s, year_s, month_s, day_s, hour_s, min_s, sec_s): New global symbol variables. (broken_time_struct, time_init): New static functions. (time_struct_local, time_struct_utc): New functions. (init): Call time_init. * lib.h (time_struct_local, time_struct_utc): Declared.
* Struct documentation.Kaz Kylheku2015-08-311-5/+750
| | | | * txr.1: New section on structs documenting functions and macros.
* Move stat functions to use a struct.Kaz Kylheku2015-08-306-37/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (init): Move hash_init and struct init before sysif_init. * share/txr/stdlib/path-test.tl (sys:path-test-mode, path-mine-p, path-my-group-p, sys:path-access, path-newer, path-examine): Convert to struct return of stat functions. * stream.c (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Global variable definitions removed from here. (stream_init): Initializations of moved global variables removed from here. * stream.h (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Declarations removed from here. * sysif.c (stat_s, dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s, rdev_s, size_s, blksize_s, blocks_s, atime_s, mtime_s, ctime_s): New global variables. (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Existing variables moved here. (stat_to_struct): New static function. (stat_impl): Use stat_to_struct, except under 113 compatibility. (sysif_init): Initialize new symbol variables. Make stat struct type. * sysif.h (stat_s, dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s, rdev_s, size_s, blksize_s, blocks_s, atime_s, mtime_s, ctime_s): Declared.
* struct: 4-way set associative slot caches.Kaz Kylheku2015-08-302-13/+61
| | | | | | | | | | | * lib.h (SLOT_CACHE_SIZE): Adjust value from 32 to 8. (slot_cache_entry_t): New struct typedef. (slot_cache_line_t): Typedef updated: a cache line consists of cache line entry structs rather than cnums. * struct.c (cacheline_lookup, cacheline_insert): New static functions. (lookup_slot): Use cacheline_lookup and cacheline_insert.
* Introducing structs.Kaz Kylheku2015-09-0215-6/+636
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * args.c (args_cat_zap): New function. * args.h: (args_cat_zap): Declared. * eval.c (struct_lit_s): New symbol variable. (eval_init): Initialize struct_lit_s. * eval.h (struct_lit_s): Declared. * gc.c (finalize): If a symbol has a struct slot hash attached to it, we must free it when the symbol is reclaimed. * lib.c (make_sym): Initialize symbol's slot_cache pointer to null. (copy): Copy structure objects. (init): Call struct_init to initialize struct module. * lib.h (SLOT_CACHE_SIZE): New preprocessor symbol (slot_cache_line_t, slot_cache_t): New typedefs. (struct sym): New member, slot_cache. * lisplib.c (struct_set_entries, struct_instantiate): New static functions. (liplib_init): Register new functions in dl_table. parser.y (HASH_S): New terminal symbol. (struct): New grammar rule. (n_expr): Derive struct. (yybadtoken): Map HASH_S to #S string. parser.l (grammar): Recognize #S and return HASH_S token. share/txr/stdlib/place.tl (slot): New defplace. share/txr/stdlib/struct.tl: New file. struct.c: New file. struct.h: New file. * Makefile (OBJS): Adding struct.o.
* Document alternation syntax.Kaz Kylheku2015-08-291-0/+8
| | | | | * txr.1: The { x | y } notation has been used in the document for a long time; now it is explained.
* Print parser error message for parse-time exceptions.Kaz Kylheku2015-08-291-3/+25
| | | | | | * parser.y (parse_once, parse): Catch error exceptions coming out of yyparse, print message, then re-throw. This way we see the file and line number near where that happened.
* Renaming c_true to tnil.Kaz Kylheku2015-08-275-25/+25
| | | | | | | | | | | | | | | | | | | | Macros called c_* should produce C counterparts of Lisp val objects, like c_num and c_str. * lib.h (c_true): Renamed to tnil. * eval.c (lexical_var_p, lexical_fun_p): c_true to tnil. * lib.c (less, chr_isalnum, chr_isalnum, chr_isalpha, chr_isascii, chr_iscntrl, chr_isdigit, chr_isgraph, chr_islower, chr_isprint, chr_ispunct, chr_isspace, chr_isblank, chr_isunisp, chr_isupper, chr_isxdigit, chr_toupper, keywordp): Likewise. * stream.c (catenated_stream_p): Likewise. * sysif.c (wifexited, wifsignaled, wcoredump, wifstopped, wifcontinued): Likewise.
* Fix wrong HTML references caused by identical section names.Kaz Kylheku2015-08-251-2/+7
| | | | | | | | | | For instance, both entries in the TOC titled "Overview" navigate to the the same section when we click on them. * genman.txr (tagnum): New hash for counting duplicate occurrences of section title. (enumerate): New function for adding numeric suffix to titles which are the same as previously seen titles.
* Fix duplication in manpage.Kaz Kylheku2015-08-251-15/+1
| | | | | * txr.1: Verbatim exact duplicate of packagep documentation removed. Fixed duplicated mknod heading over description of chmod.
* Replace two-step initialization of args with macros.Kaz Kylheku2015-08-247-84/+55
| | | | | | | | | | | | | | | | | | | | | * args.h (args_init_list, args_init): Return the struct args * pointer. (args_decl_list, args_decl): New macros. * eval.c (apply, do_eval, expand_macro, op_dwim, op_catch, (mapcarl, lazy_mapcarl): Switch to new macros. * hash.c (hashl): Likewise. * lib.c (generic_funcall, lazy_appendl, maxl, minl, funcall, funcal1, funcall2, funcall3, funcall4, transpose, juxtv, do_and, do_or, do_iff, unique): Likewise. * match.c (h_fun, v_fun): Likewise. * stream.c (vformat): Likewise. * syslog.c (syslog_wrap): Likewise.