| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: New test cases that break. The (copy
var-list) logic in the handling of and and or is incomplete.
The bifurcated vars must be merged together into the original
vars. Without this, it looks as if the operator didn't bind
any variables, and they can be repeated again without
backreferencing. In the broken examples, variable a is taking
on the value 2 instead of mismatching the previous value of 1.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_instantiate): Ensure usr:with is interned.
* share/txr/stdlib/match.tl (compile-with-match): New
function.
(compile-match): Wire in with operator.
* tests/011/patmatch.tl: Test cases.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_instantiate): Ensure usr:as is interned.
* share/txr/stdlib/match.tl (compile-let-match): Rename to
compile-as-match.
(compile-match): Remove handling of let symbol; route as
symbol to compile-as-match.
* tests/011/patmatch.tl: Update all uses of let to as.
* txr.1: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compiled-match get-vars): Local
function here becomes stand-alone defun, because we need it
elsewhere.
(compiled-mach wrap-guards): When processing the
guard-disjunction object to produce the or branches, we
calculate, for each branch, its own variables, and the variables
of the preceding clauses. We generate code to set the previous
variables to nil. Not all the previous variables, just those
that are not also in the current clause.
(get-vars): New function.
|
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: New test case showing that @(or)
no longer nulls out the variables from previous clauses like
it used to. (2 2 nil) is returned, showing a is not set to
nil when b matches.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the loose form of the @(struct ...) match, the struct type
is matched by a pattern. This pattern should execute before
the object is tested for the presence of the required slots
by by guard1. It should not come between testing for the
presence of slots, and then testing their contents.
* share/txr/stdlib/match.tl (compile-struct-match): Do not
lump together the type-match and slot-matches into a single
all-matches list. Emit type-match's guard before guard1,
and the slot-matches guards after. The order is
basic test (guard0), struct type pattern match (type-match),
slots-present (guard1) and then slot contents (slot-matches).
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-struct-match): make
guard0 and guard1 lists match-guard items. Replace
backquote with straight append.
|
|
|
|
|
|
|
| |
* txr.1: Fix use of nonexistent odd function which should be
oddp. The same example occurs in the test suite, but without
this error. Also fix indentation in this and the two related
examples above.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-dwim-predicate-match): In
he one-argument case, there is stray code referencing
var-match.test-expr, which blows up. This is hit by exactly
the one example in the documentation that was not added
as a test case.
* tests/011/patmatch.tl: Add test case from doc.
|
|
|
|
|
| |
* txr.1: The de-sugared (rcons @a @b) example is missing a
quote on the object, and so returns nil and not (1 2).
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
| |
* lib.c (delete_package): This is the only user of
alist_remove1. It can use remqual with a car_f key, which is
more efficient.
(alist_remove1): Function removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Makefile (tst/tests/000/binding.ok): Pass -B to txr for this
new test.
* match.c (v_rebind): Fix gaping copy-and-paste bug here,
which causes rebind to take on the behavior of local/forget;
it takes all symbols that appear as its arguments from the
environment and produces an environment in which they
don't exist. What we want is to remove the left
variables from the environment, and since that is a nested
pattern, the right way to do that is to flatten it.
Bug reported by Frank Schwidom.
* tests/000/binding.txr: New file.
* tests/000/binding.expected: New file.
* txr.1: Improve documentation of @(rebind), also making
improvements in @(set) documentation.
|
|
|
|
|
|
| |
* txr.1: Fix issues in the formatting of the index-list, index
and function arguments of partition, partition*, split and
split* functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Elimination of unused temporaries is really the job of the
compiler, but we can do some simple things to get better code
from the matcher in the meanwhile. In list and vector matches,
@nil gets used just for placeholding. We can avoid generating
the code which binds the corresponding value to an unused
gensym.
share/txr/stdlib/match.tl (compile-var-match): When the
variable is nil, then do not generate a match-guard with
empty content. Just generate an empty guard-chain.
The higher level compiler can then check for this empty guard
chain and prune its own material away.
(compile-vec-match, compile-cons-structure): Eliminate every
gensym and its initializing expression, whose corresponding
compiled sub-match has an empty guard chain.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (non-triv-pat-p): Extend
sys:var match so (sys:var nil) is identified as trivial.
* tests/011/patmatch.tl: Add broken test case fixed by this.
This doesn't show up when @nil is used as the only match.
It also doesn't show up if @nil is used in a vector or list
in a mixture with other operators, because those other ones
identify the overall list pattern as non-trivial. None
of the occurrences of @nil in the existing test suite,
like (@nil @nil @x) tickle the bug.
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (compiler optimize): Call
peephole method on basic-blocks object, rather than
thread-jumps.
* share/txr/stdlib/optimize.tl (basic-blocks thread-jumps):
Rename method to peephole, since it does more than just
thread-jumps. Add some dead code elimination, and elimination
of wasteful moves.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compiled-match get-var-exprs):
method get-var-exprs removed. This is only used in one place,
which is going away. Actually, the value is not even used; it
is discarded.
(compiled-match get-vars): This method now passes the list of
variables thorugh uniq. The logic of get-guard-values is
pulled into a local function, since get-guard-values has only
one caller now.
(get-guard-values): Function removed.
(compile-or-match): Removing all-var-exprs variable
and all that calculation of the unique names, as well as the
extra match-guard which duplicates those names pointlessly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (match-vars): Get rid of base,
since only match-guard would need it now.
(match-guard): Move match-vars methods and slots into this
structure.
(compiled-match): No longer inherits match-vars, so no
longer has vars and var-exprs slots. Also, slot test-expr
removed.
(compiled-match :postinit): Removed.
(compiled-match {get-vars, get-var-exprs}): Do not prepend
vars and var-exprs which no longer exist.
(compile-struct-match, compile-vec-match, compile-range-match,
compile-cons-structure, compile-let-match,
compile-hash-match): Get rid of vars, var-exprs and test-expr.
These are just causing duplicate variables to exist.
(compile-var-match): Convert necessary test-expr and vars into
match-guard object put into guard-chain.
(compile-atom-match, compile-or-match): Get rid of test-expr.
(compile-op-match, compile-predicate-match): Get rid of stray
reference to test-expr.
(compile-dwim-predicate-match): Move obj-var test into guard.
Get rid of vars, var-exprs and test-expr.
(compile-loop-match): Move vars and and test expression into
a second guard object, so there are now guard0 and guard1.
(compile-and-match): Get rid of all-var-exprs local variable
and its compuation, vars, var-exprs and test-expr.
(compile-not-match): Get rid of test-expr and empty vars.
(compile-hash-match):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (match-guard): New slot,
test-expr. This provides a bottom test, with all the variables
bound, allowing us to allocate just one match guard in a few
instances where we are allocating two. This will be important
in the upcoming refactoring.
(compiled-match :postinit): Allocate just one match-guard
with test-expr instead of a separate one with a guard-expr.
(wrap-guards): Wrap the test-expr to the code, if it is
not t.
(compile-hash-match): Reduce two match guards to one in two
instances.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This one test case requires restructuring. The handling for
the @(or ...) operator is now very different. To support @(or
...), there is now a new variant of the match-guard object
called guard disjunction, which contains multiple match-guard
chains. Furthermore, the separation between both guard-chain
lists and compiled-match having a test expression and
variables is being obliterated. For now, what we do is in a
:postinit handler on compiled-match, we immediately convert
the test-expr, vars and var-exprs slots into a match-guard
object, which is placed into the guard-chain, and then we
clear these slots. They are now vestigial only and will be
removed.
* tests/011/patmatch.tl: New test case which shows
that (@(or foo bar) ...) does not short immediately short
circuit to a failure when the corresponding element is
neither foo nor bar. Matching proceeds to the right,
wasting cycles and possibly causing errors.
* share/txr/stdlib/match.tl (*match-var*): Move to top, above
structs. There are some methods which refer to this variable
now for throwing internal errors.
(guard-disjunction): New object that is compatible with a
match-guard, and placed into guard-lists as if it were a
match-guard. This handles the bifurcation logic of an
OR match.
(compiled-match): New :postinit handler converts local vars,
var-exprs and test-expr into a match-guard placed into the
chain, and then clears these values. The compilation of code
is done purely from the guard-chain.
(compiled-match get-vars): This method is now complicated due
to the guard-disjunction objects, and so uses a helper
function called get-guard-values.
(compiled-match get-var-exprs): New method accompanying
get-vars to get the accompanying init expressions.
(compiled-match wrap-guards): Two changes are going on here.
One is that the funccion takes on more of the responsibility
which was previously carried out by the callers. The callers
were interpolating the test-expr and vars from a
compiled-match into a piece of code, which was then passed to
wrap-guards. Hence the naming: the job was just to wrap some
guards. Now, wrap-guards is called just with the body forms,
and does all of the work. Secondly, wrap-guards is complicated
due to the handling of the guard-disjunction items.
Also, there is some case handling to generate better code;
we avoid generating an empty (let () ...) and (alet () ...).
(compiled-match add-guard-pre, compiled-match add-guards-pre,
compiled-match add-guards-post): New methods for adding guards
after construction. These interfaces replace hacks of pushing
new variables, tweaking the test-expr, or explicitly pushing
guards onto the list.
(get-guard-values): New function for iterating over a
guard-chain, including match-guard and guard-disjunction
items, retrieving a particular list-valued slot from each one
using the fun argument, and returning a list of all those
lists catenated together.
(compile-struct-match, compile-vec-match,
compile-range-match): Eliminate test-expr, replacing it with
the harmless t.
(compile-op-match): We don't try to extend the test-expr of
the compiled var. Rather we add our guard expressin using the
add-guard-pre interface.
(compile-dwim-predicate-match): Likewise, and also, we
do not calculate the test-expr for the output compiled-match
from the constituent match test-exprs. We ignore those and
just set the test-expr pat-match.obj-var. The constituent
test-exprs have been converted to guard-chain items already,
so there is no point in referring to them.
(compile-predicate-match): Use add-guard-pre method to add
guard instead of pushing it on list.
(compile-cons-structure): Eliminate test-expr being calculated
from constituent test-exprs, and just stub it out to t.
(compile-require-match): Use add-guards-post to push
match-guard onto compiled child mach, instead of tweaking its
test-expr.
(compile-let-match): Oblierate calculation of test-expr from
child test-exprs, replacing with t stub.
(compile-loop-match): Call wrap-guards in the new way,
without generating assignments or test-expr.
(compile-parallel-match): This method is removed; there are
now separate compile-or-match and compile-and-match methods.
(compile-or-match): New method: compiles consitituent
expressions, and converts them into multiple guard-chains
for a guard-disjunction object. Then wrap-guards will finish
the job of emitting the or logic out of those chains.
(compile-and-match): This shares some common logic with
compile-or-match, but is substantially simpler. Pattern
matching is implicitly AND-based: in a pattern, all the
sub-patterns have to match. So there isn't much to do beyond
just evaluating all the patterns against the same object.
They can all be thrown into one combined flat guard chain.
(compile-not-match): Adjust to new wrap-guards interface.
Nothing left to do here but pass the expression t to it.
(copmile-hash-mach): The post-constructon manipulations of
the child compiled matches are done with the appropriate
add-guards-pre. The test-expr is eliminated, replaced with t.
(compile-match): Wire or and and to the new separate methods
compile-or-match and compile-and-match.
(when-match, if-match, match-case): Simplified due to
when-match interface change. The macros depend on a lot less
implementation detail now: they bind the required vars and
generate the code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (expand-each): The algorithm
for appending is completely wrong. Not only does it
destructively mutate, it doesn't look like it will behave like
the interpreted append-each operator, since it assumes
it can rplacd the tail cons of the output list, which won't
work for non-list sequence types.
* share/txr/stdlib/compiler.tl (expand-each): New translation
strategy: append-each each will now accumulate the values of
the body expression into a list, exactly like collect-each
does. Then it will apply the sys:append function to that list.
This ensures the "as if" semantics (append-each behaves like
the append function), and non-destructive behavior: everything
is copied that needs to be, except that a list tail can share
substructure.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-hash-match): In the
trivial key case, we are wastefully installing the same
expression as both a guard in the guard-chain and as a
test-expr. We should not be frobbing vm.test-expr.
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-predicate-match): Promote
condition from test-expr into guard-chain.
|
|
|
|
|
| |
* tests/011/patmatch.tl: Predicates must also be tested
earlier, as guard conditions.
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-atom-match): Do not
express the match for the atom via test-expr. That is
too late. It needs to be a guard in the guard chain.
|
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: Even though bar mismatches
foo, the second element @(all) is processed and
tries to collect the list. This results in an
error due to the list being improper.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With this commit, the new broken test case passes.
The main issue is not clearly separating temporary variables
in mach-guards from public variables.
* share/txr/stdlib/match.tl (match-vars): Remove pure-vars and
pure-var-exprs from this inheritance base, as well as the
related lets method.
(match-guard): Add the "pure" slots here, under new names:
pure-temps and pure-temp-exprs. This renaming is for clarity.
Add the lets method here, based on these new variables.
Add new slots temps, representing the impure temps.
There is no temp-exprs because impure temps are bound
to nil and later assigned.
(compiled-match get-temps): Method removed.
(compiled-match get-vars): Rewritten to avoid using get-temps
which doesn't exist any more. This method has a clear purpose:
to all the public variables coming from the patterns themselves,
whether those variables are promoted into a guard-chain for
early binding or whether they are attached on the
compiled-match object.
(compiled-match wrap-guards): Ensure that the new temps
from the guard-chain objects are bound with let.
(compile-struct-match, compile-vec-match,
compile-range-match, compile-dwim-predicate-match,
compile-cons-structure, compile-hash-match): pure-vars rename.
(compile-loop-match): We no longer bind cm.(get-temps) here.
That method doesn't exist. If we are not doing @(some), we
bind cm-vars: the public vars collected from cm. We need
local copies of them to catch their values and accumulate them
into list. In the match-guard constructor, we move the
collect-gens into temps; they are not public variables.
(compile-parallel-match): Drop ^(let ,pm.(get-temps) ...) from
the expansion.
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: It looks like there is still
a problem with scoping. An inner x is assigned the correct
value, leaving the outer x nil.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-loop-match): We must use
the get-vars method of a compiled-match to get a list of its
vars, and not directly access the vars slot.
The list of vars must include all the non-temporary variables
from the guard-chain. This is important in these rules because
they specially treat the guard-chain and do not integrate
it into their own guard chain directly.
|
|
|
|
|
| |
The matcher has a bug: the loop patterns are not collecting
the variables from enclosed parallel patterns.
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (compiler comp-let): The eenv
variable is used only in one place; the immediately next
binding for fenv. Let's eliminate it.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/optimize.tl (rewrite-case): New macro,
combining rewrite, lambda and match-case.
(basic-blocks thread-jumps): Condense using rewrite-case,
and unfold some of the expressions into longer lines,
since everything has moved quite a bit to the left.
|
|
|
|
|
| |
* share/txr/stdlib/optimize.tl (basic-blocks thread-jumps):
Wrap long pattern expressions.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (comp-switch): Convert the list
of labels for the switch instruction from vector to list.
This ends up a vector due to contagion from the sys:switch
special operator syntax.
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (compiler comp-lambda-impl):
Use the same "l" prefix for the skip label that is used
elsewhere in the compiler.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/optimize.tl (basic-blocks thread-jumps):
Also thread the implicit branch performed by close
instructions. If a close instruction branches to an
unconditional jump, then rewrite the close to jump that jump's
target.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/optimize.tl (basic-blocks thread-jumps): If
an (ifq RX RY label-X) instruction branches to an
(ifq RX RY label-Y) instruction, replace it with that
instruction. Moreover, if (if RX RY label-X) jumps to a
(jmp label-Y) instruction, also replace it with
(if RX RY label-Y).
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl: Load the new optimize module.
(compiler optimize): New method.
(compile-toplevel): Pass code through optimize method.
* share/txr/stdlib/optimize.tl: New file.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-dwim-predicate-match):
Drop redundant bindable check of sym, since compile-var-match
checks this. Support third argument which gives a pattern or
variable which captures the value from the predicate function,
which might be interesting (not just true/false).
* tests/011/patmatch.tl: New tests.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-dwim-predicate-match):
New function.
(compile-match): Route dwim symbol to
compile-dwim-predicate-match.
* txr.1: Documented.
|
|
|
|
|
| |
* txr.1: Under Pattern operator hash, include range
patterns wih non-trivial contents as being non-trivial.
|
|
|
|
|
|
|
|
|
|
| |
* checkman.txr (check-meti): New pattern function
which simply diagnoses any .meti. This relies on the fact that
.mono/.onom blocks are matched and consumed by by another rule.
All valid .meti lines are consumed as part of these blocks,
so any .meti that remain must be outside.
* txr.1: Fix numerous occurrences of this.
|
|
|
|
|
|
| |
* txr.1: Fix typo under Range match. Remove the documentation
for the nonexistent pattern operator @(rcons ...) that
was supposed to be removed before release 249.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This addresses a bug manifesting itself as a regression in the
behavior of @(freeform), which was reported by Frank Schwidom.
The sub_str operation calls lazy_subs_str for a lazy string.
But lazy_sub_str again relies on sub_str for extracting part
of the lazy string prefix. But sub_str can potentially return
the whole object rather than a copy of a substring of it.
In this case, lazy_sub_str produces a new lazy string object
which shares the prefix string object with the original
lazy string. This is incorrect because the lazy string data
type destructively manipulates the prefix. It means that
operations one one lazy string are mucking with the prefix of
another lazy string.
* lib.c (lazy_sub_str): When creating the new lazy string
object, make a copy of the prefix string pulled from the
original. We do the carefully: the copy of the prefix is made
before the make_obj call which allocates the new lazy string,
otherwise we create a wrong-way assignment from the
perspective of generational GC.
* tests/006/freeform-4.txr: New test case, from Frank.
* tests/006/freeform-4.expected: Expected output of test case.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (sub_str): If compatibility is requested, with a value
of 215 or less, then disable the optimization of returning
the original string without making a copy. This was found
to break the @(freeform) directive. That regression alerts me
to the fact that I should have made this subject to
compatibility; some user code could be affected.
* txr.1: New compat note added, under 215.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
| |
* txr.1: Add anote that a pattern a..b matches rcons syntax,
and add examples.
* tests/011/patmatch.tl: new examples from doc added as tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes the following print-read consistency issue.
Both of these objects print as @a..@b.
1> '@(rcons a b)
@a..b
2> '(rcons @a b)
@a..b
We want only the second case. After the this fix:
1> '(rcons @a b)
@a..b
2> '@(rcons a b)
@(rcons a b)
* lib.c (obj_print_impl): In the sys:expr case, we check
whether the head of the argument is rcons. If so, we adjust a
few local variables and branch directly to the generic list
case via goto to print the argument as (rcons ...) without
conversion to dotdot range notation.
|