| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a pattern variable match like @foo references a global
symbol macro, that's treated as an existing expression to
match, and not a new binding. However, local symbol macros
are not treated this way; they are invisible to variable
patterns. That is an unintended inconsistency.
* stdlib/match.tl (var-list exists): Use lexical-binding-kind
rather than lexical-var-p. This returns true for lexical
symbol macros also.
* tests/011/patmatch.tl: New test cases.
* txr.1: Documentation revised to clarify that both global
and local symbol macros are considered to be existing variable
bindings by pattern matching.
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: Move the form which compiles the
entire file to the end of the file, so that all the
interpreted test cases complete before we compile.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stdlib/match.tl (match-cond): New macro.
* autoload.c (match_set_entries): match-cond triggers
autoload of match module.
* tests/011/patmatch.tl: Tests.
* txr.1: Documented.
* stdlib/doc.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Parameter list macros work in inside macro parameter lists,
like they do in function parameter lists. However, they
ony work at the top level. Macro parameter lists are nested;
they may contain nested parameter lists that match
corresponding shapes in the argument list.
This patch extends parameter list macros to work in
nested macro parameter lists.
* eval.c (expand_opt_params_rec, expand_params_rec):
These two functions must be extended to take a body
argument, and to return not just an expanded parameter
list but a parameter list accompanied by a body.
We do that by making them return a cons cell, whose
car is the expanded parameter list and the cdr is
the possibly transformed body. Additionally, these
functions now call expand_param_macro on nested
macro parameter lists.
(expand_params): This function becomes slightly simpler
as a result of the above changes. Because expand_params_rec
already returns a cons cell holding a parameter list and
body, we just return that as-is.
* tests/011/keyparams.tl: Added some tests of this, vie the
standard :key parameter list macro. A macro is tested
which has a nested (:key ...) parameter list in a required
parameter position as well as in an optional position.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (make_var_shadowing_env): We cannot return the
original env in the empty variable case, but earnestly
make a new one. This function is used by the expander when
walking the lbind/fbind special from emitted by labels/flet.
That form clobbers the environment via make_fun_shadowing_env,
which calls make_var_shadowing_env and then destructively
moves the variable bindings to the function binding slot of
the environment. The manifestation is that when we have
(symacrolet ((x 1)) (labels () x)), the x fails to expand; it
has been wrongly moved to the function bindings area of the
macro environment.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Quasiquote patterns not containing unquotes are not
working, because the parser transforms them into
quoted objects. For instance ^#S(time) becomes
the form (quote #S(time)) and not the
form (sys:qquote (sys:struct-lit time)).
The pattern matching compiler doesn't treat quote
specially, only sys:qquote.
* parser.y (unquotes_occur): Function removed.
(vector, hash, struct, tree, json_vals, json_pairs):
Remove use of unquotes_occur. Thus vector, hash,
struct, tree and JSON syntax occurring within a
backquote will be turned into a special literal
whether or not it contains unquotes.
* lib.c (obj_print_impl): Do not print the
form (sys:hash-lit) as #Hnil, but #H().
* stdlib/match.tl (transform-qquote): Add a case
which will handle ^#H(), as if it were ^H(()).
Bugfix in the ^H(() ...) case. The use of @(coll)
means it fails to match the empty syntax when
no key/value pairs are specified, whereas
@(all) respects vacuous truth.
* test/011/patmatch.tl: A few tests.
* y.tab.shipped, y.tab.h.shipped: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For instance @(<= 10 @nil 20) is a pattern which matches
a number between 10 and 20, without binding a variable.
* stdlib/match.tl (compile-predicate-match): Looks like
this code was already halfway expressing the intent that
the avar could be nil, because arg-var takes the value
of avar if that is non-nil, otherwise a gensym is
substituted. What was missing was that the gensym that
replaces nil must also be substituted into the predicate.
* tests/011/patmatch.tl: New tests.
* txr.1: Document that the variable embedded in a
predicate may be null.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* tests/011/patmatch.tl,
* tests/019/pct-fun.tl: Disable unused
warnings around file self-compilation.
* tests/011/tree-bind.tl: Fix one unused
variable instance using interned symbol.
* tests/011/compile.tl: Disable unused
warnings around all file compilation.
* tests/012/lambda.tl: Use the parameter
of one trivial lambda.
* tests/common.tl: Disable unused warnings
around compiled tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (expand_params_rec, bind_macro_params): Handle t
specially everywhere a parameter can occur. Expansion
allows the syntax through without extending the
environment with a t variable; binding walks over
the structure without binding a variable.
* stdlib/compiler.tl (expand-bind-mac-params): Likewise,
handle occurrences of t, suppressing the generation of
and assignment to variables, while ensuring that
initializing expressions are evaluated.
* tests/011/tree-bind.tl: New file.
* txr.1: Documented.
|
|
|
|
|
|
|
|
| |
This was developed together with what became the May 12 commit
1162a735b61c1c5086fb6055471ee35cc8ed62a4; I just forgot to
git add the file.
* tests/011/macros-4.tl
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stdlib/match.tl (expand-lambda-match): A pattern that
is shorter than the maximum number of arguments is
augmented with a check ensuring that no fixed arguments
are present beyond those that the pattern requires.
However, this check must be omitted if the pattern is
variadic, because those excess arguments match its tail
pattern.
* tests/011/patmatch.tl: Cases added.
|
|
|
|
| |
* tests/011/patmatch.tl: New tests for recently fixed issue.
|
|
|
|
|
|
|
|
| |
* stdlib/match.tl (expand-quasi-match): When matching `text`
or `@var`, which are matching in the final position of the
specimen, it is not good enough that match-str returns true;
we must check that the entire string was matched.
Reported by Paul A. Patience.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
User vapnik spaknik was asking in the mailing list whether
there is an existence test for TXR pattern functions. Now
there is.
* eval.c (eval_init): Register match-fboundp intrinsic.
* match.c (match_fbound): New function.
* match.h (match_fbound): Declared.
* tests/011/txr-case.txr: New test cases.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Issues reported by user vapnik spaknik. The evaluation of init
forms is incorrect. Init forms like '(x) evaluate to
'(x) rather than (x), Also, init forms are evaluated even when
the argument is present, so the entire current approach is
wrong.
* stdlib/keyparams.tl (extract-keys, extract-keys-p,
build-key-list-expr): Functions removed.
(stuff-key-params): New function.
(:key): Rework using simplified approach, with just the
stuff-key-params helper. All variables from the keyword
parameter list are bound with let. Generated code searches
the keyword parameters for values and assigns the variables as
needed, evaluating default init forms in the not-found cases.
* tests/011/keyparams.tl: New file.
|
|
|
|
|
|
|
|
|
| |
* stdlib/match.tl (expand-quasi-match): Add regex cases with
bound variable.
* tests/011/patmatch.tl: Test cases for this.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* txr.1: Adding the missing requirement that each-match
and the other macros in that family must have an implicit
anonymous block around the body forms. This is a requirements
bug, effectively: the programmer expects these operators to be
consistent with the each operator, as part of the same family.
* match.tl (each-match-expander): Implement the requirement.
Since we are using mapping functions, we must use temporary
variables: the evaluation of the expressions which produce the
sequence argument values to the mapping functions must be
outside of the anonymous block. The block must surround only
the function call.
* tests/011/patmatch.tl: Add small test case covering this.
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: Add failing test cases.
* txr.1: Document desired requirements.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stdlib/match.tl (must-match): Renamed to just match.
It's just when-match without the "when".
(must-match-case): Renamed to match-ecase, consistent
with the case -> ecase naming scheme.
* lisplib.c (match_set_entries): Names updated here.
* tests/011/patmatch.tl: Test cases updated.
* txr.1: Names updated here.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_set_entries): Intern the match-error symbol.
Register autoloads for must-match and must-match-case.
* stdlib/match.tl (match-error): Register exception symbol, as subtype
of match-error.
(must-match, must-match-case): New macros.
* tests/011/patmatch.tl: Test cases.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* genman.txr (dupes, tagnum): Replace defvar with defvarl.
* stdlib/doc-lookup.tl (os-symbol): Same.
* tests/011/macros-3.tl (x): Same.
* tests/011/mandel.txr (x-centre, y-centre, width, i-max, j-max, n)
(r-max, pixel-size, x-offset, y-offset): Same.
(file, colour-max): Delete (unused) variables.
* tests/012/circ.tl (x): Replace defvar with defvarl.
* tests/012/stack.tl (stack-limited): Same.
* tests/012/struct.tl (s): Same.
* tests/013/maze.tl (vi, pa, sc): Delete variables. Use
function arguments instead.
(usage): Fix typo.
* tests/014/dgram-stream.tl (family): Rename to...
(*family*): ...this.
* tests/014/socket-basic.tl (socktype): Rename to...
(*socktype*): ...this.
(%iters%): Replace defvar with defvarl.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_set_entries): Autoload on new while-match,
while-match-case and while-true-match-case symbols.
* share/txr/stdlib/match.tl (while-match, while-match-case,
while-true-match-case): New macros.
* tests/011/patmatch.tl: Tests.
* txr.1: Documented.
* share/txr/stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/txr-case.tl (txr-case-impl): If the input
is a stream, then convert it to a lazy list of lines, so that
running multiple functions against it produces sane,
backtracking behavior, like a @(cases) construct.
* tests/011/txr-case.expected: Updated.
* tests/011/txr-case.txr: Now actually contains a test case
for txr-case.
* txr.1: Address an issue reported by Paul A. Patience: the
input to match-fun, txr-if and txr-when may be a stream. That
has always been the case in the implementation. Also document
that when the input is a single string, it is treated as a
list. Document the new requirement in txr-case that a stream
is converted into lazy list of lines.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a regression that was introduced in 191. The change in
191 was trying to prevent defsymacro from being expanded
immediately by the expander except in 190 compatibility.
Unfortunately, this caused the whole defsymacro block not to
be entered unless in 190 compatibility, otherwise taking the
common exit which returns form_ex, containing the expanded
replacement form.
* eval.c (do_expand): Split up implementation of defvarl and
defsymacro. In the defsymacro block, do not do any expanding
on entry. Absent of compatibility mode, we just do some sanity
checks and pass the entire form through. In 262 compatibility,
we do the expansion to obtain form_ex. Then all the previous
compat logic is wrapped in that block.
* tests/011/macros-3.tl: Add a test case which confirms that
symbol macros are lazily expanded. Weakness in the test suite
is how these regressions creep in.
* txr.1: Improve defsymacro documentation, spelling out
clearly that the unexpanded replacement form is associated
with the symbol. Eliminate obsolescent text suggesting that
defsymacro is evaluated at macro time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The recent commit 225ff2fa2fdb9e5169db5e2c06dc3b0053b775bb
titled "errors: avoid premature release of deferred warnings."
obviates the need for dealing with noise when detecting
errors from test cases.
* patmatch.tl: Remove macro-time-let around several
test cases.
* tests/012/ifa.tl: Likewise.
* tests/common.tl (macro-time-let): Macro removed.
|
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: New test case.
* txr.1: Heading fix: Quasiquote matching notation, not
quasiliteral. Examples of quasiquote notation added.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* parser.y (json_val): We must nreverse the json_pairs which
were pushed in right to left order. This didn't matter for
constructing hashes so it was left out, but under quasiquoting
the order matters: it determines the order of evaluation and
of pattern matching.
* tests/011/patmatch.tl: New quasiquoting pattern matching
cases, including JSON.
* y.tab.c.shipped: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The @(hash ...) operator now allows key-only patterns
like (42) or (@x), where x could be bound or unbound.
This has separate semantics from when a value is present.
* share/txr/stdlib/match.tl (compile-hash-match): Implement.
* tests/011/patmatch.tl: Test.
* txr.1: Document.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_set_entries): New autoload symbols:
each-match, append-matches, keep-matches, each-match-product,
append-match-products, keep-match-products.
* share/txr/stdlib/doc-syms.tl: Updated.
* share/txr/stdlib/match.tl (each-match-expander): New
function.
(each-match, append-matches, keep-matches, each-match-product,
append-match-products, keep-match-products): New macros.
* tests/011/patmatch.tl: New tests covering each macro,
far from exhaustively.
* txr.1: Documented.
|
|
|
|
|
| |
* tests/011/patmatch.tl: Use mtest throughout to condense the
syntax.
|
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: Add variants based on existing tests
which insert an extra character at the left that is matched by
a bound variable. This tests that the remainder of the pattern
is following the offset numeric position within the string.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (expand-quasi-match): bound-p
local function must return nil if the symbol is nil.
* share/txr/stdlib/match.tl: New test cases testing that @nil
is treated as an unbound variable in the
non-consecutive-variables test. Also, making duplicates of
certain tests that start with a text match and sticking @nil
as the first element into them, so that the text match is
forced to be the second item.
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (expand-quasi-match): Calculate
npos correctly relative to current pos. Use match-str rather
than starts-with.
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: More tests. All explicitly coded
cases covered, except the fall-through situations we are
not yet catching in expand-quasi-match.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (expand-quasi-match): Add case fo
r unbound var followed by var, followed by nothing.
* tests/011/patmatch.tl: New tests.
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (expan-quasi-match): Use rest
variable consistently instead of (cdr args). Two instances of
(cdr rest) should just be rest. New case added for variable
with no modifiers followed by text being the last item.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (expand-quasi-match): The return
value of search-str isn't a length but an absolute position.
We not only fix a bug, but lose a useless calculation.
* tests/011/patmatch.tl: New test cases for quasiliteral
patterns, starting with the most rudimentary.
Last one broke, due to the above issue.
|
|
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: Wrap one test with compile-only and
eval-only so that the compiler ignores it. Add a form
at the end of the file, similarly ignored by the compiler
to compile the file. This compiles and executes all the test
cases.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-match): Pattern macro
expanders now have an environment parameter. We turn the list
of variables that have been bound so far into a fake
macro-time lexical environment, the parent of which is the
surrounding environment. The pattern macro can query this
using the lexical-var-p function to determine whether a given
variable already has a binding, either in the pattern, or
in the surrounding lexical environment.
(defmatch): Generate a two-argument lambda, and use the new
mac-env-param-bind to make the environment object available
to the user-defined expansion.
* tests/011/patmatch.tl: New test cases for this environment
mechanism, and also for defmatch itself.
* txr.1: Document role of :env under defmatch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/doc-syms.tl: New entry for end.
* share/txr/stdlib/match.tl (check, check-end, check-sym,
loosen, pat-len): New functions, taken from original local
functions of sme macro.
(sme): Refactored by hoisting local functions out. Some
local variable renaming.
(end): New pattern macro.
* tests/011/patmatch.tl: New test for end.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (match_instantiate): Intern sme symbol.
* share/txr/stdlib/doc-syms.tl: Update with sme entry.
* share/txr/stdlib/match.tl (sme): New defmatch macro.
* tests/011/patmatch.tl: New tests for sme.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Makefile (%.expected): New implicit rule. Whenever a test requires a
.expected file, if it is missing, we create an empty one.
This file will be treated as an intermediate by GNU Make, which means
that it will be deleted when make terminates.
* tests/012/compile.tl: Some of the .tl files no longer have
an .expected file, so we have to test for that in the
catenating logic.
* tests/008/call-2.expected,
* tests/008/no-stdin-hang.expected,
* tests/011/macros-3.expected,
* tests/011/patmatch.expected,
* tests/012/aseq.expected,
* tests/012/ashwin.expected,
* tests/012/compile.tl,
* tests/012/cont.expected,
* tests/012/defset.expected,
* tests/012/ifa.expected,
* tests/012/oop-seq.expected,
* tests/012/parse.expected,
* tests/012/quasi.expected,
* tests/012/quine.expected,
* tests/012/seq.expected,
* tests/012/struct.expected,
* tests/012/stslot.expected,
* tests/014/dgram-stream.expected,
* tests/014/in6addr-str.expected,
* tests/014/inaddr-str.expected,
* tests/014/socket-basic.expected,
* tests/015/awk-fconv.expected,
* tests/015/split.expected,
* tests/015/trim.expected,
* tests/016/arith.expected,
* tests/016/ud-arith.expected,
* tests/017/ffi-misc.expected,
* tests/018/chmod.expected: Empty file deleted.
|
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: New test case showing that existing
variables that don't match in an @(or) retain their values;
they do not become nil, unlike freshly bound variables in
non-matching or-clauses.
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: back-referencing between the
expressions in an @(and) patter has recently been introduced,
and needs some coverage.
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-predicate-match): Always
allocate res-var as a gensym; do not use resvar. Otherwise we
will freshly bind resvar as a local, failing to back-reference.
* tests/011/patmatch.tl: Add test cases, the second of which
fails before this change.
|
|
|
|
| |
* tests/011/patmatch.tl: New test case.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All he typical uses of this are better served by the new
predicate match. If op is really needed, it can be used with
the DWIM form of the predicate, as in @[(op ...) ...].
* share/txr/stdlib/match.tl (compile-op-match): Function
removed.
(compile-match): Remove op case.
* tests/011/patmatch.tl: Keep op test cases by converting them
to predicate test cases.
* txr.1: Documentation removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (compile-dwim-predicate-match):
Function removed. There is no more special @(dwim ...)
or @[...] pattern.
(compile-predicate-match): Function rewritten, providing
different syntax and semantics.
(compile-match): dwim dispatch removed.
(non-triv-pat-p): Replaced @(op ...) calls with new-style
predicate syntax.
(var-pat-p): Likewise, and upgraded one instance of old-style
predicate syntax to new.
* share/txr/stdlib/compiler.tl (reduce-or): Adjust predicate
pattern to new style.
* share/txr/stdlib/optimize.tl (dedup-labels): Likewise.
* tests/011/patmatch.tl: All test cases with predicate syntax
are updated to new style. One test case removed; some added.
* txr.1: Predicate patterns re-documented. All examples
involving predicate patterns updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/match.tl (struct var-list): New slot, menv.
(var-list exists): Method now falls back on lexical scope and
dynamic variables.
(get-var-list): New function.
(when-match, if-match, match-case, when-exprs-match): Capture
macro environment and use get-vars-list to convert to a vars
object which carries it as the menv slot. With this, the
compiler framework has access to the lexical environment.
* tests/011/patmatch.tl: Test cases of back-referencing with
Lisp lexicals.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The @(with side-pat expr main-pat) syntax becomes
@(with main-pat side-pat expr), which is more useful.
Also, the main-pat can be omitted.
* share/txr/stdlib/match.tl (compile-with-match): Recognize
two forms of the syntax: two argument form with main-pat
omitted and the full form. In the full form, main-pat is
on the left now and processed first, so we have to rearrange
the compilation and integration order.
* tests/011/patmatch.tl: Existing tests updated. Two-argument
test added.
* txr.1: Updated.
|