| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
When a match for the @(last) material occured at the end of data,
c->data was being mistakenly set to nil rather than t before breaking
out of the loop, wreaking havoc.
|
|
|
|
| |
* stream.c (w_opendir): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(dir_tables_init): Register dispatch for repeat to v_collect
function.
* parser.y (collect_repeat): New nonterminal symbol.
(clause): Removed repeat_clause error case because that now clashes
with the syntax in collect_clause.
(collect_clause): Repeat syntax implemented, with help of
collect_repeat.
(out_clause): Error case for collect_clause removed due to
syntactic clash.
* txr.1: Added mention of @(collect :vars nil) and documented
@(repeat) as the shorthand.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
in argument list. Fix is not to rely on the hack of using the first
element of the list of files to hold the name of the current file.
* match.c (match_files_ctx): New member, curfile.
(mf_all): Initialize curfile.
(mf_args): Set curfile to "args".
(mf_file_data): Initialize curfile.
(v_skip, v_fuzz, v_gather, v_collect): Use c->curfile rater than
first(c->files) in debug calls.
(freeform_prepare, match_files): Pass c->curfile to ml_all constructor
of match_line_ctx rather than rather than first(c->files).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
causes CONFIG_GEN_GC to be defined as 1 in config.h.
* eval.c (op_defvar, dwim_loc, op_modplace, transform_op): Handle
mutating assignments via set macro.
(op_dohash): Inform gc about mutated variables. TODO here.
* filter.c (trie_add, trie_compress): Handle mutating assignments
via set macro.
* gc.c (BACKPTR_VEC_SIZE, FULL_GC_INTERVAL): New preprocessor symbols.
(backptr, backptr_idx, partial_gc_count, full): New static variables.
(make_obj): Initialize generation to zero.
(gc): Added logic for deciding between full and partial gc.
(gc_set, gc_mutated): New functions.
* gc.h (gc_set, gc_mutated): Declared.
* hash.c (hash_mark): Changed useless use of vecref_l to vecref.
(gethash_f): Use set when assigning through *found since it
is a possible mutation.
* lib.c (car_l, cdr_l, vecref_l): Got rid of loc macro uses. Using the
value properly is going to be the caller's responsibility.
(push): push may be a mutation, so use set.
(intern): Uset set to mutate a hash entry.
(acons_new_l, aconsq_new_l): Use set when replacing *list.
* lib.h (PTR_BIT): New preprocessor symbol.
(obj_common): New macro for defining common object fields.
type_t is split into two bitfields, half a pointer wide,
allowing for generation to be represented.
(struct any, struct cons, struct string, struct sym, struct package,
struct func, struct vec, struct lazy_cons, struct cobj, struct env,
struct bignum, struct flonum): Use obj_common macro to defined
common fields.
(loc): Macro removed.
(set, mut): Macros conditionally defined for real functionality.
(list_collect, list_collect_nconc, list_collect_append): Replace
mutating operations with set.
* match.c (dest_set, v_cat, v_output, v_filter): Replace
mutating operations with set.
* stream.c (string_in_get_line, string_in_get_char,
strlist_out_put_string, strlist_out_put_char): Replace mutating
operations with set.
* unwind.c (uw_register_subtype): Replace mutating operation with set.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
happen to request a successful termination by invoking @(accept)
the position must not advance into the trailer material.
* match.c (v_trailer): Added an unwind protect which
detects that an accept is taking place and adjusts the return value to
restrict the input position at the point given to trailer.
(accept_fail): Use uw_block_return_proto instead of uw_block_return
and pass the symbol as the protocol identifier.
* unwind.c (uw_current_exit_point): New function.
(uw_block_return): Function renamed to uw_block_return_proto;
takes new parameter which is stored in the block structure.
* unwind.h (struct uw_block): New member, protocol.
(uw_block_return): Becomes an inline wrapper for uw_block_return_proto.
(uw_block_return_proto, uw_current_exit_point): Declared.
* txr.1: Interaction between @(trailer) and @(accept) documented.
|
|
|
|
|
|
|
|
| |
by throwing an exception. Allow nil, but wherever nil occurs,
do not produce a binding.
* txr.1: State the restrictions against using t in the section
on Variables and also describe the nil ignore feature.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For instance given @(bind a ("a" "b" "c")) it is now possible
to do @(filter :upcase a) whereby a promptly takes on the value
("A" "B" "C").
* filter.c (string_filter): Function renamed to string_tree_filter.
(compound_filter): Follows rename.
(filter_string): Function renamed to filter string tree.
Can filter tree of strings, or possibly other objects,
if the filter function allows.
(filter_equal): No special case test for objects that are strings.
Just put them through the filter.
* filter.h (filter_string): Declaration updated.
* match.c (format_field, subst_vars, v_filter): Follow rename.
|
|
|
|
|
|
|
| |
after each @(output) block. Otherwise if output blocks
that go to standard output are interleaved with output blocks
which pipe to some command which then goes to standard out,
the output won't be in the proper order.
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (rebind_s): Declared.
* match.c (v_rebind): New static function.
(dir_tables_init): Registered rebind_s to v_rebind,
and also to hv_trampoline in the horizontal directive table.
* txr.1: Documented it.
|
|
|
|
|
| |
* match.c (syms_init): text_s must be in the system
package because it's not a user-visible operator.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
the regular expression does not match all the way to
the end of the line was getting by the check for
a complete match.
* match.c (do_match_line): Loses the second parameter
named completely. The check whether the line was matched
completely is done higher up, in match_line_completely.
This is needed because do_match_line has some early
successful return cases which bypass the check.
(match_line): Remove second paramter in call to do_match_line.
(match_line_completely): Do the check here that the line
was matched completely. Nothing can get by this.
(v_freeform): Do notpass second nil argument to do_match_line.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
simpler. A pseudo type code is introduced called NIL with value 0.
* lib.h (enum type): New enumeration value, NIL.
(type): Function accepts object nil and maps it to code NIL.
* eval.c (dwim_loc, op_dwim): test for nil obj and goto hack is gone,
just handle NIL in the switch.
* gc.c (make_obj, mark): Handle new NIL type code in switch.
* hash.c (equal_hash): Handle NIL in the switch instead of nil test.
* lib.c (code2type): Map new NIL type code to null.
(typeof, typecheck): Code simplified.
(class_check, car): Move nil test into switch.
(eql, equal, consp, bignump, stringp, lazy_stringp,
symbolp, functionp, vectorp, cobjp): Simplified.
(length, sub, ref, refset, replace, obj_print, obj_pprint): Handle NIL
in switch instead of nil test. goto hack removed from refset.
* match.c (do_match_line, do_output_line): switch condition simplified.
* regex.c (regexp): Simplified.
(regex_nfa): Assert condition simplified.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* txr.c (version): Bumped.
* txr.1: Bumped version and set date.
* configure (txr_ver): Bumped.
* eval.c (op_modplace): Fix warning about uninitialized variable.
No bug.
* filter.c: gcc compilation regresion: missing <stdio.h> breaks inclusion
of "stream.h" header. Strangely, didn't show up when configured for
compiling with g++ on Ubuntu.
* match.c (match_filter): Fixed ununsed variable warning.
* txr.vim: Bunch of missing keywords added.
* dep.mk: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Blocks no longer extend to the end of the surrounding
scope.
* match.c (v_block): Rewrite for new syntax.
* parser.l (BLOCK): New token type handled.
* parser.y (BLOCK): New token.
(block_clause): New nonterminal grammar symbol.
(clause): Collateral fix: replaced a bunch of
list(X, nao) forms with cons(X, nil).
Introduced block_clause as a constituent of clause.
* txr.1: Revamped documentation of block, and
wrote about using blocks for reducing nested
skips and reducing backtracking in general.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
can't ever come out true.
* match.c (search_form, h_var, h_coll, h_parallel, h_fun): Handle
position t emanating from match_line, indicating match to end of line.
(h_skip): When skipping to the end of line (empty spec), just
return t as the position rather than the end of the line. This avoids
calculating the length of the line, which forces a lazy string.
(do_match_line): Near the beginning of the loop, if the position is t,
then substitute the length of the line.
(freeform_prepare): Return the freeform line limit value.
(v_freeform): Check for t coming out of match line and do the
conversion back to the trailing list in that case, but only if
the freeform was limited by number of lines.
|
|
|
|
|
|
|
| |
but match_line returns absolute, and so needs to be offset by -c->base.
(h_trailer, h_fun): Bugfix: return the absolute position, rather than
relative c->pos. The return value of these functions becomes the return
value of do_match_line, so the semantics has to agree.
|
|
|
|
| |
location using source_loc_str rather than raw object using source_loc.
|
| |
|
|
|
|
| |
directives following the load and consume input properly.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
that occur in horizontal matching of basic text patterns.
* lib.c (match_str, match_str_tree): New functions.
* lib.h (match_str, match_str_tree): Declared.
* match.c (do_match_line): Use match_str_tree and match_str when matching
strings and string lists, respectively, rather than stupidly calling
search functions and then asserting that the match was found at the
starting position.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The check for completely matching a line is now done within
do_match_line.
(match_line): Pass nil to do_match_line, specifying that a prefix
match is okay.
(match_line_completely): New interface to do_match_line, which
requests a match to the end of the line.
(v_freeform): Pass nil to do_match_line: freeform needs
incomplete match semantics.
(match_files): Use match_line_completely instead of match_line.
By doing it this way, we do not need to compute the length of
the original line and compare it to the absolute position.
This saves time and memory since computing the length of a lazy
string forces it.
|
|
|
|
|
|
| |
be done for lazy strings, otherwise it just causes unnecessary
memory use by duplicating the line, and inefficiency via
thanks to allocator churn.
|
|
|
|
|
|
|
|
|
|
| |
object is nil.
* match.c (do_match_line): Bugfix for incorrect treatment of long
lines. Must return the absolute position from the start of the original
line (plus(c->pos, c->base)), rather than just c->pos, which only
measures from the start of a line that may have been chopped by
consume_prefix.
|
|
|
|
|
|
|
|
|
|
|
| |
which forces the printing.
* txr.c (help): Under -b, mention that printing the word false is
suppressed also. Added documentation for -B.
(main): Implemented -B option.
* txr.1: Documented -B option and added clarifying text under -b
option explaining the conditions under which bindings are printed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
represent empty optional output clauses, distinguishing them from
missing clauses. This creates an ambiguity, so that an @(output)
block which puts out a single empty line is treated as empty.
Present but empty clauses are now represented by t.
* match.c (do_output_line): Check for t and bail.
(do_output): Check for t instead of (nil) and bail.
* parser.y (o_elems_opt2): Nonterminal deleted.
(out_clauses_opt): Empty case generates nil.
(req_parts_opt): o_elems_opt2 replaced by o_elems_opt.
(repeat_rep_helper): Function now keeps track of which
clauses were specified. For those that were specified, but
empty, it substitutes t.
* tests/008/empty-clauses.expected: New file.
* tests/008/empty-clauses.txr: New file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.h: Likewise.
* debug.c: Added copyright header.
* debug.h: Updated copyright year.
* eval.c: Likewise.
* eval.h: Likewise.
* filter.c: Likewise.
* filter.h: Likewise.
* gc.c: Likewise.
* gc.h: Likewise.
* hash.c: Likewise.
* hash.h: Likewise.
* lib.c: Likewise.
* lib.h: Likewise.
* match.c: Likewise.
* match.h: Likewise.
* parser.h: Likewise.
* regex.c: Likewise.
* regex.h: Likewise.
* stream.c: Likewise.
* stream.h: Likewise.
* txr.c: Likewise, and e-mail address.
* txr.h: Updated copyright year.
* unwind.c: Likewise.
* unwind.h: Likewise.
|
|
|
|
|
|
|
|
| |
* match.c (do_txeval): Establish a dynamic env frame around
evaluation of quasiliteral and around embedded TXR Lisp expression
(which may contain quasiliterals) and stick the bindings there
via set_match_context. This way if filte functions are invoked through
a quasiliteral, they can see bindings.
|
|
|
|
|
|
|
|
| |
transformation of the load syntax because the parent location
is already associated with the syntax.
* match.c (v_load): Pull out source location info from
the form itself.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_error): Use source_loc_str to get source location.
* match.c (debuglf, sem_err, file_err): Likewise.
* parser.h (source_loc_str): Declared.
* parser.l (parse_init): form_to_ln_hash must be equal based now.
* parser.y (rl): Store new form of read-time source location info.
* txr.1: Documented load.
|
|
|
|
|
| |
Check if it is absolute and do not substitute parent
file's directory.
|
|
|
|
| |
rlcp. Only the parser should use rl to establish location info.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
needs to record file name, not only line number; absolute paths
not handled, etc.
* match.c (load_s): New symbol variable.
(v_load): New static function.
(syms_init): load_s initialized.
(dir_tables_init): Load directive registered.
* match.h (load_s): Declared.
* parser.h (parse_reset): New function declared.
* parser.l (spec_file_str): Global variable moved from txr.c.
(parse_reset): New function.
* parser.y (clause): Special handling for @(load ...) directive.
parent file path inserted into the syntax at parse time,
so when the load directive executes, it can load the file from
the same directory as the parent file.
* txr.c (spec_file_str): Global variable moved to parser.l.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* debug.c (help, show_bindings): put_string arguments reversed.
* eval.c (bind_args): Support colon notation in interpreted
function lambda lists for optional arguments. Improved error checking.
(apply): Allow optional arguments to be left out.
(dwim_loc): Reversed arguments to replace_str, replace_vec,
replace_list.
(eval_init): Numerous intrinsics now have arguments that are optional.
New function rand introduced which reverses arguments relative to
random. New intrinsic function hash introduced for alternative
construction of hashes.
* gc.c (sweep): Reversed arguments to put_char.
* hash.c (weak_keys_k, weak_vals_k, equal_based_k): New keyword
symbol variables.
(hashv): New function.
(hash_init): Intern new symbols.
* hash.h (weak_keys_k, weak_vals_k, equal_based_k, hashv): Declared.
* lib.c (colon_k): New keyword symbol variable.
(replace_list, replace_str, replace_vec): Arguments rearranged.
(tree_find): testfun becomes optional argument.
(int_str): base becomes optional argument.
(func_f0, func_f1, func_f2, func_f3, func_f4, func_n0,
func_n1, func_n2, func_n3, func_n4, func_f0v, func_f1v,
func_f2v, func_f3v, func_f4v, func_n0v, func_n1v,
func_n2v, func_n3v, func_n4v, func_interp): Initialize optargs to zero.
(func_n0o, func_n1o, func_n2o, func_n3o, func_n4o): New functions.
(cobj_print_op): Reversed arguments to put_string.
(find): testfun and keyfun become optional arguments.
(replace): Parameters rearranged and arguments rearranged in calls to
replace_list, replace_str and replace_vec.
(obj_init): colon_k initialized.
(obj_print, obj_pprint): Arguments reversed, and stream defaults
to std_output. Arguments reversed in calls to put_char and put_string.
(dump): Arguments reversed in call to put_char.
* lib.h (struct func): sizes of minparam, fixparam bitfields
adjusted. New bitfield optargs. New unnamed bitfield added so
the previous ones add up to 16 bits.
(colon_k): Declared.
(func_n0o, func_n1o, func_n2o, func_n3o, func_n4o): Declared.
(replace_list, replace_str, replace_vec, replace): Declarations updated.
* match.c (debuglf, dump_shell_string, dump_byte_string, dump_var,
do_output_line, extract): Reversed arguments to put_char and
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (sub, ref, replace): Declared.
* match.c (format_field): Generic indexing using new functions.
* txr.1: Documentation stub.
* txr.vim: Highlighting for new functions.
|
|
|
|
|
|
| |
expression, then recurse into the expression to find
variables. This allows us to do things like @{`@x`} inside
a @(repeat) or @(rep).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (subst_vars): Treat the variable as an arbitrary
expression rather than just a symbol.
* match.c (subst_vars): Likewise.
* parser.y (o_var): Further simplification. The first item in
an output var is an expr and not an IDENT.
* txr.1: Updated.
* txr.vim: Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
or not. This is now done right inside the standard output stream.
* match.c (output_produced): Variable removed.
(complex_open): Assignment to output_produced removed.
* stream.c (output_produced): New global variable.
(stdio_put_string, stdio_put_char): Set output_produced
to t if the target of the output is stdout.
* stream.h (output_produced): Declared.
* txr.h (output_produced): Declaration removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* match.c (v_do): Store match context.
(match_fun): New function.
* match.h (match_fun): Declared.
* stream.c (streamp): New function.
* stream.h (streamp): Declared.
* txr.1: Stub section for match-fun.
* txr.vim: Highlight match-fun.
|
|
|
|
|
|
| |
* match.h (match_funcall): Declaration updated.
* filter.c (get_filter): Updated.
|
|
|
|
|
|
|
|
|
| |
list, and not the atom nil.
* match.c (v_try): Do not transform an atomic exception x into
the list ((t . x)). Just to (x). This (t . x) representation is
a vestige of from the time when the exception consisted of the
old-style return values from txeval.
|
|
|
|
| |
* match.c (h_coll): Call consume_prefix in the loop.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
in debug reporting.
* debug.c (debug): New argument, base.
* debug.h (debug_check): New argument, base.
(debug): Declaration updated.
* eval.c (do_eval): Pass new argument of debug_check as nil.
* match.c (LOG_MISMATCH, LOG_MATCH): Take into account base
when displaying character position.
(do_match_line): Pass base position to debug_check.
(match_files): Pass nil as base to debug_check.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
a large file horizontally under @(freeform) in constant memory.
Position reporting is incorrect.
* match.c (match_line_ctx): New member, base.
(ml_all): Initialize new member to zero.
(consume_prefix): New static function.
(do_match_line): New static function, contains implementation of
match_line. Calls consume_prefix.
(match_line): Becomes a wrapper for do_match_line.
(search_form, h_skip): Call consume_prefix.
(freeform_prepare): New function. External to avoid inlining.
(v_freeform): Uses do_match_line, to down context by reference,
and also refactored to avoid spurious retention of c->data.
* unwind.c (uw_push-block, uw_push_env, uw_push_debug,
uw_push_catch): Zero out the structure, otherwise the unused
fields can cause spurious retention.
|
|
|
|
|
|
|
|
|
|
|
| |
* match.c (h_match_func): Changed to one-argument form.
(LOG_MISMATCH, LOG_MATCH): References to structure members
changed from member selection . to ->.
(h_text, h_var, h_skip, h_coll, h_parallel, h_trailer,
h_fun, hv_trampoline, h_define, h_do): Changed to one-argument form
that takes a pointer to the context.
(match_line): Local pointer named c used so that the
LOG_MISMATCH and LOG_MATCH macros can be used.
|
|
|
|
|
| |
which are compound expression (e.g. computed field widths).
This was broken by the first commit of 2012-01-26.
|
|
|
|
|
|
|
|
|
| |
needed because str is already a string). The purpose was to reduce
character to strings.
(subst_vars): Some of the new logic in format_field must be replicated
in the case when format_field is not called because the variable
has no modifiers. Lists must be converted to a space-separated string.
Bugfix here: occurence of pat and modifiers is not mutually exclusive.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
of range arguments. They are already evaluated since the cons
expression is evaluates as part of the dwim arglist.
Replaced some open code with function calls to the new listref
and listref_l functions.
(tostring, tostringp): made extern and moved to lib.c.
* lib.c (listref, listref_l): New functions.
(tostring, tostringp): moved here from eval.c.
* lib.h (listref, listref_l, tostring, tostringp): Declared.
* match.c (format_field): Handle index and range references.
* txr.1: Documented new output variable syntax.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(debug): In backtrace, show the renaming pairs for unbound
variables (up_p_a_pairs) if they are present.
* debug.h (debug_begin): Renamed to debug_frame.
* eval.c (eval): Wrap debug_begin/debug_end around function dispatch,
so TXR Lisp functions are included in backtraces.
* match.c (h_fun): Follow rename of debug_begin to debug_frame.
Pass in evaluated args, not the original ones.
(v_fun): Likewise.
* unwind.c (uw_push_debug): bindings argument renamed to env.
Bugfix: args argument was being assigned to ub_p_a_pairs.
* unwind.h (struct uw_debug): Member bindings renamed to env.
(uw_push_debug): Declaration updated.
|
|
|
|
|
|
|
| |
(match_files): Moving debug_check out of directive case so
it covers all forms handled by loop. All this makes the n
command in the debugger work better: not skip over
function calls or horizontal material.
|