summaryrefslogtreecommitdiffstats
path: root/tests/011
Commit message (Collapse)AuthorAgeFilesLines
* tests: add forgotten test for new expansion rule.Kaz Kylheku2022-05-211-0/+11
| | | | | | | | 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
* lambda-match: bug: over-strict match in variadic pattern.Kaz Kylheku2022-05-111-0/+14
| | | | | | | | | | | | * 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.
* matcher: test case for `@{nil #/regex/}`.Kaz Kylheku2022-02-091-0/+2
| | | | * tests/011/patmatch.tl: New tests for recently fixed issue.
* matcher: bug: quasiliteral allowing prefix matches.Kaz Kylheku2022-02-041-1/+4
| | | | | | | | * 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.
* New function: match-fboundp.Kaz Kylheku2022-01-171-1/+6
| | | | | | | | | | | | | | | | | | 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.
* keyparams: fix broken.Kaz Kylheku2022-01-171-0/+38
| | | | | | | | | | | | | | | | | | | 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.
* match: allow bound variables with regex modifier.Kaz Kylheku2021-12-271-0/+6
| | | | | | | | | * stdlib/match.tl (expand-quasi-match): Add regex cases with bound variable. * tests/011/patmatch.tl: Test cases for this. * txr.1: Documented.
* each-match macro family: missing anon block.Kaz Kylheku2021-12-081-0/+3
| | | | | | | | | | | | | | | | | * 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.
* match: unquoted quasiliteral patterns don't work.Kaz Kylheku2021-10-261-0/+5
| | | | | | * tests/011/patmatch.tl: Add failing test cases. * txr.1: Document desired requirements.
* matcher: rename error-throwing macros.Kaz Kylheku2021-08-191-5/+5
| | | | | | | | | | | | | | | * 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.
* matcher: new must-match and must-match-case macros.Kaz Kylheku2021-08-131-0/+9
| | | | | | | | | | | | | * 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, lib, tests: use defvarl where possible.Paul A. Patience2021-07-052-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* matcher: new looping macros.Kaz Kylheku2021-06-241-0/+25
| | | | | | | | | | | | | | * 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.
* txr-case: upkeep.Kaz Kylheku2021-06-162-0/+13
| | | | | | | | | | | | | | | | | | | * 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.
* defsymacro: regression: don't expand replacement.Kaz Kylheku2021-06-151-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* tests: remove *stderr* to *stdnull* redirection.Kaz Kylheku2021-06-111-8/+6
| | | | | | | | | | | | | | 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.
* matcher: doc fix, quasiquote examples, new test.Kaz Kylheku2021-06-041-0/+1
| | | | | | | * tests/011/patmatch.tl: New test case. * txr.1: Heading fix: Quasiquote matching notation, not quasiliteral. Examples of quasiquote notation added.
* json: pattern matching test cases and bugfix.Kaz Kylheku2021-06-031-0/+17
| | | | | | | | | | | | | * 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.
* matcher: allow hash pattern to omit values.Kaz Kylheku2021-05-241-0/+7
| | | | | | | | | | | | 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.
* matcher: new "each-match family" of macros.Kaz Kylheku2021-05-041-0/+53
| | | | | | | | | | | | | | | | | | * 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.
* matcher: make use of mtest in test suite.Kaz Kylheku2021-04-271-111/+122
| | | | | * tests/011/patmatch.tl: Use mtest throughout to condense the syntax.
* matcher: add some test variants.Kaz Kylheku2021-04-261-2/+20
| | | | | | | * 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.
* matcher: quasi match incorrectly treats nil as bound.Kaz Kylheku2021-04-261-1/+5
| | | | | | | | | | | | * 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.
* matcher: bugfix in `text{rest}` case.Kaz Kylheku2021-04-261-0/+3
| | | | | | * share/txr/stdlib/match.tl (expand-quasi-match): Calculate npos correctly relative to current pos. Use match-str rather than starts-with.
* matcher: more quasi tests: coverage of all cases.Kaz Kylheku2021-04-251-1/+8
| | | | | | * 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.
* match: third round of quasi tests and fixes.Kaz Kylheku2021-04-251-0/+14
| | | | | | | * 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.
* matcher: second round of quasi tests and fixes.Kaz Kylheku2021-04-251-0/+6
| | | | | | | * 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.
* matcher: first round of quasi tests and bugfix.Kaz Kylheku2021-04-251-0/+10
| | | | | | | | | | * 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.
* matcher: compile the test cases.Kaz Kylheku2021-04-221-6/+13
| | | | | | | | * 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.
* matcher: defmatch: useful :env parameter.Kaz Kylheku2021-04-211-0/+15
| | | | | | | | | | | | | | | | | | | * 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.
* matcher: new pattern operator @(end)Kaz Kylheku2021-04-201-0/+7
| | | | | | | | | | | | | | | * 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.
* matcher: first pattern macro, sme.Kaz Kylheku2021-04-191-0/+37
| | | | | | | | | | | | * 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.
* tests: implicitly generate empty .expected files.Kaz Kylheku2021-04-122-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* matcher: add @(or) test involving existing variables.Kaz Kylheku2021-02-081-0/+5
| | | | | | | * 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.
* matcher: @(and) back-referencing test.Kaz Kylheku2021-02-081-0/+3
| | | | | | * tests/011/patmatch.tl: back-referencing between the expressions in an @(and) patter has recently been introduced, and needs some coverage.
* matcher: fix backreferencing in predicate.Kaz Kylheku2021-02-081-0/+6
| | | | | | | | | * 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.
* matcher: test for dotted variable in predicate.Kaz Kylheku2021-02-081-0/+4
| | | | * tests/011/patmatch.tl: New test case.
* matcher: remove @(op ...) pattern.Kaz Kylheku2021-02-061-2/+2
| | | | | | | | | | | | | | | 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.
* matcher: redesign predicate pattern.Kaz Kylheku2021-02-061-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | * 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.
* matcher: back-reference Lisp variables.Kaz Kylheku2021-02-051-0/+21
| | | | | | | | | | | | | | | | * 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.
* matcher: rearrange match order of @(with).Kaz Kylheku2021-02-051-2/+7
| | | | | | | | | | | | | | | | | 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.
* matcher: lambda-match: redoc, bugfix, test-casesKaz Kylheku2021-02-041-0/+50
| | | | | | | | | | | | | | | * share/txr/stdlib/match.tl (expand-lambda-match): In a case that takes the maximum number of fixed args and no dotted pattern, in a function that is variadic, we must assert that the rest parameter is nil: there are no additional arguments. In the lambda args, we must generate the colon that separates the optional arguments. * tests/011/patmatch.tl: basic test cases for lambda-match and defun-match. * txr.1: lambda-match and defun-match redocumented, with examples.
* matcher: new failing backreferencing test case.Kaz Kylheku2021-02-021-0/+4
| | | | | | | | | | * 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.
* matcher: new @(with) operator.Kaz Kylheku2021-02-011-0/+8
| | | | | | | | | | | | * 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.
* matcher: rename @(let) to @(as).Kaz Kylheku2021-02-011-6/+6
| | | | | | | | | | | | | * 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.
* matcher: adding test case for @(or) regression.Kaz Kylheku2021-02-011-0/+3
| | | | | | | * 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.
* matcher: bugfix: bad stray code in @[...] matcher.Kaz Kylheku2021-02-011-0/+4
| | | | | | | | | | * 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.
* matcher: bugfix: @nil isn't trivial.Kaz Kylheku2021-01-291-0/+1
| | | | | | | | | | | | | * 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.
* matcher: restructuring to fix new broken case.Kaz Kylheku2021-01-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* mather: new bad (@(predicate) @(all ...)) test case.Kaz Kylheku2021-01-271-0/+2
| | | | | * tests/011/patmatch.tl: Predicates must also be tested earlier, as guard conditions.