| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
replacement text.
* filter.c (build_filter_from_list): Allow tuples to denote
multiple keys mapping to the same value.
* lib.c (do_curry_123_2, do_curry_123_1): New static functions.
(curry_123_2, curry_123_1): New functions.
* lib.h (curry_123_2, curry_123_1): New functions declared.
* match.c (v_deffilter): Allow tuples of strings rather than
just pairs.
* txr.1: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* filter.c (filter_equal): Takes two filters instead of one.
(lfilt_k, rfilt_k): New keyword variables.
(filter_init): New keyword variables initialized.
* filter.h (filter_equal): Declaration updated.
(lfilt_k, rfilt_k): Declared.
* lib.c (funcall4): New function.
(do_curry_1234_34): New static function.
(curry_1234_34): New function.
(do_swap_12_21): New static function.
(swap_12_21): New function.
* lib.h (funcall4, curry_1234_34, swap_12_21): Declared.
* match.c (dest_bind): Swap use the function argument swapping
combinator when calling tree find such that the value
being searched is on the left and pattern material is on the right.
(v_bind): Implemented :lfilt and :rfilt.
* txr.1: Documented :lfilt and :rfilt.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* filter.c (filter_equal): New function.
(upcase_k, downcase_k): New keyword variables.
(filter_init): New keyword variables initialized,
and new upcase and downcase filters registered.
* filter.h (filter_equal): Declared.
* lib.c (tree_find): Takes new argument, the equality test function.
(upcase_str, downcase_str): New functions.
(do_curry_123_23): New static function.
(curry_123_23): New function.
* lib.h (tree_find): Declaration updated.
(upcase_str, downcase_str, curry_123_23): Declared.
* match.c (dest_bind): Updated to take equality function.
Uses it and passes it down to tree_find.
(v_bind): Filter feature implemented.
(h_var, v_try): Add equal_f to dest_bind argument list.
* txr.1: Updated to describe new filters and bind arguments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
library, allow output to be captured as a list of strings
representing lines (in contrast to string streams which capture
a single string).
The output directive can output to a variable,
and next can scan over a variable.
* lib.c (span_str, compl_span_str, break_str): New functions.
* lib.h (span_str, compl_span_str, break_str): New functions declared.
* match.c (into_k, var_k): New keyword variables.
(mf_file_data): New static function.
(v_next): Refactored argument handling. Added support for :var
keyword.
(v_output): Added support for :into keyword.
* stream.c (strlist_mark, strlist_out_put_string,
strlist_out_put_char): New static functions.
(strlist_out_ops): New static struct.
(make_strlist_output_stream, get_list_from_stream): New functions.
* stream.h (make_strlist_output_stream, get_list_from_stream): New
functions declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
functions.
* lib.h (proper_plist_to_alist, improper_plist_to_alist): New
functions declared.
* match.c (append_k): New keyword symbol variable.
(complex_open): New append argument.
(v_output): Streamlined parsing of keywords.
Support :append keyword.
* txr.1: Output directive's keyword documentation revised.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Vertical skip directive moved into function dispatched
via hash table. Test suite passes.
* lib.c (cptr_s): New symbol variable.
(cptr_equal_op): New static function.
(cptr_equal_op, cptr, cptr_get): New functions.
(cptr_ops): New static structure.
(obj_init): New variable initialized.
* lib.h (cptr_s, cptr, cptr_get): Declared.
* match.c (decline_k, same_data_k): New symbol variables.
(v_match_func): New typedef.
(v_skip): New function.
(match_files): Check symbol in v_directive_table and dispatch
the associated function if an entry exists.
Skip directive handling moved to v_skip function.
(syms_init): Initialize new symbol variables.
(dir_tables_init): Enter v_skip into v_directive_table under
skip_s symbol.
|
|
|
|
|
|
|
|
|
| |
* lib.h (wli): This macro now does the pointer displacement by 1.
(auto_str, static_str): #if/#else/#endif gone. These functions just
add the type tag. The + 1 logic was incorrect; it should have
been + sizeof(wchar_t). But even that was not right because other
code expects a wchli_t * to point to the first character,
such as the string_out_put_char function.
|
|
|
|
|
|
|
| |
* lib.h (wini, wref): New macros.
* stream.c (string_out_put_char): Rewritten with macros to eliminate
preprocessor #if test.
|
|
|
|
|
|
|
| |
so that this hack is correct for null strings. When recovering
the wchar_t pointer from a null literal object, we wil increment
unconditionally, since it always points to a null character.
We end up skipping past null terminator #1, but safely landing on #2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* filter.c (struct filter_par): wchar_t becomes wchli_t.
* lib.h (wchli_t): New type: an incomplete structure type,
so that a pointer to this type is incompatible with anything else.
(wli): Macro produces const wchli_t * pointer instead of
const wchar_t *.
(auto_str, static_str): Accept a const wchli_t * instead
of const wchar_t *, making it impossible to misuse these
functions by passing in a literal.
* stream.c (string_out_put_char): These type changes showed
this hack to have a bug. Confronted with the need to cast
from const wchar_t * to const wchli_t *, it's obvious that
the conversion has to be done properly with the + 1 in the
one platform case, but not the other.
* txr.c (version): Type changed to const wchli_t.
* txr.h (version): Declaration updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TODO: there should be some type safety with the new wli macro
so that if it is forgotten, there will be a diagnostic.
* configure (lit_align): New configuration variable
and configuration test. Generates LIT_ALIGN in config.h.
Fixed the integer-holds-pointer test for the different output
from the nm program on Cygwin. The arrays become common symbols
marked C which do not show an offset attribute, only size:
one less column.
* filter.c (to_html_table, from_html_table): wrap wide string
literals with the wli macro. This must be done from now on for
all literals and initializes of arrays that are going to be
directly converted to type tagged val-s.
* lib.h (wli): New macro.
(auto_str, static_str, litptr, lit_noex): Handle wide literals on
platforms where they are aligned to only two bytes, such that we don't
have two bits in the pointer. We can still add our 11 bit type tag, but
then when recovering the pointer to the data, we have may have
to fix up the pointer.
* parser.l: Another portability issue here. Flex generates a scanner
which has #include <unistd.h> in the middle, after the source file's
own #includes which can introduce macros. On Cygwin, there is some
hygiene problem whereby our "noreturn" macro causes the <unistd.h>
header to generate bad syntax and fail to compile. Stupid Cygwin
and even stupider flex! The workaround is to include <unistd.h>
at the top in the flex source.
* stream.c (string_out_put_char): This is one more place where
the string literal handling hack spreads.
* txr.c (version): Wrap string in wli.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(obj_init): New variable initialized.
* lib.h (eol_s): Declared.
* match.c (match_line): Implemented horizontal skip as and
new eol directive.
(match_lines): Vertical skip defers to horizontal skip if
there is trailing material.
* txr.1: Updated.
* lib.c (eol_s): New symbol variable.
(obj_init): New variable initialized.
* lib.h (eol_s): Declared.
* match.c (match_line): Implemented horizontal skip as and
new eol directive.
(match_lines): Vertical skip defers to horizontal skip if
there is trailing material.
* txr.1: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
nested lists. This is in anticipation of future features.
* lib.c (expr_s): New symbol variable.
(obj_init): expr_s initialized.
* lib.h (expr_s): Declared.
* match.c (dest_bind): Now takes linenum. Tests for the meta-syntax
denoted by the system symbols var_s and expr_s, and throws an
error.
(eval_form): Similar error checks added. Also, hack: do not add
file and line number to an exception which begins with a '('
character; just re-throw it. This suppresses duplicate line
number addition when this throw occurs across some nestings.
(match_files): Updated calls to dest_bind.
* parser.l (yybadtoken): Handle new token kind, METAVAR and METAPAR.
(grammar): Refactoring among patterns: TOK broken into
SYM and NUM, NTOK introduced, unused NUM_END removed.
Rule for @( producing METAPAR in nested state.
* parser.y (METAVAR, METAPAR): New tokens.
(meta_expr): New nonterminal.
(expr): meta_expr and META_VAR productions handled.
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (bind2): Function renamed to curry_12_2.
(bind2other): Function renamed to curry_12_1.
(do_bind_2, do_bind2other): Helpers renamed likewise.
(tree_find): Follows rename of bind2.
* match.c (match_files): deffilter code follows bind2 rename
to curry_12_2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(do_curry_123_2): New static function.
* lib.h (funcall3, curry_123_2): Declared.
* match.c (subst_vars): Bugfix: throw error on unbound variable instead
of ignoring the situation. This bug caused unbound variables in
quasiliterals to be silently ignored.
(eval_form): Function changed to three argument form, so that
it takes a line number for reporting errors. Restructured to catch
the new unbound variable exception from subst_vars, and re-throw
it with a line number. Also, throws exception now instead of returning
nil if itself it detets an unbound variable. Uses of eval_form
no longer have to test the return value for nil, but just assume
it worked.
(match_lines): Currying calls to eval form updated to use
curry_123_2. Test of eval return value eliminated. In function
calls, eval isn't used for reducing symbol arguments to values,
because it now throws in the unbound case, and it's not worth
setting up a catch for this. Instead, assoc is used directly.
|
|
|
|
|
|
| |
hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y,
regex.c, regex.h, stream.c, stream.h, txr.1, txr.c, txr.h, unwind.c,
unwind.h, utf8.c, utf8.h: Updated e-mail address.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
* 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!)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
(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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
lib.h, match.c, match.h, parser.h, parser.l, parser.y, regex.c,
regex.h, stream.c, stream.h, txr.1, txr.c, txr.h, unwind.c, unwind.h,
utf8.c, utf8.h: Updated copyright year.
|
| |
|
|
|
|
|
|
|
|
| |
* lib.c (split_str, split_str_set): It is necessary to protect input
parameters against GC, because we cache their internal pointers,
after which we no longer refer to the objects themselves. Moreover,
we perform object allocation, and then keep using the internal
pointers.
|
|
|
|
|
|
|
|
|
| |
* lib.c (split_str_sep): New function.
(split_str): Semantics changed; the second argument
is not a set of separator characters (like in split_str_sep)
but rather a separator string. Fixed bug: if the input
string is empty, the output list is empty. This caused
infinite looping behavior in @(freeform).
|
|
|
|
|
|
|
|
| |
Exponential memory consumption behavior was observed when
matching the input aaaaaa....
against the regex a?a?a?a?....aaaa....
The fix is to eliminate common subexpressions
from the derivative for the or operator.
|
| |
|
| |
|
| |
|
|\
| |
| |
| |
| | |
Conflicts:
ChangeLog
|
| |
| |
| |
| |
| |
| |
| |
| | |
in the middle of statement block.
* lib.h (TAG_MASK): Becomes type cnum rather than long.
(nao): Based off 1 rather than -1 to avoid left shift of
negative number.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This turns out to be easy to do in NFA land.
The complement of an NFA has exactly the same number
and configuration of states and transitions, except
that the states have an inverted meaning; and furthermore,
failed character transitions are routed to an extra
state (which in this impelmentation is permanently
allocated and shared by all regexes). The regex &
is implemented trivially using DeMorgan's.
Also, bugfix: regular expressions like A|B|C are allowed
now by the syntax, rather than constituting syntax error.
Previously, this would have been entered as (A|B)|C.
|
|
|
|
|
|
|
|
| |
* hash.h (sethash): Declared.
* lib.c (cobj_handle): New function.
* lib.h (cobj_handle): Declared.
|
|
|
|
|
|
| |
no null pointer check over struct cobj_ops operations.
New typechecking function for COBJ objects.
|
|
|
|
|
| |
from now on, which is compatible with unsigned char *.
No implicit conversion to or from this type, in C or C++.
|
|
|
|
| |
in regex module not exposed in header. Etc.
|
|
|
|
|
|
|
|
| |
to vector data; they point to element 0 which is actually the third
element of the vector. If an object is only referenced by interior
pointers, Valgrind reports it as possibly leaked. This change
conditionally adds a pointer to the true start of the vector,
if Valgrind support is enabled.
|
| |
|
| |
|
|
|
|
|
| |
Allow compiler command to be set independently of full path
for easier compiler switching.
|
|
|
|
| |
can be taken advantage of for better diagnostics.
|
|
|
|
| |
have a _s suffix.
|
|
|
|
|
|
|
|
| |
can be converted to a type long and vice versa. The configure
script tries to detect the appropriate type to use. Also,
some run-time checking is performed in the streams module
to detect which conversions specifier strings to use for
printing numbers.
|
|
|
|
|
|
|
|
|
|
| |
a system package instead of being hacked with the $ prefix.
Keyword symbols are provided. In the matcher, evaluation
is tightened up. Keywords, nil and t are not bindeable, and
errors are thrown if attempts are made to bind them.
Destructuring in dest_bind is strict in the number of items.
String streams are exploited to print bindings to objects
that are not strings or characters. Numerous bugfixes.
|