summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* * lib.c (acons): New function.Kaz Kylheku2011-10-044-16/+46
| | | | | | | | | | | | | | | | | (set_diff): Optimize common case: list1 and list2 are the same, or list2 is substructure of list1. Situations in which this won't be the case for variable bindings are rare. * lib.h (acons): Declared. * match.c (match_line): Use acons rather than acons_new, when binding variables that we know are new (the symbol is unbound). When computing the set difference over bindings, use cons cell equality, rather than symbol equality. Symbol equality is wrong because a binding can be removed, and then a new binding can be introduced using the same symbol. This must be treated as a different binding.
* Bugfixes to the semantics of binding environments, whichKaz Kylheku2011-10-044-34/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | were broken in the face of deletions (local, forget). For some stupid reason, I had written a destructive routine for removing elements from an association list, and used it as the basis for the local and forget directives. * lib.c (eq_f, car_f): New variables. (identity_tramp, equal_tramp): Obsolete functions removed. (apply): Broken function disabled at run time. (funcall, funcall1, funcall2): Throw meaningful error instead of aborting. (alist_remove_test): New static function. (alist_remove, alist_remove1): Rewritten to be functional rather than destructive. (alist_nremove, alist_nremove1): Destructive functions, using previous implementations of alist and alist_nremove. (do_sort): Recurses directly rather than via sort. That was probably why this helper was introduced! (find, set_diff): New functions. (obj_init): gc-protect new variables eq_f and car_f, and initialize them. Initializations for equal_f and identity_f changed to use equal and identity directly, without the obsolete wrappers. * lib.h (eq_f, car_f, alist_nremove, alist_nremove1, find, set_diff): Declared. * match.c (match_line): Use set_diff to determine what bindings are new, rather than ldiff and ldiff-like logic which break when the new bindings do not share structure with the old. (match_files): Likewise.
* * txr.1: Starte dodcumenting the forgotten merge directive.Kaz Kylheku2011-10-032-0/+28
|
* Implemented new last clause for collect and coll.Kaz Kylheku2011-10-036-33/+138
| | | | | | | | | | | | | | | | | | | | Bugfix in cases inside coll: was not collecting bindings. Bugfix for until inside coll: was not seeing bindings from main clause. * lib.c (ldiff): New function. * lib.h (ldiff): Declared. * match.c (match_line): Implemented last clause. Fixed cases handling by moving misplaced termination check. (match_files): Implemented last clause. * parser.y (until_last): New nonterminal symbol. (collect_clause): Refactored syntax to support until and last. (elem): Likewise. * txr.1: Updated.
* * parser.y (rep_elem): Bugfix: forgotten o_elems_transform ontxr-038Kaz Kylheku2011-10-022-1/+9
| | | | | syntax tree of o_elems constituent, leading to problems with consecutive variables in a @(rep).
* * match.c (match_line): Handle trailer_s directive.Kaz Kylheku2011-10-022-5/+19
| | | | | | (match_files): Remove check against trailer_s not having trailing material. If it doesn't, it's a vertical directive processed here, otherwise leave it alone so match_line processed it.
* Compiles as C++ again.Kaz Kylheku2011-10-023-6/+31
| | | | | | | | | | | * lib.h (cons_set): New macro. * match.c (match_line, match_files): In collect clause handlers, move variable declarations above goto, and initialize with cons_set, instead of declaring and initializing with cons_bind. This eliminates the stupid C++ error that goto skips a variable initialization (which happens even when it can be trivially proven that the has no next use at the goto site!)
* Spelling.Kaz Kylheku2011-10-011-1/+1
|
* Version 038Kaz Kylheku2011-10-014-4/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New eof directive. Fixes in skip directive to work very well with eof. Consecutive variable matching semantics improved; concept of double variable match introduced for unbound variable followed by regex variable. Directives collect and coll have keyword arguments for more control over their behavior. Paralle directives (all, some, none, ...) are available in horizontal mode. New choose directive for selecting one of numerous alternatives GC bugfix in new filtering code. The code has an issue compling with GNU C++ instead of C, which is something that is supported by this project. Not a release-blocking issue. Not easy to fix without restructuring some code. * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped.
* Maintaining C++ compiling (except for two issues that willKaz Kylheku2011-10-015-16/+34
| | | | | | | | | | | | | | | | need another commit). * filter.c: Include "gc.h" for prototype of protect. (struct filter_pair): Use const wchar_t *, so we can assign literals. (html_hex_continue): Ditto. * lib.c (and): Function renamed to andf, since and is a C++ operator. * lib.h (and): Declaration renamed. * match.c (match_files): Use of and updated to andf.
* HACKING: Clarified that --vg-debug is also needed to turn on onKaz Kylheku2011-10-012-2/+9
| | | | the Valgrind support at run-time, in addition to building it in.
* Added missing data.Kaz Kylheku2011-10-011-0/+6
|
* New test case, covering some filtering from HTML/XML.Kaz Kylheku2011-10-015-0/+42
| | | | | | | | * Makefile: Defined TXR_ARGS for new test case. * tests/008/students.expected: New file. * tests/008/students.txr: New file. * tests/008/students.xml: New file.
* * filter.c (filters, filter_init): Serious gc bug fixed: neglected toKaz Kylheku2011-10-012-0/+8
| | | | | inform the garbage collector about the filters global variable. Ouch!
* New test case under tests/008.Kaz Kylheku2011-10-015-1/+72
| | | | | | | | | | | | * Makefile: Made previous TXR_ARGS for 008 specific to tokenizing test case, and introduced separate TXR_ARGS for this test case. * tests/008/configfile: New file. * tests/008/configfile.expected: New file. * tests/008/configfile.txr: New file.
* Deleted reference to accidentally added file.Kaz Kylheku2011-10-011-1/+0
|
* Remove accidentally added .out file.Kaz Kylheku2011-10-011-2/+0
|
* Tokenizing test case, exercising for @(coll :gap 0)Kaz Kylheku2011-10-015-0/+40
| | | | | | | | | | and horizontal @(choose :shortest ...). * Makefile: Defined TXR_ARGS for tests/008 directory. * tests/008/data: New file. * tests/008/tokenize.expected: New file. * tests/008/tokenize.txr: New file.
* New test case, covering exception handling across nestedKaz Kylheku2011-10-015-1/+48
| | | | | | | | | | function invocations. * Makefile (TEST): Test targets marked as .PHONY, because they are. * tests/007/except-1.expected: New file. * tests/007/except-1.out: New file. * tests/007/except-1.txr: New file.
* * parser.y (all_clause, some_clause, none_clause, maybe_clause,Kaz Kylheku2011-10-012-12/+18
| | | | | cases_clause, choose_clause, elem): Regression bug fix: bad list calls in parser, lacking nao terminator.
* Merge commit '4afe959'Kaz Kylheku2011-10-013-2/+11
|\ | | | | | | | | | | | | Conflicts: ChangeLog Lost commit.
| * Regression bug fix: longest match variables broken byKaz Kylheku2011-10-013-2/+11
| | | | | | | | | | | | | | | | 2011-09-28 commit which introduced the double var match. * match.c (match_line): Handle case where modifier is t. * parser.y (var_op): Produce modifir as (t) rather than t.
* | * txr.1: Documented choose and horizontal mode for paralleKaz Kylheku2011-10-012-17/+61
|/ | | | constructs.
* New directive: choose.Kaz Kylheku2011-10-015-25/+164
| | | | | | | | | | | | | | | | | | | | | | * match.c (choose_s, longest_k, shortest_k): New variables. (match_line, match_files): Introduced choose directive. (match_init): Initialize new variables. * match.h (choose_s): Declared. * parser.l (yybadtoken): Handle CHOOSE. (CHOOSE): Clause added for returning this token. * parser.y: Added #include "match.h". (CHOOSE): New token symbol. (choose_clause): New nonterminal symbol. (clause): choose_clause added. (all_clause, some_clause, none_clause, maybe_clause, cases_clause): Abstract syntax tree tweaked. (choose_clause): New syntax. (elem): Abstract syntax trees tweaked for many clauses. New CHOOSE clauses. (out_clause): New error case for choose_clause.
* * HACKING: Updated with debugging hints.Kaz Kylheku2011-09-302-4/+214
|
* * txr.1: Clarified consecutive variables and documented doubleKaz Kylheku2011-09-302-10/+29
| | | | variable match.
* * parser.l: Implemented backslash continuations in SPECIALKaz Kylheku2011-09-303-13/+66
| | | | | | state, regexes and string literals. * txr.1: Documented.
* * match.c (match_line): Implemented horizontal all, some,Kaz Kylheku2011-09-293-4/+80
| | | | | | | | | | none, maybe and cases directives. (match_files): Recognize horizontal version of these directives by the presence of the extra symbol t and do not process. Also, bugfix in the all directive: not resetting the all_match flag when short circuiting out. * parser.y (clause_parts_h, additional_parts_h): New nonterminals. (elem): New clauses added.
* * match.c (chars_k): New variable.Kaz Kylheku2011-09-295-38/+92
| | | | | | | | | | | | (match_line): Keyword arguments in coll implemented. (match_init): chars_k variable initialized. * parser.l (COLL): Lexical syntax changed to allow for argument material. * parser.y (elem): Coll syntax rewritten for arguments. * txr.1: Updated.
* * match.c (mingap_k, maxgap_k, gap_k, times_k, lines_k): NewKaz Kylheku2011-09-297-62/+177
| | | | | | | | | | | | | | | | | symbol variables. (match_lines): Keyword arguments in collect implemented. (match_init): New function. * match.h (match_init): Declared. * parser.l (COLLECT): Lexical syntax changed for COLLECT to allow for argument material. * parser.y (%union): obj renamed to val. (exprs_opt): New nonterminal. (collect_clause): Rewritten for arguments. * txr.c (main): Call to match_init introduced.
* * match.c (match_line): Bugfix in double var. Do notKaz Kylheku2011-09-282-2/+9
| | | | prepend the next_pat to the specline if it is nil.
* * match.c (match_line): Logic restructured to allow forKaz Kylheku2011-09-283-38/+126
| | | | | | | | | | | | | | | | | | regex variables which also have nested variables. Previously this code was assuming that the cases were mutually exclusive, and the parser happened to work that way. Also, added support for a "double var" match which occurs when an unbound variable is followed by a regex variable. This case should be allowed because it makes sense. It's similar to a variable followed by a regex, except that the regex is also a variable binding. * parser.y (o_elems_transform): New function. (o_elems_opt, o_elems_opt2, quasilit): Transform o_elems with new function. This is needed because subst_vars doesn't deal with the nested var syntax for consecutive variables. (var): New syntax case '{' IDENT exprs '}' elem. This allows consecutive variables to be nested in all cases.
* * parser.y ('{', '}'): Nope, still not right.Kaz Kylheku2011-09-272-2/+7
| | | | | These must have exactly the same precedence as IDENT for this to work right, of course.
* * parser.y ('{', '}'): Bugfix: precedence of theseKaz Kylheku2011-09-272-1/+10
| | | | | | | terminals was causing @foo@foo to be parsed differently from @foo@{foo}. We need consecutive variables to be specially folded in the syntax under a single var_s node.
* * match.c (match_files): One more fix to this, argh.Kaz Kylheku2011-09-272-8/+22
| | | | | | | | | | | | | The test for !data should be done after matching, before incrementing to the next line. Then it is a true bottom of the loop test. This commit allows @(skip) @first_line @(skip nil 3) @(eof) to correctly match the first line of the input, not the fourth one from the bottom, since the second skip has an unbounded range.
* * match.c (match_files): Another bugfix to skip.Kaz Kylheku2011-09-272-0/+15
| | | | | | | If a hard skip tries to go beyond EOF, then the query must fail. However, a skip to exactly EOF is fine. I.e. data can hit nil at the same time as the right number of skip iterations is performed.
* * match.c (match_files): Bugfix in skip directive.Kaz Kylheku2011-09-272-1/+17
| | | | | | | | | | | | We should try the match at least once even if there is no data after a hard skip, so that the query has an opportunity to do an explicit match for no data, as with @(endp). This commit makes possible queries like: @fourth_line_from_bottom @(skip 1 3) @(eof) This query depends on @(skip 1 3) not failing when it runs out of data, because @(eof) checks for htis.
* * lib.c (eof_s): New symbol variable.Kaz Kylheku2011-09-275-2/+27
| | | | | | | | | | | (obj_init): New variable initialized. * lib.h (eof_s): Declared. * match.c (match_files): New @(eof) directive explicitly matches end of data. * txr.1: Updated.
* Support &#NNNN; decimal escapes also.txr-037Kaz Kylheku2011-09-262-4/+41
| | | | | | | | | * filter.c (html_hex_continue): Bail with nil if no digits are collected. The &#x; syntax is not translated to anything. (html_dec_continue): New function. (html_hex_handler): Function renamed to html_numeric_handler. (filter_init): Change function-based trie node over to html_numeric_handler.
* Support &#xNNNN; hex escapes in html. Bugfix in field formatting.Kaz Kylheku2011-09-265-14/+85
| | | | | | | | | | | | | | | | | | | chr function inlined. * filter.c (trie_value_at, trie_lookup_feed_char): Handle function case. (build_filter): New parameter, compress_p. (html_hex_continue, html_hex_handler): New functions. (filter_init): Add a function-based node to the from_html trie. * lib.c (chr): Function removed. (functionp) New function. * lib.h (chr): Declaration replaced with inline function. (functionp): Declared. * match.c (format_field): Bugfix: failed to apply filter that came in as an argument.
* Version 037.Kaz Kylheku2011-09-264-4/+25
|
* Merge branch 'master' of ssh://kkylheku@git.sv.gnu.org/srv/git/txrKaz Kylheku2011-09-260-0/+0
|\
| * Bugfixeses: Consistent escaping in various literals. DoubleKaz Kylheku2011-09-262-6/+12
| | | | | | | | | | | | | | | | | | | | backslash codes for single backslash. Output clause can be empty. * parser.l (char_esc): Backslash handled. Use internal_error rather than abort. (REGCHAR, LITCHAR): Backslash added to lexical syntax. * parser.y (output_clause): Allow empty output clause.
* | Bugfixes: Consistent escaping in various literals. DoubleKaz Kylheku2011-09-263-6/+23
|/ | | | | | | | | | backslash codes for single backslash. Output clause can be empty. * parser.l (char_esc): Backslash handled. Use internal_error rather than abort. (REGCHAR, LITCHAR): Backslash added to lexical syntax. * parser.y (output_clause): Allow empty output clause.
* New feature: @(deffilter)Kaz Kylheku2011-09-267-15/+210
| | | | | | | | | | | | | | | | | | | | | | | | | | Bugfix in @(throw) when non-symbol is thrown: exception message referred to the symbol throw rather than the erroneous object. * filter.c (build_filter_from_list, register_filter): New functions. * filter.h (register_filter): New function declared. * lib.c (deffilter_s): New variable defined. (chain): Function changed from single list argument to variable argument list to reduce the complexity of use. (do_and, and): New functions. (obj_init): deffilter_s initializatio added. * lib.h (deffilter_s, and): New declarations. (chain): Declaration updated to new function signature. (eq): Changed from macro to inline function. * match.c (do_output_line): Simplified expression involving chain. (do_output): Likewise. (match_files): Bugfix in error handling of throw. Implementation of deffilter. * txr.1: Documented deffilter.
* Trie compression. Hash table iteration.Kaz Kylheku2011-09-268-16/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bugfix in typeof. * filter.c (trie_compress): New function. (trie_value_at, trie_lookup_feed_char, filter_string): Handle cons cell nodes in trie. (build_filter): Call trie_compress. * gc.c (cobj_destroy_op): Function renamed to cobj_destroy_stub_op since it doesn't do anything. (cobj_destroy_free_op): New function. * hash.c (struct hash_iter): New type. (hash_destroy): Function removed. (hash_ops): Reference to hash_destroy replaced with cobj_destroy_free_op. (hash_count, hash_iter_mark, hash_begin, hash_next): New functions. (hash_iter_ops): New static structure. * hash.h (hash_count, hash_begin, hash_next): New functions declared. * lib.c (hash_iter_s): New symbol variable. (typeof): Bugfix: TAG_LIT type tag not handled. (vecref): New function. (obj_init): Initialize hash_iter_s. * lib.h (cobj_destroy_op): Declaration renamed. (cobj_destroy_free_op, vecref): New functions declared. (hash_iter_s): New variable declared. * stream.c (string_in_ops, byte_in_ops): cobj_destroy_op renamed to cobj_destroy_stub_op.
* Documented :from_html.Kaz Kylheku2011-09-251-2/+2
|
* Filtering from HTML implemented.Kaz Kylheku2011-09-253-12/+280
| | | | | | | * filter.c (from_html_k): New variable. (to_html_table): New static array. (filter_init): Intern new symbol. Instantiate new filter and store in filters hash.
* Filtering feature for variable substitution in output.Kaz Kylheku2011-09-2512-46/+505
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * filter.c, filter.h: New files. * Makefile (OBJS): filter.o added. * gc.c (mark_obj): Mark new alloc field of string objets. * hash.c (struct hash): New member, userdata. (hash_mark): Mark new userdata member of hash. (make_hash): Initialize userdata. (get_hash_userdata, set_hash_userdata, hashp): New functions. * hash.h (get_hash_userdata, set_hash_userdata, hashp): New functions declared. * lib.c (getplist, string_extend, cobjp): New functions. (string_own, string, string_utf8): Initialize new alloc field to nil. (mkstring, mkustring): Initialize new alloc field to actual size. (length_str): When length is computed and cached, also compute and cache alloc. (init): Call filter_init. * lib.h (string string): New member, alloc. (num_fast): Macro converted to inline function. (getplist, string_extend, cobjp): New functions declared. * match.c (match_line): Follows change of modifier s-exp syntax. (format_field): New parameter, filter. New modifier syntax parsed. Filter retrieved, and applied. (subst_vars): New parameter, filter. Filter is either applied in this function or passed to format_field, as needed. (eval_form): Pass nil to new parameter of subst_vars. (do_output_line): New parameter, filter. Passed down to subst_vars. (do_output): New parameter, filter. Passed down to do_output_line. (match_files): Pass nil filter to subst_vars in cat directive. Output directive refactored to parse keywords, extract the filter and pass down to do_output. * parser.y (regex): Generate (sys:regex regex syntax ...) instead of (regex syntax ...). (elem, expr): Updated w.r.t. regex syntax change. (var): Cases '{' IDENT regex '}' and '{' IDENT NUMBER '}' are removed. new syntax '{' IDENT exprs '}' to handle these more generally and allow for keywords. * txr.1: Updated.
* Numeric constants become real constants.Kaz Kylheku2011-09-243-16/+28
| | | | | | | | | | | | Vector code cleanup. * lib.h (zero, one, two, negone, maxint, minint): Extern declarations removed, macros introduced for these identifiers. * lib.c (zero, one, two, negone, maxint, minint): File scope definitions removed. (vector): Use vec_alloc and vec_fill enums instead of constants. (obj_init): Remove references to removed definitions.