| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is no longer any way to write a @(rcons ...)
pattern using the range syntax, so there is no point in
supporting that operator. The silly syntax @@a..@b
which previously worked was actually due to a mistaken
requirement in the parser.
* share/txr/stdlib/match.tl (compile-range-match): Function
moved closer to compile-atom-match, below compile-vec-match.
The argument is now a range object containing patterns, so we
pull it apart with from and to.
(compile-atom-match): Pass range directly to
compile-range-match; no need to construct (rcons ...) syntax.
* tests/011/patmatch.tl: Add range tests from documentation
and a few others.
* txr.1: References to @(rcons ...) pattern scrubbed.
One wrong #R pattern example corrected.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (match-vars): New slots, pure-vars
and pure-var-exprs.
(match-vars lets): New method.
(compiled-match wrap-guards): Generate an alet that binds the
temporaries, and then does the assignments of the regular
variables.
(compile-vec-match, compile-cons-structure,
compile-hash-match, compile-range-match): Use the pure-vars
for match-guard temporaries that are bound and not assigned,
rather than vars.
(when-match, if-match): Use alet for obj-var.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The following form fails to expand:
(let (a) (set a '#1=(#1#)))
This is due to macro ancestor propagation which wants to
traverse the entire (set ...) form in order to indicate its
macro ancestor.
* share/txr/stdlib/place.tl (sys:propagate-ancestor): We check
whether to-tree already has a macro ancestor, and only recurse
if it doesn't.
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-atom-match): Handle range
type, via transformation to rcons operator and
compile-range-mach.
(compile-range-match): New function.
(compile-match): Hook in compile-range-match for @(rcons).
(non-triv-pat-p): Handle range case.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous commit made the general pattern matcher dependent
on calling non-triv-pat-p function. But that function needs
the matcher to work in order to be defined. This has left the
code base uncompilable.
* share/txr/stdlib/match.tl (non-triv-pat-p): Precede the
real definition of non-triv-pat-p with a temporary one which
returns a conservative t value, which suspects all syntx to
be non-trivial. This means that the real non-triv-pat-p can
use match-case, because match-case's expander will be using
the temporary version of the function. non-triv-pat-p won't
benefit from the optimizations arising from identifying
trivial patterns: but since it doesn't have any such patterns,
so it makes no difference.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-atom-match): Test whether
a vector is really a non-trivial pattern, or a trivial
piece of datum. If it is trivial, then compile it
as an atom, which is matched by a simple call to equal,
which is way less code bloat, and implemented in C.
(compile-match): Similarly, check whether the cons structure
case is nontrivial and only then treat it as a cons
pattern, otherwise compile it as an atom, which will
just match it with equal.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change causes a key-value pattern like (@a @b)
to be treated specially when @a already has a binding from a
previous pattern. In this case, it behaves like the
trivial key case: the value of @a is looked up to try to find
a single value. If @a is not bound, then the exhaustive
search takes place, using equal equality.
* share/txr/stdlib/match.tl (compile-hash-match): Implement
special case.
(var-pat-p): New function.
* tests/011/patmatch.tl: Existing test case now changes
value. New test case added.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
| |
Hash pattern matching must not assume that if gethash returns
nil, the item is not found. That's just a convenience that can
be coded in some situations, not in a general mechanism.
* share/txr/stdlib/match.tl (compile-hash-match): Allocate a
gensym that serves as a unique object. Pass this to gethash
as the alt argument, and then check whether gethash has
returned this value to indicate failure.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-hash-match): Follow
rename of is-pattern function to non-triv-pat-p.
(is-pattern): Renamed to non-triv-pat-p, to follow terminology
in the reference manual. A bug is fixed here: we must
recognize cons patterns with operators and variables in the
dotted position as non-trivial.
* tests/011/patmatch.tl: New hash test case, from doc.
* txr.1: Documented hash pattern operator.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes the inadequacy that all variables occurring
in a pattern under @(all ...) or @(coll ...) are blindly
collated into lists, ignoring the fact that they may be
previously bound variables that must back-reference and not be
colleced into lists (just like in the TXR Pattern language!)
* share/txr/stdlib/match.tl (compile-loop-match): Calculate
the subset of variables in the pattern that have been freshly
bound. Only generate the collection gensyms for those
variables and only collect and nreverse those variables.
* tests/011/patmatch.tl: Some test cases that backreference
into an @(all).
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (struct match-guard): guard-expr
slot defaults to t, so the guard defauls open.
Guards are sometimes used just for binding temporaries and not
imposing any condition.
(compile-parallel-match, compile-hash-match): Omit
initial value of t for guard-expr.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-hash-match): New
function.
(compile-match): Hook in hash operator.
(is-pattern): New function: uses match-case, and is used in
the implementation of the hash operator. This works because
the function doesn't use @(hash ...) anywhere.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-loop-match): Implement
coll semantics. coll fails if it collects nothing, which
uses common logic with all*. We just have to move the
flipping of the loop-iterated-var into the match, and not
do it unconditionally for every iteration.
(compile-match): Hook in the coll operator.
* tests/011/patmatch.tl: Test case copied from doc example.
* txr.1: Documented.
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (when-match): Replace incorrect if
with when.
|
|
|
|
|
|
|
|
|
|
| |
Relax the restrictions in these operators so they work with
sequences rather than specifically lists.
* share/txr/stdlib/match.tl (compile-loop-match): Make the
necessary adjustments so that abstract iteration is used.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-parallel-match): Just
like what was done in compile-loop-match in the prior commit,
we fix the situation here. guard1's guard-expr, in which the
matching logic actually happens, becomes the main test-expr.
Thus guard1 disappears and guard0 is renamed to the one and
only guard.
* tests/011/patmatch.tl: Added test case which is fixed
by this.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is caused by the way the loop match compiler moves the
matching logic into a guard, which causes a re-ordering of the
variable assignments which interferes with backreferencing
when @(some) is embedded into a @(let), and probably other
situations. The issues is that the backreferencing equal
tests can be reordered to occur before the assignment which
sets the intial value of the backreferenced variable:
cart before the horse kind of thing.
* share/txr/stdlib/match.tl (compile-loop-match): Do not add
the submatch into the guard sequence. Thus guard1's vars and
var-exprs, move into into the main compiled-match,
and guard1's guard-expr moves into guard0. Thus guard1
disappears, guard0 becomes guard.
* tests/011/patmatch.tl: New test case that is also fixed,
and which was not fixed by a different approach to the problem
that I scrapped.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-let-match): Reimplement
cleanly in terms of compiling a variable match and a pattern
match against the same object and integrating the two.
Also, do not reject nil as a variable name; the documentation
clearly says it is allowed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Multiple occurrences of variables unify using equal.
* share/txr/stdlib/match.tl (var-list): New struct type.
Used for tracking what variables have been defined.
(compile-struct-match, compile-vec-match, compile-atom-match,
compile-op-match, compile-cons-structure,
compile-require-match, compile-let-match, compile-loop-match,
compile-parallel-match, compile-not-match): Take var-match
argument and pass it down.
(compile-parallel-match): Take var-match argument and pass
copies of it down to the compile jobs of the branches, since
they do not unify.
(compile-var-match, comiple-let-match, compile-op-match):
Handle variables carefully: check for variable already
being defined and generate a backreference instead of
a new binding match.
(compile-match): Take optional var-list argument,
instantiating the object if it is missing, pass down to all
recursive compile unctions.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (match-case): The first case
should not test the flag variable, the variable is false.
This compiles to a useless if instruction and unreachable code.
I tried writing a peephole rule against that instruction
sequence in an experimental peephole optimizer, but across the
entire code, it only matched in code in compiler.tl arising
out of match-case, so it is better to squash this at the
source. I won't commit the peephole optimizer until it comes
up with something that isn't better fixed elsewhere.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-require-match): The bug
here is that the condition is placed before the
match.test-expr, which is incorrect. The conditions can only
be evaluated if match.test-expr has succeeded, because
otherwise the variables are not validated to have the
correctly matching value. Also, in the documentation,
the synax insinuates there can be more than one expression. So
let's just make it work: require takes multiple expressions
and combines them with an implicit and.
* txr.1: Documentation updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* /share/txr/stdlib/compiler.tl (expand-and): The case with
@(true-const-p) is wrongly ordered with respect to (and @a).
The problem is that @rest can match a null terminator, and
then we wrongly consume the constant; i.e. (and 42)
calls (expand-and ^(and)) yielding t.
Also, we eliminate the (and @a @b) case, because it is
redundant with respect to (and @a . @rest).
We adjust the latter to just output (if ...).
And, lo and behold, now the function's cases map 1:1 to the
ones in reduce-or. In fact reduce-or was originally produced
from expand-and. I debugged it thoroughly, but neglected to
backport to expand-and.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Bumped from incorrect 245 to 247.
* txr.vim, tl.vim: Regenerated.
* protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-struct-match,
compile-predicate-match, compile-cons-structure,
compile-require-match, compile-let-match, compile-loop-match,
compile-parallel-match, compile-not-match, match-case): Use
mac-param-bind for better error reporting against the original
form when inner tree patterns don't match.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-loop-match): Introduce a
new guard, and bind the pattern's variables there. The main
compiled match now has an empty list of vars and var-exprs,
so there is no length mismatch. The nreversing of the
accumulated lists (only done in the @(and) case) is part of
the test-expr now.
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-parallel-match): The
problem here is that vars in the new compiled-match being
returned is not a list of the same length as var-exprs (that
being empty). When this is embedded in other expressions, and
the vars/var-exprs are appended together, this causes a
mismatch, causing assignments to go to the wrong variables.
The solution is to move the binding of all-vars into a new
guard. Guards are not blindly combined by appending.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Squeeze the constant and unreachable cases out of (and ...)
and (or ...) forms, producing a more streamlined translation.
This is the first appearance of structural pattern matching in
the compiler!
* share/txr/stdlib/compiler.tl (compiler compile): Handle and
using new expand-and function, which translates it to if
forms. Handle or via the renamed method comp-or.
(compiler comp-and-or): Renamed to comp-or, since it handles
only or. All the switching between or/and is eliminated.
The or form is first reduced using simplify-or.
We retain this function because one case in cond relies on or;
or is a useful primitive because (or a b) evaluates a only
once; whereas (if a a b) requires common-subexpression
elimination to generate the same code as (or a b).
(true-const-p, expand-and, flatten-or, reduce-or,
simplify-or): New functions.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-not-match): New function.
(compile-match): Hook in not operator.
* txr.1: Documented.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (cmopile-parallel-match):
Rearrange the code and bind an all-vars local variable so that
in submatch-fun we have access to the set of symbols. When
compiling the @(or) operator, we use the list to null out all
the variables that don't belong to the matching pattern.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-struct-match):
Allow a pattern instead of a struct type name, in which
case the object can be of any struct type which has
the slots required by the pattern.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* lisplib.c (match_set_entries): New autoload triggers.
* share/txr/stdlib/match.tl (lambda-match, defun-match): New
macros.
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_set_entries): Add match-case and if-match
autoload trigger symbols.
* share/txr/stdlib/match.tl (if-match, match-case): New
macros.
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-op-match): New function.
(compile-match): Route op operator to new function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is implemented using exactly the same code as @(or ...);
the only difference is whether the and or or operator is used
in the expression.
* share/txr/stdlib/match.tl (compiile-or-match): Renamed to
compile-or-parallel match. Some local variables are renamed to
avoid being OR-specific. The operator is extracted from the
pattern, and inserted into the guard expression. That one
insertion is the only differnce between and and or.
(compile-match): Route the or operator to the renamed
function. Rout the new and operator to it also.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-loop-match): Eliminate
repeated (op eq 'some) tests by evaluating this once into the
some-p variable. Do not wastefully generate the code that
pushes values onto accumulation lists if we are translating
the some operator; those lists are ignored. Don't generate
those accumulation variables themselves at all.
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-or-match): New function.
(compile-match): Route or operator to new function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the existential quantifier to accompany @(all).
* share/txr/stdlib/match.tl (compile-loop-match): Check for
the some symbol in a few places and adjust the output.
We don't need a local binding of the patter's variables,
only the temps. The values go directly to the outer binding of
the variables which are not shadowed now. We also don't need
the nreverse logic to set the outer variables: var-exprs
is nil at the outer level. The polarity of the loop
termination test is reversed: we quit the loop on the first
match, as is the polarity of the return value: if the loop is
aborted early t is returned instead of nil.
(compile-match): Wire in the some operator.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is in anticipation of using the same function to compile
other patterns that involve iteration.
* share/txr/stdlib/match.tl (compile-all-match): Function
renamed to compile-loop-match. The successful match and loop
termination variables are renamed to different symbols.
Also, test for the usr:all* symbol explicitly rather than
all for making the test consp.
(compile-match): Follow function rename.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-all-match): We use a flag
to break out of the loop instead of (return). The loop's block is
thereby later eliminated by the compiler. For this we
re-purpose the same all-match-p-var symbol.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_set_entries): Ensure usr:all* is interned.
* share/txr/stdlib/match.tl (compile-all-match): When the
operator is the existing all, we must listp as a guard, not
consp, because an empty list must match vacuously by virtue of
not containing any counterexample to the pattern. For
situations when a vacuous empty match is not desired, we
support the all* alternative operator, which uses consp.
(compile-match): Wire in the all* operator.
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-all-match): New function.
(compile-match): Hook it in.
|
|
|
|
|
|
|
|
|
|
| |
For instance @(oddp) instead of @(oddp x) to require an
element to satisfy oddp without capturing it to a variable.
* share/txr/stdlib/match.tl (compile-predicate-match): Make
the symbolic argument optional, defaulting to nil.
A nil symbol is already treated as pseudo-variable which
consumes an item without binding to a variable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
So quick and dirty; you have to love special variables.
* share/txr/stdlib/match.tl (*match-form*): New special
variable.
(compile-var-match, compile-predicate-match,
compile-let-match): Use compile-error instead of error,
passing the value of *match-form* as the context.
(compile-match): Ditto, and eliminate unreachable case from
cond form.
(when-match): Capture form directly into special variable
using :form *match-form*.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (match-vars): New struct.
Holds vars and expressions, and provides the method to
zipper them up into the assignments.
(match-guard, compiled-match): Inherit from match vars.
match-guard loses temps and temp-exprs. It now has
vars and var-exprs from the base and those are used
instead.
(compiled-match get-temps): Follow temps vars rename.
(compiled-match wrap-guards): Use assignments method
inherited from base instead of assignments function.
(assignments): Function removed.
(compile-struct-match, compile-vec-match,
compile-cons-structure): Follow vars temps rename in
match-guard struct.
(when-mach): Use assignments method of compiled-match instead
of assignments function.
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_instantiate, match_set_entries): New static
functions.
(lisplib_init): Register autoload using new statics.
* share/txr/stdlib/match.tl: New file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* METALICENSE: 2020 copyrights bumped to 2021. Added note
about SHA-256 routines from Colin Percival.
* LICENSE, LICENSE-CYG, Makefile, alloca.h, args.c, args.h,
arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c,
chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c, combi.h,
configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h,
filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h,
hash.c, hash.h, itypes.c, itypes.h, jmp.S, lex.yy.c.shipped,
lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h,
lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h,
parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c,
regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl,
share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl,
share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl,
share/txr/stdlib/copy-file.tl, share/txr/stdlib/debugger.tl,
share/txr/stdlib/defset.tl, share/txr/stdlib/doloop.tl,
share/txr/stdlib/each-prod.tl, share/txr/stdlib/error.tl,
share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl,
share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl,
share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl,
share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl,
share/txr/stdlib/package.tl, share/txr/stdlib/param.tl,
share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl,
share/txr/stdlib/pmac.tl, share/txr/stdlib/quips.tl,
share/txr/stdlib/save-exe.tl, share/txr/stdlib/socket.tl,
share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl,
share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl,
share/txr/stdlib/trace.tl, share/txr/stdlib/txr-case.tl,
share/txr/stdlib/type.tl, share/txr/stdlib/vm-param.tl,
share/txr/stdlib/with-resources.tl,
share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl,
signal.c, signal.h, socket.c, socket.h, stream.c, stream.h,
struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h,
syslog.c, syslog.h, termios.c, termios.h, time.c, time.h,
tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h,
utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr,
y.tab.c.shipped: Copyright year bumped to 2021.
|
|
|
|
|
| |
* share/txr/stdlib/quips.tl (sys:%quips%): East Van cross and
reference to urban myth regarding Sports Illustrated cover.
|
|
|
|
| |
* share/txr/stdlib/quips.tl (sys:%quips%): Updated.
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl: Load "conv", not "conv.tl", so
that if there is a .tlo present, it is loaded instead.
|