summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* * debug.c (debug): Eliminated duplicate code.Kaz Kylheku2011-11-132-12/+26
| | | | Implemented better way of printing character context.
* Adding a debugger. This is an experimental prototype.Kaz Kylheku2011-11-1311-8/+295
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile (OBJS): New object file debug.o. * dep.mk: Updated. * match.c (h_fun): Use debug_begin and debug_end macros to set up a debug frame for backtracing. (match_line, match_files): Call debug_check to give debugger a chance to instrument call. (v_fun): Use debug_begin and debug_end macros to set up a debug frame for backtracing. Call debug_check to give debugger a chance to instrument call. * stream.c (struct strm_ops): New function pointer, flush. (stdio_maybe_write_error): Wrong word in error message corrected. (stdio_flush): New static function. (stdio_ops, pipe_ops): New function entered into tables. (flush_stream): New function. * stream.h (flush_stream): Declared. * txr.c (help): New options documented. (main): call to debug_init added. New debug options parsed and opt_debugger set accordingly. * unwind.c (uw_push_debug, uw_current_frame): New function. * unwind.h (uw_frtype): New enumeration member UW_DBG. (struct uw_debug): New frame variant. (union uw_frame): New member, db. (uw_push_debug, uw_current_frame): Declared, * debug.c: New file. * debug.h: New file.
* Fix regression in earlier commit:Kaz Kylheku2011-11-132-2/+12
| | | | | | | | | "Eliminate line numbers from the abstract syntax tree representation of the TXR query." * match.c (match_funcall): Remove spurious object being added to the front of a form where a line number used to be.
* * match.c: Removed <assert.h>Kaz Kylheku2011-11-133-2/+6
| | | | * txr.c: Likewise.
* Bug #34813Kaz Kylheku2011-11-132-0/+11
| | | | | | * match.c (v_freeform): Fail if the data is null, to avoid a false positive match as an empty line, followed by the type error of incrementing a nonexistent data line number.
* * parser.y: Correctly record line number info for regex.Kaz Kylheku2011-11-122-1/+5
|
* Improved line number reporting in errors and debug traces.Kaz Kylheku2011-11-122-33/+28
| | | | | | | | * match.c (debugf): Function removed. (dest_bind, v_output, v_eof): Use debuglf instead of debugf, and sem_error instead of uw_throwf. (match_files): Likewise, and file_err is called with form.
* Eliminate line numbers from the abstract syntaxKaz Kylheku2011-11-126-243/+301
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tree representation of the TXR query. * match.c (debuglf, sem_error, file_err, eval_form): Line number argument replaced with the form to which the situation pertains. Location information is pulled from the hash table entry associated with the form. (dest_set, dest_bind, eval_form, vars_to_bindings): Context argument renamed since it isn't a line number. (struct match_line_ctx): spec_lineno member removed. (ml_all, ml_bindings_specline): lineno parameter removed. (LOG_MISMATCH, LOG_MATCH, h_var, h_skip, h_coll, h_parallel, match_line): Pass elem to debuglf instead of line number. as context. (h_trailer, h_eol): define elem for LOG_MISMATCH and LOG_MATCH macros. (h_fun): Pass elem variable to debuglf instead of line number. Body stored as a simple cons cell once again (no line number). (do_output_line): Line number parameter removed. Pass specline to sem_error instead of line number. (do_output): Adjusted for one less parameter in do_output_line. (mf_from_ml): Pass one less parameter to ml_all. Conversion of specline to spec is just a wrapping into a nested list, with no line number. (spec_bind): Linenumber variable parameter removed from macro. Definition simplified. (v_skip): Pass specline to debuglf instead of spec_linenum, which is no longer computed. (v_trailer): Use new definition of specline. Pass first_spec to sem_error instead of spec_linenum. Computation of ff_specline no longer has to skip line number. (v_freeform, v_block, v_accept_fail, v_next, v_parallel, v_gather, v_collect, v_merge, v_bind, hv_trampoline, v_cat, v_output, v_try, v_defex, v_throw, v_deffilter, v_filter, match_funcall): Use new definition of specline. Pass first_spec to sem_error instead of spec_linenum. (v_forget_local): Specline computed differently since there is no linenumber to skip. (h_define): Back to implified representation of function with no extra cell for line number. (v_define, v_fun): Pass first_spec to sem_error instead of spec_linenum. Back to implified representation of function with no extra cell for line number. (match_files): first_spec_item computed differently. Pass first_spec to sem_error instead of spec_linenum. * parser.h (source_loc): Declared. * parser.l (source_loc): New function. * parser.y:x (grammar): Removed line numbers from abstract sytnax tree. A few more places needed the annotation of forms with location info, and a couple of cases of the need to propagate the info was
* Infrastructure for storing line number informationKaz Kylheku2011-11-1212-82/+299
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | outside of the code, in hash tables. * filter.c (make_trie, trie_add): Update to three-argument make_hash. * hash.c (struct hash): New members, hash_fun, assoc_fun acons_new_l_fun. (ll_hash): Renamed to equal_hash. (eql_hash): New static function. (cobj_hash_op): Follows ll_hash rename. (hash_grow): Use new function indirection to call hashing function. (make_hash): New argument to specify type of hashing. Initialize new members of struct hash. (gethash_l, gethash, remhash): Use function indirection for hashing and chain search and update. (pushhash): New function. * hash.h (make_hash): Declaration updated with new parameter. (pushhash): Declared. * lib.c (eql_f): New global variable. (eql, assq, aconsq_new, aconsq_new_l): New functions. (make_package): Updated to new three-argument make_hash. (obj_init): gc-protect and initialize new variable eql_f. * lib.h (eql, assq, aconsq_new, aconsq_new_l): Declared. * match.c (dir_tables_init): Updated to there-argument make_hash. * parser.h (form_to_ln_hash, ln_to_forms_hash): Global variables declared. * parser.l (form_to_ln_hash, ln_to_forms_hash): New global variables. (grammar): Set yylval.lineno for tokens that are classified to that type in parser.y. (parse_init): Initialize and gc-protect new global variables. * parser.y (rl): New static helper function. (%union): New member, lineno. (ALL, SOME, NONE, MAYBE, CASES, CHOOSE, GATHER, AND, OR, END, COLLECT, UNTIL, COLL, OUTPUT, REPEAT, REP, SINGLE, FIRST, LAST, EMPTY, DEFINE, TRY, CATCH, FINALLY, ERRTOK, '('): Reclassified as lineno type. In the grammar, these keywords can thus provide a stable line number from the lexer. (grammar): Numerous rules updated to add constructs to the line number hash tables via the rl helper. * dep.mk: Updated. * Makefile (depend): Use the installed, stable txr in the system path to update dependencies rather than locally built ./txr, to prevent the problem that txr is broken because out out-of-date dependencies, and thus cannot regenerate dependencies.
* Bug #34799: errors in horizontal functionsKaz Kylheku2011-11-102-6/+21
| | | | | | | | | | | reported to caller line number. * match.c (ml_bindings_specline): Extended with extra argument (h_coll): Pass nil for new argument of ml_bindings_specline. (h_fun): Extract line number from stored function. Pass line number to ml_bindings_specline. (h_define, v_define): Store function as a cons cell containing the line number and body.
* * txr.1: Document -l/--lisp-bindings.Kaz Kylheku2011-11-102-0/+7
|
* * match.c (opt_nobindings, opt_arraydims): GlobalKaz Kylheku2011-11-105-17/+44
| | | | | | | | | | | | | | | | | variables moved from parser.l. (opt_lisp_bindings): New variable. (dump_bindings): Dump Lisp syntax bindings on standard output if opt_lisp_bindings is set. (v_cat): Do not complain about trailing material; this is not compatible with horizontal cat. * parser.l (opt_nobindings, opt_arraydims): Moved to match.c. * txr.c (txr_main): New options, --lisp-bindings and the equivalent -l. * txr.h: opt_lisp_bindings declared.
* Task #11583Kaz Kylheku2011-11-102-0/+16
| | | | | | | * match.c (dir_tables_init): Mapping flatten_s, forget_s, local_s, merge_s, set_s, cat_s and filter_s to hv_trampoline function, thereby making all these directives work in horizontal contexts in one fell swoop.
* Task #11583Kaz Kylheku2011-11-102-7/+27
| | | | | | | | | More generic approach. * match.c (h_bind): Function removed. (hv_trampoline): New function. (dir_tables_init): hv_trampoline installed in h_directive_table instead of h_bind.
* * parser.l: Fixed wrong error message.Kaz Kylheku2011-11-102-1/+5
|
* * match.c (v_fun): Bugfix: if there is material afterKaz Kylheku2011-11-103-20/+53
| | | | | | | the function call, decline it; it is a horizontal context. * txr.1: Discussion and examples of calls that are in a horizontal context.
* Minor.Kaz Kylheku2011-11-091-1/+1
|
* * txr.1: Documented horizontal function definitions and callsKaz Kylheku2011-11-092-37/+129
|
* Task #11583Kaz Kylheku2011-11-092-0/+28
| | | | | | | @(bind) in horizontal mode. * match.c (mf_from_ml, h_bind): New functions. (dir_tables_init): h_bind entered into table.
* * match.c (h_fun, v_fun): Slightly more informative tracing from failedKaz Kylheku2011-11-092-2/+7
| | | | function calls.
* * txr.vim: Missing coll keyword added.Kaz Kylheku2011-11-092-1/+5
|
* Task #11431. First cut at horizontal match functions.Kaz Kylheku2011-11-083-25/+171
| | | | | | | | | | | | | | * match.c (h_fun): New function. (match_line): Rearranged not to do hash lookup if the directive is a regex or list. If hash lookup fails, try it as a horizontal function. (h_define): New function. Handles horizontal function syntax embedded in line. (v_define): Handle the horizontal function syntax occuring on a line by itself. The function info is now stored as a cons cell whose car is the vertical function and cdr the horizontal one. (v_fun): Adjust to new function storage convention. (dir_tables_init): h_define entered in table. * parser.y: Added syntax for horizontal define.
* * txr.vim: Make sure whitespace is recognized after @.Kaz Kylheku2011-11-062-4/+8
|
* Task #11581 & bugfix.Kaz Kylheku2011-11-063-5/+73
| | | | | | | | | | | | * match.c (noval_s): New symbol variable. (vars_to_bindings): Use a default value of noval_s to indicate a required variable, rather than nil, which would not allow an optional variable with a default value of nil. (h_coll, v_collect): Check default value against noval_s, rather than nil. (v_gather): Support :vars keyword. (syms_init): Initialize new symbol variable. * txr.1: Documented gather's :vars parameter.
* Task #11581Kaz Kylheku2011-11-067-5/+171
| | | | | | | | | | | | | | | | | * match.c (gather_s): New keyword variable. (v_gather): New function. (syms_init): gather_s initialized. (dir_tables_init): v_gather entered into table. * match.h (gather_s): Declared. * parser.l: GATHER token scanning added. * parser.y: GATHER token added. gather_clause nonterminal added. * txr.1: New directive documented. * txr.vim: gather keyword introduced.
* * lib.c (env): Fixed inappropriate cut-and-pasted error messages.Kaz Kylheku2011-11-052-3/+15
| | | | | Check for failure of GetEnvironmentStringsW, and call FreeEnvironmentStringsW is called.
* * match.c (dir_tables_init): Bugfix: horizontal @(some)Kaz Kylheku2011-11-052-0/+6
| | | | directive not included in dispatch table.
* * configure: Bugfixes. Before the compiler tests, we mustKaz Kylheku2011-11-052-0/+15
| | | | | | | remove the conftest executable, to make sure that the next test will try to re-make it. The configure runs fast enough that the new conftest.c does not always have a timestamp which is newer than previous conftest executable.
* Added #define NOMINMAX so <windows.h> since we have our own macros.Kaz Kylheku2011-11-051-0/+1
|
* Task #11442. Make work on MingW.Kaz Kylheku2011-11-053-4/+69
| | | | | | | * configure: Test for environ and GetEnvironmentStrings. * lib.c: Conditionally include <windows.h>. (env): Implemented for POSIX and Windows with #ifdefs.
* Task #11442. Access to environment variables.Kaz Kylheku2011-11-055-10/+68
| | | | | | | | | | | | | | * lib.c (env_list): New static variable. (env): New function. (match): Declaration of nonexistent function removed. (obj_init): New variable gc-protected. * lib.h (env): Declared. * match.c (env_k): New symbol variable. (v_next): Implemented :env. * txr.1: @(next :env) described.
* * hash.c (ll_hash): Added a break in the case that handlesKaz Kylheku2011-11-042-0/+7
| | | | | pointer hashing of identity-equal objects. Without this, if the pointer size is not 4 or 8, we fall through to the next case.
* * txr.c (help): Change year from 2009 to 2011.Kaz Kylheku2011-11-042-1/+5
|
* * tests/008/students.txr: Use disciplined collect with :vars.Kaz Kylheku2011-11-032-4/+5
|
* * tests/008/students.txr: Regexes removed.Kaz Kylheku2011-11-032-2/+6
|
* * txr.vim: Character literals.Kaz Kylheku2011-11-031-4/+6
|
* * txr.vim: Eliminated useless skip arguments from several regions.Kaz Kylheku2011-11-021-3/+3
|
* * txr.vim: Highlight variables inside directives and lists.Kaz Kylheku2011-11-021-2/+4
| | | | Also, highlight embedded metalists as regions.
* * txr.vim: Added missing keywords.Kaz Kylheku2011-11-022-2/+9
|
* * genman.txr: Use filter for mapping month digits to names.Kaz Kylheku2011-11-012-38/+14
| | | | Added comment about where to find the right man2html.
* * txr.vim: Added installation instructions.Kaz Kylheku2011-11-012-0/+15
|
* Syntax highlighting for Vim.Kaz Kylheku2011-11-012-0/+54
| | | | * txr.vim: New file.
* Version 041txr-041Kaz Kylheku2011-10-304-4/+49
|
* We don't include headers in headers in this project.Kaz Kylheku2011-10-304-3/+11
| | | | | | | | * parser.h: Do not include <stdio.h> * regex.c: Include <limits.h> * regex.h: Do not include <limits.h>
* Bug #34691Kaz Kylheku2011-10-302-227/+220
| | | | | | | | | | | | | | | | Changing the parameter passing convention for vertical directives. They take one parameter which is a pointer, rather than a copy of the structure. They do not have to perform a structure assignment when returning next_spec_k. * match.c (v_match_func): Typedef updated to new function signature. (v_skip, v_trailer, v_freeform, v_block, v_accept, v_accept, v_next, v_parallel, v_collect, v_flatten, v_forget, v_forget, v_merge, v_bind, v_set, v_cat, v_output, v_define, v_try, v_defex, v_throw, v_deffilter, v_filter, v_eof, v_fun): Refactored. (match_files): Updated dispatch logic to new style calls. (match_funcall): Updated to new way of calling v_fun.
* * HACKING: Grammar fixes. Expanded on lazy strings a little bit.Kaz Kylheku2011-10-292-35/+74
| | | | | Added something about mem_t *, and a few extra words here and there, including a blurb about a Valgrind debugging caveat.
* Bug #34657Kaz Kylheku2011-10-272-12/+64
| | | | | | * txr.1: Added explanations about the differences between empty streams and empty lines, and to watch out when passing empty strings to @(next :string ...).
* Bugfix: prepared_error_message variable needs to be gc-protected.Kaz Kylheku2011-10-264-1/+18
| | | | | | | | | * parser.h (parse_init): Declared. * parser.l (parse_init): New function. * txr.c (main): Call parse_init. (txr_main): No need to gc-protect yyin_stream since parse_init does it.
* Parse error handling improvements.Kaz Kylheku2011-10-265-65/+141
| | | | | | | | | | | | | | | | | | | | | | | | * parser.l (prepared_error_message): New static variable. (yyerror): Emit and clear prepared error message. (yyerrprepf): New static function. (yybadtoken): Function moved into parser.y. (grammar): For irrecoverable lexical errors, stash error message with yyerrprepf and return the special error token ERRTOK to generate a syntax error. I could find no other interface to the parser to make it cleanly exit. * parser.y (ERRTOK): New terminal symbol, does not appear anywhere in the grammar. (spec): Bail after 8 errors, recover to nearest newline, and use yyerrok to clear error situation. (YYEOF): Provided by Bison, conditionally defined for other yacc-s. (yybadtoken): Function moved from parser.l. Checks for the next token being YYEMPTY or YYEOF, and also handles ERRTOK. * stream.c (vformat_to_string): New function. (format): If stream is nil, format to string and return it. * stream.h (vformat_to_string): Declared.
* * match.c (v_cat): Bugfix: unterminated variable argument list.Kaz Kylheku2011-10-263-2/+8
| | | | * tests/001/query-3.txr: Updated to new cat syntax.