| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
* regex.c (regex_source): New function.
(regex_init): regex-source intrinsic registered.
* regex.h (regex_source): Declared.
* txr.1: Documented.
|
|
|
|
|
| |
* regex.c (print_rec): Fix checking arg1
for consp but accessing arg2.
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-state loop): If the rs
variable is nil, provide a record reader which reads
paragraphs, like under Awk's paragraph mode when RS
is blank. This does not support the requirement that
newline is always a field separator, regardless of
the value of FS.
* txr.1: Documented paragraph mode.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-state loop): Refactor
code so that record-processing loop obtains a lambda
which is called to extract a record. If rs and krs did
not change, then the same lambda is obtained from
a variable which caches it. The get-rec-reader local
function thus encapsulates the whole record delimiting
strategy as well as changes to the variables. With this
structure, it will be relatively easy to add support
for Awk's paragraph mode, which is notably missing in
the implementation.
|
|
|
|
|
|
|
|
| |
* awk.tl (sys:awk-state loop): The loop now notices
when rs or krs changes and switches to a new
record-adapter or to the raw stream as necessary.
* txr.1: Notes added about changes to rs and krs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stream.c (struct strlist_in): New struct type.
(strlist_in_stream_mark, strlist_in_get_line,
strlist_in_get_char, strlist_in_unget_char,
strlist_in_get_prop, strlist_in_get_error_str):
New static functions.
(strlist_in_ops): New static struct.
(make_strlist_input_stream): New function.
(stream_init): Register make-strlist-input-stream
intrinsic.
* stream.h (make_strlist_input_stream): Declared.
* txr.1: Documented make-strlist-input-stream.
Call fill_stream_ops on new strlist_in_ops
struct to fill in common default stream operations.
|
|
|
|
|
| |
* txr.1: Documenting effect of fconv on rec,
and its return value.
|
|
|
|
|
| |
* txr.1: POSIX-derived example 1 can be made to
conform to the original with orec.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-state): New slot,
orig-rec.
(sys:awk-state loop): Initialize orig-rec after reading
each record.
(sys:awk-let): Provide orec symbol macro.
* txr.1: Document orec variable.
|
|
|
|
|
| |
* txr.1: Adding 19 examples, converted from POSIX
standard's Awk eamples.
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:range-test): Function renamed
to sys:awk-test, since it's not just for ranges.
(sys:awk-let): Uses of sys:range-test follow rename.
sys:awk-test introduced into expansion of cond parts
of cond-action clauses.
* txr.1: Documented new behavior (conditions can produce
a function or regex, which is implicitly invoked on rec).
|
|
|
|
| |
* txr.1: Change .coSS to .SS* in two places.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl: If there are no cond-action
clauses in the macro, do not generate the main record
processing lambda, or the begin-file and end-file
lambdas, and do not generate the call to the
awk state object's loop method.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/conv.tl (sys:conv-let): New
flets iz, oz, xz, bz and rz.
* txr.1: Documented under fconv.
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (tofloatz, tointz): New functions.
* arith.h (tofloatz, tointz): Declared.
* eval.c (eval_init): Register tofloatz and tointz intrinsics.
* txr.1: Documented new functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TXR Lisp files run from the command line do not see -Dvar=val
bindings, whereas -p expressions do. The REPL sees the
bindings, but not code loaded from it using (load "file.tl")
because they are lexical.
Let's keep these bindings as local lexicals for -p and -e
forms, but install them as global lexicals for the
other situations.
* parser.c (repl): Get rid of the local repl_env made
from the bindings that are passed in. Instead, before
starting the REPL, loop through the bindings and install
them as global lexicals with reg_varl.
* txr.c (txr_main): Before processing a Lisp file,
install the bindings as global lexicals with reg_varl.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a problem not handling negative list indices
which index beyond the beginning of the list.
Such accesses are just storing and retrieving the
first element!
* lib.c (listref): If a negative index is still negative
after the length of the list is added to it, then
return nil. Do not return car(list)!
(listref_l): Similary, do not return car_l(list) if
the index is less than zero, so that an error
occurs for an out-of-range negative index.
* txr.1: Update the documentation for ref
to describe these indexing constraints, and also
to include hashes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-compile-time): New slot,
rng-rec-temp. Specifies the name of a temporary variable
which is scoped over the evaluation of ranges, and which
caches a reference to the current record string.
(sys:range-test): New function.
(awk:let): Rename the original rng macrolet to sys:rng,
and introduce rng as a wrapper around it which inserts
the logic for calling the regex or function that might
emerge from the evaluation of from-expr or to-expr.
(awk): If ranges are present in the syntax, then bind
the temporary variable which caches the record around
the evaluations of the ranges.
* txr.1: Document new special behavior of rng w.r.t
functions and regexes. Add admonition against modifying
rec and some other awk variables from range expressions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The sys:regex internal symbol was historically used when
derivative-based regexes had a S-exp representation headed
by that symbol. It had to be a private symbol.
Now the regex symbol is only used as the COBJ class type
for regexes; it makes no sense for it to be in the sys
package. We want user code to be able to refer to this
type using a public symbol.
* lib.c (obj_init): Intern the regex symbol stored
in regex_s in user_package.
* txr.1: Include regex in the type graph in the
Object Type section, and in the type list under
the typeof function.
|
|
|
|
|
|
|
| |
* eval.c (do_eval): The no such function or operator message
is replaced with one which makes it clear that this means
that the first element of the form doesn't name an operator
or function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* regex.c (do_match_full, do_match_full_offs, do_match_left,
do_match_left_offs, do_match_right, do_match_right_offs):
New static functions.
(regex_match_full_fun, regex_match_right_fun,
regex_match_full, regex_match_left, regex_match_right,
regex_range_full, regex_range_left, regex_range_right):
New functions.
(regex_init): Register f^$, f^, f$, m^$, m^, m$, r^$,
r^ and r$ intrinsics.
* regex.h (regex_match_full_fun, regex_match_right_fun,
regex_match_full, regex_match_left, regex_match_right,
regex_range_full, regex_range_left, regex_range_right):
Declared.
* txr.1: Documented new functions.
|
|
|
|
|
| |
* txr.1: New paragraph added under the Regular Expressions Library
minor section.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The way the end-position argument works in match-regex-right
and match-regst-right is poorly considered. It basically
enforces a constraint that there is a match which ends
at that position and does not go beyond. This patch changes
it work right: the functions test that the regex matches
up to that position, as if the string ended there.
* regex.c (match_regex_right_old): New static function,
identical to the previous match_regex_right.
Since we won't ever be using this inside TXR from any
other module, we don't make it external.
(match_regex_right): Rewritten to new semantics.
(match_regst_right_old): New static function;
provides the semantics of the old match_regst_right
based on match_regex_right_old.
(regex_init): Register match-regex-right and match-regst-right
intrinsics to the match_regex_right_old and
match_regst_right_old functions if compatibility <= 150 is
requested. Otherwise they go to the rewritten new
functions.
* txr.1: Documentation updated, and compat notes
added.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The documentation says that match-regex returns the length.
Actually, it returns the position after the last character
matched. This makes a difference when the match doesn't begin
at character zero.
The actual behavior is that of the match_regex C function
which has behaved that way since the dawn of TXR, and
internals depend on it behaving that way.
So the internal function is being retained, and a new function
is being registered as the match-regex intrinsic. The choice
of binding for match-regex is subject to the compatibility
option.
The behavior of match-regst is also being fixed since its
return value is incorrect due to this issue. Since its
return value makes no sense at all (does not represent
the matched text), it is not subject to the compatibility
option; it is just fixed to conform with the documentation.
* regex.c (match_regex_len): New function.
(match_regst): Keep using match_regex, but use its return
value properly. This simplifies the range extraction code,
which is why match_regex works that way in the first place.
(regex_init): Register match-regex to match_regex_len,
unless compatibility <= 150 is requested; then register
to match_regex.
* regex.h (match_regex_len): Declared.
* txr.1: Compatibility notes added.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* LICENSE: Reverted to Two-Clause BSD license. The
copyright of the Linenoise library are included, because
it uses exactly the same license. A note is added
about MPI being in the public domain.
* LICENSE-CYG: Revised text to clarify the situation that
Cygnal is only bundled with a particular Windows build of TXR.
* METALICENSE: Revised text. All references to modifications
to the BSD license are removed. Gives pointers to the MPI and linenoise
license files. Notes that linenoise is under the Two-Clause BSD also.
Makes a note about Cygnal and points to LICENSE-CYG.
* inst.nsi: Remove the text which tells the user that
use of the program requires agreement with the license;
refer only to redistribution. The "Agree" buttons are renamed
"Acknowledge".
* mpi/make-logtab, mpi/mpi.c, mpi/mpi.h, mpi/mplogic.c,
mpi/mplogic.h: Remove copyright notices and "all rights
reserved", since the author had placed this into the public
domain, as made explicit in the README file.
|
|
|
|
|
| |
* txr.1: search-regst added to heading of section which
describes it.
|
|
|
|
|
|
|
|
| |
* lib.c (generic_funcall): Add case for regexes.
Handle arguments in such a way that the string is always
rightmost, with a view to convenient partial application.
* txr.1: Documented in multiple places.
|
|
|
|
|
|
|
|
|
| |
* regex.c (regsub): Allow the second argument to be
a function, which is called with str as an argument,
and returns a range which indicates what part of
the string is to be replaced, or else nil.
* txr.1: Documented functional argument of regsub.
|
|
|
|
|
|
|
|
|
| |
* regex.c (match_regex, match_regex_right): Detect
a negative start or end position, respectively,
and add the string length to it. If it is still
negative, bail with nil.
* txr.1: Documented.
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Remove all regex-related function
registrations from here.
* regex.c (regex_init): Move regex-related function
registrations here.
|
|
|
|
|
|
| |
* share/txr/stdlib/place.tl (pset, push, pushnew): Use rlet
for binding the assigned or pushed value to a temporary,
so the temporary can disappear if the value is a constant.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is used in the awk macro. Breaking test case is
an update modification of f, like (push 3 f);
a broken call to sys:rslotset is generated with a
too few arguments.
* share/txr/stdlib/struct.tl (defplace sys:rslot): Fix name
clash between gensym and parameter. Add the meth-slot-sym
parameter into the sys:rslotset call where it is missing
as a required parameter.
|
|
|
|
|
| |
* txr.1: Adding remark that assignment to nonexistent
fields isn't permitted, unlike in Awk.
|
|
|
|
|
|
|
|
| |
* txr.1: fs and ft are described in one simplified
section. The default behavior when they are both nil
is described simply as token extraction, which is how
it is now implemented. Some verbiage is reduced
in the krs description.
|
|
|
|
|
|
|
|
|
| |
* share/txr/awk.tl (sys:awk-state rec-to-f): Check for empty
record only in the fs case; it's not necessary when tokenizing
with ft. Check (not self.kfs) first, since it's the common
case. Handle default case (no fs or ft) using tok-str
using the regex #/[^ \t\n]+/, which requires no trim-str
and no empty record check.
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (build_set_entries, build_instantiate): New static
functions.
(dlt_register): Register dynamic loading of build.tl via
the two new functions.
* share/txr/stdlib/build.tl: New file.
* txr.1: Documented everything.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-let): Add new symbol
macro, fconv.
* share/txr/stdlib/conv.tl: New file.
* txr.1: Documented fconv.
|
|
|
|
| |
* txr.1: "require user id" -> "required user id".
|
|
|
|
|
|
|
| |
* txr.1: Document that on Windows, the home directory is
determined from USERPROFILE for finding the ~/.txr_history
file as well placing the temporary file for the
edit-in-editor interactive feature.
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (get_home): New static
function.
(edit_in_editor): Call get_home instead of
getenv("HOME").
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-state): New slot, krs.
(sys:awk-state loop): Use record-adapter if krs is true,
even if the default fs is in effect. Pass value of krs to
record-adapter function.
(sys:awk-let): Provide krs "awk variable" symbol macro.
* txr.1: Documented krs. Clarified semantics of rs being
those of both separation and termination.
|
|
|
|
| |
* tests/015/split.tl: New cases added.
|
|
|
|
|
|
|
|
| |
* Makefile (TXR_DBG_OPTS): Disable for tst/tests/015.
* tests/common.tl (mtest): New macro.
* tests/015/split.tl: New file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (tok_str): Only continue the loop if
the new position isn't past the end of the string.
This fixes the problem of recognizing an empty
token past the last character in the string.
Also, advance new_pos by one if there is a zero
length match. Then don't advance pos by one later
in that case. This fixes the bug that we collect
empty separator pieces *and* empty tokens,
and also prevents empty matches before the first
character of the string. Logic in tok_str is now very similar
to that in split_str_keep.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-state): New slots, ft and
kfs.
(sys:awk-state rec-to-f): Implement ft and kfs semantics.
(sys:awk-let): Provide ft and kfs as "awk variable" via
symbol macros.
* txr.1: Documented ft and kfs.
|
|
|
|
|
| |
* txr.1: Improve some wording in the description
of the awk fs variable.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (split_str_keep): In the regex case, changing
to an infinite loop. The do/while is no longer needed because
the if statement includes a test of the position having
reached the end of the string. This is done before it is
incremented by len, so we avoid wrongly keeping a separator.
* txr.1: Clarified that an empty regex match
behaves like an sep which is an empty string,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register split-str to split_str_keep,
with optional argument.
* lib.c (split_str_keep): New function, formed from
split_str, with third argument.
(split_str): Reduced to wrapper around split_str_keep.
Thus we don't have to update umpteen existing calls
with an extra nil parameter.
* lib.h (split_str_keep): Declared.
* txr.1: Documented new optional argument of split-str.
|
|
|
|
| |
* regex.c (reg_optimize): Implement ~~R -> R reduction.
|