diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f2bf94..c961eed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: if-no-files-found: error # Separate job because it needs the network *inside* the build: contrib/ - # pulls Quicklisp (for clweb) on top of cl-prolog/cl-weave from this flake's + # pulls Quicklisp (for clweb) on top of cl-prolog-kit/cl-weave from this flake's # inputs, and the Nix sandbox has none. # # continue-on-error because contrib is opt-in and isolated from the core @@ -124,7 +124,7 @@ jobs: --eval "(quicklisp-quickstart:install)" ' - # `nix develop` puts cl-prolog/cl-weave from this flake's inputs on + # `nix develop` puts cl-prolog-kit/cl-weave from this flake's inputs on # CL_SOURCE_REGISTRY (see flake.nix devShells.default.shellHook). - name: Run contrib verification run: nix develop --command sbcl --script contrib/verify-contrib.lisp diff --git a/README.md b/README.md index 0a939d0..11ceedd 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ to a double-buffered render loop; see ## Install The core `cl-tty-kit` system is dependency-free, but its test system depends on -[`cl-prolog`](https://github.com/nerima-lisp/cl-prolog) and +[`cl-prolog-kit`](https://github.com/nerima-lisp/cl-prolog-kit) and [`cl-weave`](https://github.com/nerima-lisp/cl-weave), neither of which is on Quicklisp. Nix is the supported way to put both on `CL_SOURCE_REGISTRY`: diff --git a/cl-tty-kit.asd b/cl-tty-kit.asd index b1bb06d..4ca9930 100644 --- a/cl-tty-kit.asd +++ b/cl-tty-kit.asd @@ -6,9 +6,9 @@ ;;; See PACKAGE_STANDARD.md "asd の書き方". (in-package #:asdf-user) -;; nerima-lisp/cl-prolog and nerima-lisp/cl-weave (see docs/src/guide/logic-engine.md +;; nerima-lisp/cl-prolog-kit and nerima-lisp/cl-weave (see docs/src/guide/logic-engine.md ;; and t/sgr-prolog-oracle-test.lisp) are both used only by :CL-TTY-KIT/TEST below -- -;; cl-prolog as a differential-testing oracle cross-checking the hand-written +;; cl-prolog-kit as a differential-testing oracle cross-checking the hand-written ;; SGR/CSI decoders, cl-weave as the test framework -- never by :CL-TTY-KIT ;; itself; those two stay test-only regardless of what :CL-TTY-KIT's own ;; :DEPENDS-ON grows to (see the note on its :DEPENDS-ON below). Neither is @@ -150,7 +150,7 @@ :bug-tracker "https://github.com/nerima-lisp/cl-tty-kit/issues" :source-control (:git "https://github.com/nerima-lisp/cl-tty-kit.git") :serial t - :depends-on (#:cl-tty-kit #:cl-prolog #:cl-weave) + :depends-on (#:cl-tty-kit #:cl-prolog-kit #:cl-weave) :components ((:file "t/package") (:file "t/helpers-package-data") (:file "t/suite") diff --git a/contrib/README.md b/contrib/README.md index dbdc5e0..25138fb 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -4,26 +4,26 @@ Optional, opt-in integrations that layer external libraries on top of the core toolkit. **Nothing here is part of the core `cl-tty-kit` build or CI** — `:cl-tty-kit`'s own dependency is `sb-posix` (see the root README's "Compatibility" section). These modules pull additional libraries from -Quicklisp, or from `nerima-lisp/cl-prolog`, `nerima-lisp/cl-weave`, and +Quicklisp, or from `nerima-lisp/cl-prolog-kit`, `nerima-lisp/cl-weave`, and `nerima-lisp/cl-parser-kit` via this repository's `flake.nix` (`nix develop` puts all three on `CL_SOURCE_REGISTRY`, the same as `:cl-tty-kit/test`), and are loaded explicitly. -## `cl-tty-kit-cl-prolog-csi-grammar` — DCG grammar via nerima-lisp/cl-prolog +## `cl-tty-kit-cl-prolog-kit-csi-grammar` — DCG grammar via nerima-lisp/cl-prolog-kit A declarative recognizer for the ECMA-48 CSI (Control Sequence Introducer) -byte-class grammar, built on [`nerima-lisp/cl-prolog`](https://github.com/nerima-lisp/cl-prolog) +byte-class grammar, built on [`nerima-lisp/cl-prolog-kit`](https://github.com/nerima-lisp/cl-prolog-kit) (pulled from this repository's `flake.nix` inputs — it is not distributed by Quicklisp). `src/input-decode.lisp` already decodes CSI sequences imperatively on the render loop's hot path; this module instead expresses that same sequence shape — zero or more parameter bytes, then zero or more intermediate bytes, then exactly one final byte — as a `def-dcg-rule` -grammar run through `phrase`, demonstrating cl-prolog's DCG support +grammar run through `phrase`, demonstrating cl-prolog-kit's DCG support independently of the hand-written decoder. ```lisp -;; nix develop -- puts cl-prolog on CL_SOURCE_REGISTRY, once per shell -(asdf:load-system :cl-tty-kit-cl-prolog-csi-grammar) +;; nix develop -- puts cl-prolog-kit on CL_SOURCE_REGISTRY, once per shell +(asdf:load-system :cl-tty-kit-cl-prolog-kit-csi-grammar) (tty-csi-grammar:csi-sequence-valid-p "1;1H") ; => T (cursor position) (tty-csi-grammar:csi-sequence-valid-p "38;5;196m") ; => T (SGR, 256-color fg) @@ -35,7 +35,7 @@ independently of the hand-written decoder. A second, independent declarative recognizer for the same ECMA-48 CSI grammar as the DCG version above, built on [`nerima-lisp/cl-parser-kit`](https://github.com/nerima-lisp/cl-parser-kit)'s -`seq`/`many`/`type-token` parser combinators instead of cl-prolog's DCG rules +`seq`/`many`/`type-token` parser combinators instead of cl-prolog-kit's DCG rules (pulled from this repository's `flake.nix` inputs — it is not distributed by Quicklisp). `contrib/verify-contrib.lisp` cross-checks the two grammars agree on every case, the same differential-testing shape `t/sgr-prolog-oracle.lisp` @@ -64,7 +64,7 @@ that read attacker-controlled PTY bytes. It also regression-tests the DCG CSI grammar above. ```lisp -;; nix develop -- puts cl-prolog and cl-weave on CL_SOURCE_REGISTRY, once per shell +;; nix develop -- puts cl-prolog-kit and cl-weave on CL_SOURCE_REGISTRY, once per shell (asdf:load-system :cl-tty-kit-weave-tests) (cl-tty-kit/weave-property-tests:run-tests) ; => T on success @@ -88,7 +88,7 @@ loadable Lisp. ## Verifying the contrib `contrib/verify-contrib.lisp` exercises the Quicklisp-backed clweb tangle -integration, and additionally exercises the cl-prolog/cl-parser-kit/cl-weave +integration, and additionally exercises the cl-prolog-kit/cl-parser-kit/cl-weave integrations above when ASDF can find the relevant system (skipped, not failed, otherwise): diff --git a/contrib/cl-parser-kit-csi-grammar.lisp b/contrib/cl-parser-kit-csi-grammar.lisp index 94d14b7..5b1f56f 100644 --- a/contrib/cl-parser-kit-csi-grammar.lisp +++ b/contrib/cl-parser-kit-csi-grammar.lisp @@ -7,7 +7,7 @@ (:documentation "Advanced usage of nerima-lisp/cl-parser-kit: a parser-combinator recognizer for the same ECMA-48 CSI (Control Sequence Introducer) byte-class -grammar contrib/cl-prolog-csi-grammar.lisp recognizes via cl-prolog's DCG +grammar contrib/cl-prolog-kit-csi-grammar.lisp recognizes via cl-prolog-kit's DCG support. src/input-decode.lisp already decodes CSI sequences imperatively for the render loop's hot path; this module is a second, independent declarative specification of that same sequence shape -- zero or more diff --git a/contrib/cl-prolog-csi-grammar.lisp b/contrib/cl-prolog-kit-csi-grammar.lisp similarity index 89% rename from contrib/cl-prolog-csi-grammar.lisp rename to contrib/cl-prolog-kit-csi-grammar.lisp index cf1bd90..7c2815f 100644 --- a/contrib/cl-prolog-csi-grammar.lisp +++ b/contrib/cl-prolog-kit-csi-grammar.lisp @@ -1,13 +1,13 @@ -(defpackage #:cl-tty-kit/cl-prolog-csi-grammar +(defpackage #:cl-tty-kit/cl-prolog-kit-csi-grammar (:use #:cl) - (:import-from #:cl-prolog #:make-rulebase #:def-dcg-rule #:dcg-star #:phrase) + (:import-from #:cl-prolog-kit #:make-rulebase #:def-dcg-rule #:dcg-star #:phrase) (:nicknames #:tty-csi-grammar) (:documentation - "Advanced usage of nerima-lisp/cl-prolog: a DCG recognizer for the ECMA-48 CSI + "Advanced usage of nerima-lisp/cl-prolog-kit: a DCG recognizer for the ECMA-48 CSI (Control Sequence Introducer) byte-class grammar. `src/input-decode.lisp` already decodes CSI sequences imperatively for the render loop's hot path; this module instead gives that same sequence shape a declarative grammar -built from cl-prolog's `def-dcg-rule`/`phrase`, useful for validating or +built from cl-prolog-kit's `def-dcg-rule`/`phrase`, useful for validating or documenting the shape independently of the hand-written decoder. A CSI sequence body (the bytes after ESC [) is, per ECMA-48 section 5.4: @@ -18,7 +18,7 @@ final byte (0x40-0x7E).") #:tokenize-csi-body #:*csi-grammar*)) -(in-package #:cl-tty-kit/cl-prolog-csi-grammar) +(in-package #:cl-tty-kit/cl-prolog-kit-csi-grammar) (defun %csi-byte-kind (char) "Classify CHAR into an ECMA-48 CSI byte class, or NIL if it fits none." diff --git a/contrib/cl-tty-kit-cl-parser-kit-csi-grammar.asd b/contrib/cl-tty-kit-cl-parser-kit-csi-grammar.asd index 2efb138..a4791a8 100644 --- a/contrib/cl-tty-kit-cl-parser-kit-csi-grammar.asd +++ b/contrib/cl-tty-kit-cl-parser-kit-csi-grammar.asd @@ -2,8 +2,8 @@ ;;;; ;;;; A parser-combinator recognizer for the ECMA-48 CSI byte-class grammar, ;;;; built on nerima-lisp/cl-parser-kit -- a second, independent declarative -;;;; specification of the same grammar cl-tty-kit-cl-prolog-csi-grammar -;;;; recognizes via cl-prolog's DCG support. Load it explicitly from inside +;;;; specification of the same grammar cl-tty-kit-cl-prolog-kit-csi-grammar +;;;; recognizes via cl-prolog-kit's DCG support. Load it explicitly from inside ;;;; a Nix dev shell, which puts cl-parser-kit on CL_SOURCE_REGISTRY (see ;;;; flake.nix devShells.default.shellHook): ;;;; diff --git a/contrib/cl-tty-kit-cl-prolog-csi-grammar.asd b/contrib/cl-tty-kit-cl-prolog-csi-grammar.asd deleted file mode 100644 index 855002b..0000000 --- a/contrib/cl-tty-kit-cl-prolog-csi-grammar.asd +++ /dev/null @@ -1,16 +0,0 @@ -;;;; Optional contrib system. NOT part of the core cl-tty-kit build or CI. -;;;; -;;;; A DCG-based recognizer for the ECMA-48 CSI byte-class grammar, built on -;;;; nerima-lisp/cl-prolog. Load it explicitly from inside a Nix dev shell, -;;;; which puts cl-prolog on CL_SOURCE_REGISTRY (see flake.nix -;;;; devShells.default.shellHook): -;;;; -;;;; nix develop -;;;; (asdf:load-system :cl-tty-kit-cl-prolog-csi-grammar) - -(asdf:defsystem #:cl-tty-kit-cl-prolog-csi-grammar - :description "DCG recognizer for the ECMA-48 CSI grammar, built on nerima-lisp/cl-prolog." - :author "nerima-lisp" - :license "MIT" - :depends-on (#:cl-prolog) - :components ((:file "cl-prolog-csi-grammar"))) diff --git a/contrib/cl-tty-kit-cl-prolog-kit-csi-grammar.asd b/contrib/cl-tty-kit-cl-prolog-kit-csi-grammar.asd new file mode 100644 index 0000000..64cb2ea --- /dev/null +++ b/contrib/cl-tty-kit-cl-prolog-kit-csi-grammar.asd @@ -0,0 +1,16 @@ +;;;; Optional contrib system. NOT part of the core cl-tty-kit build or CI. +;;;; +;;;; A DCG-based recognizer for the ECMA-48 CSI byte-class grammar, built on +;;;; nerima-lisp/cl-prolog-kit. Load it explicitly from inside a Nix dev shell, +;;;; which puts cl-prolog-kit on CL_SOURCE_REGISTRY (see flake.nix +;;;; devShells.default.shellHook): +;;;; +;;;; nix develop +;;;; (asdf:load-system :cl-tty-kit-cl-prolog-kit-csi-grammar) + +(asdf:defsystem #:cl-tty-kit-cl-prolog-kit-csi-grammar + :description "DCG recognizer for the ECMA-48 CSI grammar, built on nerima-lisp/cl-prolog-kit." + :author "nerima-lisp" + :license "MIT" + :depends-on (#:cl-prolog-kit) + :components ((:file "cl-prolog-kit-csi-grammar"))) diff --git a/contrib/cl-tty-kit-weave-mutation-tests.asd b/contrib/cl-tty-kit-weave-mutation-tests.asd index 30ee719..2a6299f 100644 --- a/contrib/cl-tty-kit-weave-mutation-tests.asd +++ b/contrib/cl-tty-kit-weave-mutation-tests.asd @@ -5,7 +5,7 @@ ;;;; battery a unit test would use kills every mutation. This measures ;;;; whether the tests actually notice a wrong implementation, which ;;;; SB-COVER line/branch coverage alone cannot show. Load and run it -;;;; explicitly from inside a Nix dev shell, which puts cl-prolog and +;;;; explicitly from inside a Nix dev shell, which puts cl-prolog-kit and ;;;; cl-weave on CL_SOURCE_REGISTRY (see flake.nix ;;;; devShells.default.shellHook): ;;;; diff --git a/contrib/cl-tty-kit-weave-tests.asd b/contrib/cl-tty-kit-weave-tests.asd index 2bba87b..bf5000a 100644 --- a/contrib/cl-tty-kit-weave-tests.asd +++ b/contrib/cl-tty-kit-weave-tests.asd @@ -3,7 +3,7 @@ ;;;; Property-based fuzz tests built on nerima-lisp/cl-weave, exercising the ;;;; UTF-8 and input decoders against arbitrary octets plus the DCG-based CSI ;;;; grammar. Load and run it explicitly from inside a Nix dev shell, which -;;;; puts cl-prolog and cl-weave on CL_SOURCE_REGISTRY (see flake.nix +;;;; puts cl-prolog-kit and cl-weave on CL_SOURCE_REGISTRY (see flake.nix ;;;; devShells.default.shellHook): ;;;; ;;;; nix develop @@ -14,7 +14,7 @@ :description "Property-based fuzz tests for cl-tty-kit, built on nerima-lisp/cl-weave." :author "nerima-lisp" :license "MIT" - :depends-on (#:cl-tty-kit #:cl-weave #:cl-tty-kit-cl-prolog-csi-grammar) + :depends-on (#:cl-tty-kit #:cl-weave #:cl-tty-kit-cl-prolog-kit-csi-grammar) :components ((:file "weave-property-tests")) :perform (asdf:test-op (op system) (declare (ignore op system)) diff --git a/contrib/literate/tty-relations.clw b/contrib/literate/tty-relations.clw index 33eb760..d38959c 100644 --- a/contrib/literate/tty-relations.clw +++ b/contrib/literate/tty-relations.clw @@ -9,7 +9,7 @@ @*Clauses to an external ISO Prolog. A clause written as a plain Lisp list of the shape |(head . body)|, with logic variables as |?|-prefixed symbols, is -cl-prolog's own clause DSL shape (see the Rule DSL docs) and happens to match +cl-prolog-kit's own clause DSL shape (see the Rule DSL docs) and happens to match the convention the maintained |cl-prolog2| library uses to drive a full external ISO Prolog. This module captures --- literately --- the one structural rewrite that lets such a clause cross from the Lisp-list shape to diff --git a/contrib/verify-contrib.lisp b/contrib/verify-contrib.lisp index 35a5e54..eb55ca1 100644 --- a/contrib/verify-contrib.lisp +++ b/contrib/verify-contrib.lisp @@ -1,14 +1,14 @@ ;;;; Verify the optional contrib integrations. Run from the project root -;;;; inside a Nix dev shell, which puts nerima-lisp/cl-prolog and +;;;; inside a Nix dev shell, which puts nerima-lisp/cl-prolog-kit and ;;;; nerima-lisp/cl-weave on CL_SOURCE_REGISTRY (see flake.nix ;;;; devShells.default.shellHook): ;;;; ;;;; nix develop --command sbcl --script contrib/verify-contrib.lisp ;;;; ;;;; It exercises clweb (via tangling the literate module) from Quicklisp, -;;;; plus the nerima-lisp/cl-prolog DCG grammar, the nerima-lisp/cl-parser-kit +;;;; plus the nerima-lisp/cl-prolog-kit DCG grammar, the nerima-lisp/cl-parser-kit ;;;; combinator grammar, and nerima-lisp/cl-weave property tests. The -;;;; cl-prolog/cl-parser-kit/cl-weave checks are skipped, not failed, when +;;;; cl-prolog-kit/cl-parser-kit/cl-weave checks are skipped, not failed, when ;;;; ASDF cannot find the relevant system (i.e. outside a Nix dev shell with ;;;; CL_SOURCE_REGISTRY pointed at none of them). @@ -38,18 +38,18 @@ (equal '(:- (ancestor ?a ?b) (parent ?a ?b)) (funcall fn '((ancestor ?a ?b) (parent ?a ?b)))))))) -;;; --- nerima-lisp/cl-prolog DCG grammar -------------------------------------- -(if (asdf:find-system :cl-prolog nil) +;;; --- nerima-lisp/cl-prolog-kit DCG grammar -------------------------------------- +(if (asdf:find-system :cl-prolog-kit nil) (progn (handler-bind ((warning #'muffle-warning)) - (asdf:load-system :cl-tty-kit-cl-prolog-csi-grammar)) - (check "cl-prolog DCG grammar accepts a well-formed CSI body" + (asdf:load-system :cl-tty-kit-cl-prolog-kit-csi-grammar)) + (check "cl-prolog-kit DCG grammar accepts a well-formed CSI body" (funcall (read-from-string "tty-csi-grammar:csi-sequence-valid-p") "38;5;196m")) - (check "cl-prolog DCG grammar rejects an unterminated CSI body" + (check "cl-prolog-kit DCG grammar rejects an unterminated CSI body" (not (funcall (read-from-string "tty-csi-grammar:csi-sequence-valid-p") "1;1")))) - (format t "~&[SKIP] cl-prolog not on CL_SOURCE_REGISTRY (run inside `nix develop`)~%")) + (format t "~&[SKIP] cl-prolog-kit not on CL_SOURCE_REGISTRY (run inside `nix develop`)~%")) ;;; --- nerima-lisp/cl-parser-kit combinator grammar --------------------------- (if (asdf:find-system :cl-parser-kit nil) @@ -65,7 +65,7 @@ ;; The two independent grammars -- Prolog DCG and parser combinators -- ;; must agree whenever both are loaded, the same differential-testing ;; contract SGR-PROLOG-ORACLE holds against the hand-written decoder. - (when (asdf:find-system :cl-prolog nil) + (when (asdf:find-system :cl-prolog-kit nil) (dolist (case '("1;1H" "38;5;196m" "?25h" "" "1;1" "1H2" "A" "9x;1" ">0;276;0c" "1;1;104;200u")) (check (format nil "grammars agree on ~S" case) diff --git a/contrib/weave-property-tests.lisp b/contrib/weave-property-tests.lisp index d4c4bc2..14c4ba4 100644 --- a/contrib/weave-property-tests.lisp +++ b/contrib/weave-property-tests.lisp @@ -11,7 +11,7 @@ ;;; Advanced usage of nerima-lisp/cl-weave: property-based fuzzing of the two ;;; decoders that consume attacker-controlled PTY bytes, plus regression -;;; coverage for contrib/cl-prolog-csi-grammar.lisp's DCG recognizer. Every +;;; coverage for contrib/cl-prolog-kit-csi-grammar.lisp's DCG recognizer. Every ;;; decoder property below encodes the same contract each decoder already ;;; documents: malformed input signals a CL-TTY-KIT condition, never an ;;; unrelated Lisp error escaping from array indexing or type mismatches. @@ -20,7 +20,7 @@ (coerce (loop for code from #x40 to #x7E collect (code-char code)) 'string) "Every ECMA-48 CSI final byte (0x40-0x7E), as a GEN-CHARACTER alphabet.") -(describe "cl-prolog DCG: ECMA-48 CSI grammar (contrib/cl-prolog-csi-grammar.lisp)" +(describe "cl-prolog-kit DCG: ECMA-48 CSI grammar (contrib/cl-prolog-kit-csi-grammar.lisp)" (it "accepts a bare final byte" (expect (tty-csi-grammar:csi-sequence-valid-p "H"))) (it "accepts a parameter plus a final byte" diff --git a/docs/notes/feature-audit.md b/docs/notes/feature-audit.md index 3309eac..2e3c5cb 100644 --- a/docs/notes/feature-audit.md +++ b/docs/notes/feature-audit.md @@ -178,7 +178,7 @@ See [PTY](../src/guide/pty.md) for the full API. | Capability | Status | Notes | |---|---|---| -| Unification + CPS resolution + clause DB | DONE | `nerima-lisp/cl-prolog`, a test-suite dependency (differential-testing oracle) | +| Unification + CPS resolution + clause DB | DONE | `nerima-lisp/cl-prolog-kit`, a test-suite dependency (differential-testing oracle) | See [Logic Engine](../src/guide/logic-engine.md) for the full API. diff --git a/docs/src/getting-started.md b/docs/src/getting-started.md index 3f5f717..83f6aa9 100644 --- a/docs/src/getting-started.md +++ b/docs/src/getting-started.md @@ -12,7 +12,7 @@ and a first decoded key event. UTF-8 codec and [`cl-concurrent-kit`](https://github.com/nerima-lisp/cl-concurrent-kit) for raw mode's lock — and its test system, `:cl-tty-kit/test`, - additionally on [`cl-prolog`](https://github.com/nerima-lisp/cl-prolog) + additionally on [`cl-prolog-kit`](https://github.com/nerima-lisp/cl-prolog-kit) and [`cl-weave`](https://github.com/nerima-lisp/cl-weave). None of the four is on Quicklisp — [Nix](https://nixos.org) is the supported way to put them on ASDF's `CL_SOURCE_REGISTRY`, via this repository's @@ -32,10 +32,10 @@ nix flake check # hermetic test suite + a paredit-lint structural-parse ``` `flake.nix` declares `nerima-lisp/cl-codec-kit`, -`nerima-lisp/cl-concurrent-kit`, `nerima-lisp/cl-prolog`, +`nerima-lisp/cl-concurrent-kit`, `nerima-lisp/cl-prolog-kit`, `nerima-lisp/cl-weave`, `nerima-lisp/cl-parser-kit`, and `nerima-lisp/paredit-cli` as inputs. `cl-codec-kit` and `cl-concurrent-kit` -are `:cl-tty-kit`'s own ASDF dependencies; `cl-prolog` and `cl-weave` are +are `:cl-tty-kit`'s own ASDF dependencies; `cl-prolog-kit` and `cl-weave` are ASDF dependencies of `:cl-tty-kit/test` only, and `cl-parser-kit` of `contrib/` only. `sb-posix` stays out of `:depends-on` — it ships with SBCL and the raw-mode implementation loads it with `require`. The Nix apps, @@ -53,7 +53,7 @@ Put the repository somewhere ASDF can see it, for example: and make `cl-codec-kit` and `cl-concurrent-kit` discoverable the same way — as their own `local-projects` checkouts, or your own `CL_SOURCE_REGISTRY` entry — since neither ships with `cl-tty-kit` or Quicklisp and loading -`:cl-tty-kit` at all needs both. Add `cl-prolog` and `cl-weave` alongside +`:cl-tty-kit` at all needs both. Add `cl-prolog-kit` and `cl-weave` alongside them to run the test suite. Any directory ASDF already searches works too, for example a path added to `asdf:*central-registry*`. diff --git a/docs/src/guide/contrib.md b/docs/src/guide/contrib.md index 068531b..c32b578 100644 --- a/docs/src/guide/contrib.md +++ b/docs/src/guide/contrib.md @@ -8,7 +8,7 @@ build or CI** — `:cl-tty-kit`'s own ASDF dependencies are limited to the two neither from Quicklisp; its SBCL-only raw-mode implementation loads the bundled `sb-posix` contrib with `require` (see [Compatibility](../reference/compatibility.md)). These modules pull additional -libraries from Quicklisp, or from `nerima-lisp/cl-prolog`, +libraries from Quicklisp, or from `nerima-lisp/cl-prolog-kit`, `nerima-lisp/cl-weave`, and `nerima-lisp/cl-parser-kit` via this repository's `flake.nix` (`nix develop` puts all three on `CL_SOURCE_REGISTRY`, the same as `:cl-tty-kit/test`), and must be loaded explicitly. @@ -21,22 +21,22 @@ as `:cl-tty-kit/test`), and must be loaded explicitly. should never require — a flaky network never blocks a core merge, and a contrib regression never blocks a core release. -## `cl-tty-kit-cl-prolog-csi-grammar` — DCG grammar via `nerima-lisp/cl-prolog` +## `cl-tty-kit-cl-prolog-kit-csi-grammar` — DCG grammar via `nerima-lisp/cl-prolog-kit` A declarative recognizer for the ECMA-48 CSI (Control Sequence Introducer) byte-class grammar, built on -[`nerima-lisp/cl-prolog`](https://github.com/nerima-lisp/cl-prolog) +[`nerima-lisp/cl-prolog-kit`](https://github.com/nerima-lisp/cl-prolog-kit) (pulled from this repository's `flake.nix` inputs — it is not distributed by Quicklisp). [Input Decoding](input-decoding.md) already decodes CSI sequences imperatively on the render loop's hot path; this module instead expresses that same sequence shape — zero or more parameter bytes, then zero or more intermediate bytes, then exactly one final byte — as a `def-dcg-rule` -grammar run through `phrase`, demonstrating cl-prolog's DCG support +grammar run through `phrase`, demonstrating cl-prolog-kit's DCG support independently of the hand-written decoder. ```lisp -;; nix develop -- puts cl-prolog on CL_SOURCE_REGISTRY, once per shell -(asdf:load-system :cl-tty-kit-cl-prolog-csi-grammar) +;; nix develop -- puts cl-prolog-kit on CL_SOURCE_REGISTRY, once per shell +(asdf:load-system :cl-tty-kit-cl-prolog-kit-csi-grammar) (tty-csi-grammar:csi-sequence-valid-p "1;1H") ; => T (cursor position) (tty-csi-grammar:csi-sequence-valid-p "38;5;196m") ; => T (SGR, 256-color fg) @@ -48,7 +48,7 @@ independently of the hand-written decoder. A second, independent declarative recognizer for the same ECMA-48 CSI grammar as the DCG version above, built on [`nerima-lisp/cl-parser-kit`](https://github.com/nerima-lisp/cl-parser-kit)'s -`seq`/`many`/`type-token` parser combinators instead of cl-prolog's DCG rules +`seq`/`many`/`type-token` parser combinators instead of cl-prolog-kit's DCG rules (pulled from this repository's `flake.nix` inputs — it is not distributed by Quicklisp). `contrib/verify-contrib.lisp` cross-checks the two grammars agree on every case, the same differential-testing shape @@ -80,7 +80,7 @@ that read attacker-controlled PTY bytes. It also regression-tests the DCG CSI grammar above. ```lisp -;; nix develop -- puts cl-prolog and cl-weave on CL_SOURCE_REGISTRY, once per shell +;; nix develop -- puts cl-prolog-kit and cl-weave on CL_SOURCE_REGISTRY, once per shell (asdf:load-system :cl-tty-kit-weave-tests) (cl-tty-kit/weave-property-tests:run-tests) ; => T on success @@ -107,7 +107,7 @@ full external ISO Prolog (swipl/gprolog/yap) — and tangles to loadable Lisp. ## Verifying the contrib `contrib/verify-contrib.lisp` exercises the Quicklisp-backed clweb tangle -integration, and additionally exercises the cl-prolog/cl-parser-kit/cl-weave +integration, and additionally exercises the cl-prolog-kit/cl-parser-kit/cl-weave integrations above when ASDF can find the relevant system (skipped, not failed, otherwise): diff --git a/docs/src/guide/logic-engine.md b/docs/src/guide/logic-engine.md index 2e1f59a..cd314af 100644 --- a/docs/src/guide/logic-engine.md +++ b/docs/src/guide/logic-engine.md @@ -1,7 +1,7 @@ # Logic Engine (Prolog) `cl-tty-kit`'s embedded logic engine is -[`nerima-lisp/cl-prolog`](https://github.com/nerima-lisp/cl-prolog) itself, +[`nerima-lisp/cl-prolog-kit`](https://github.com/nerima-lisp/cl-prolog-kit) itself, not reimplemented. It is a `:cl-tty-kit/test` dependency, not a `:cl-tty-kit` one (see [Getting Started](../getting-started.md)): the core toolkit ships hand-written imperative decoders on its hot paths, and the test suite states part of that @@ -29,8 +29,8 @@ runtime. `assertz`/`retract` goals with logical-update-view semantics. - **A rich ISO built-in set** — cut, arithmetic, `findall/3`/`bagof/3`/`setof/3`, `assert`/`retract`, DCG grammars, `library(assoc)`, `library(pairs)`, string - and character-classification predicates, and more. See cl-prolog's own - [Builtin Goals](https://github.com/nerima-lisp/cl-prolog) reference for the + and character-classification predicates, and more. See cl-prolog-kit's own + [Builtin Goals](https://github.com/nerima-lisp/cl-prolog-kit) reference for the full list. - **Bounded search** — `:max-depth` bounds user-rule resolution (exhaustion signals `prolog-depth-limit-exceeded`) and `:limit` caps the number of @@ -46,10 +46,10 @@ whose first element is a relation symbol, e.g. `(parent abraham isaac)` or followed by zero or more body goals. `AND`, `OR`, `NOT`, and `=` are ordinary symbols inherited from `#:CL`, so they -name cl-prolog's builtins from any package without qualification. `CALL`, +name cl-prolog-kit's builtins from any package without qualification. `CALL`, `FINDALL`, `TRUE`, and `FAIL` (among others) have no `#:CL` equivalent, so a -goal using one of these from outside the `CL-PROLOG` package must spell it -`cl-prolog:call`, `cl-prolog:findall`, and so on — an unqualified symbol of the +goal using one of these from outside the `CL-PROLOG-KIT` package must spell it +`cl-prolog-kit:call`, `cl-prolog-kit:findall`, and so on — an unqualified symbol of the same name is a *different* symbol and the engine reports the goal as an undefined procedure. @@ -60,7 +60,7 @@ undefined procedure. ```lisp (defparameter *family* - (cl-prolog:prolog + (cl-prolog-kit:prolog ((parent abraham isaac)) ((parent isaac jacob)) ((parent jacob joseph)) @@ -73,11 +73,11 @@ without touching the original: ```lisp (defparameter *extended* - (cl-prolog:extend-rulebase *family* + (cl-prolog-kit:extend-rulebase *family* ((parent joseph benjamin)))) -(cl-prolog:query-prolog *extended* '(parent joseph ?child)) ; sees benjamin -(cl-prolog:query-prolog *family* '(parent joseph ?child)) ; still empty +(cl-prolog-kit:query-prolog *extended* '(parent joseph ?child)) ; sees benjamin +(cl-prolog-kit:query-prolog *family* '(parent joseph ?child)) ; still empty ``` ## Querying @@ -94,14 +94,14 @@ Each solution is an alist of query-variable bindings — project a single variable with `solution-binding`: ```lisp -(mapcar (lambda (solution) (cl-prolog:solution-binding '?d solution)) - (cl-prolog:query-prolog *family* '(ancestor abraham ?d))) +(mapcar (lambda (solution) (cl-prolog-kit:solution-binding '?d solution)) + (cl-prolog-kit:query-prolog *family* '(ancestor abraham ?d))) ;; => (ISAAC JACOB JOSEPH) ``` A ground proof with no variables to bind succeeds with the alist `nil`, so its solution list is `(nil)` — not `nil` (that means no proof at all). See -cl-prolog's own Querying and Troubleshooting docs for the full result +cl-prolog-kit's own Querying and Troubleshooting docs for the full result convention. !!! warning "Queries are bounded" @@ -122,10 +122,10 @@ convention. | `(and GOAL...)` | prove every goal (relational conjunction) | | `(or GOAL...)` | succeed with each solution of any goal (disjunction) | | `(not GOAL)` | negation as failure: succeed when `GOAL` has no proof | -| `(cl-prolog:true)` | succeed exactly once | -| `(cl-prolog:fail)` | never succeed | -| `(cl-prolog:call GOAL)` | meta-call: prove a (possibly variable) goal term | -| `(cl-prolog:findall TEMPLATE GOAL RESULT)` | unify `RESULT` with the list of `TEMPLATE` instances over every proof of `GOAL` | +| `(cl-prolog-kit:true)` | succeed exactly once | +| `(cl-prolog-kit:fail)` | never succeed | +| `(cl-prolog-kit:call GOAL)` | meta-call: prove a (possibly variable) goal term | +| `(cl-prolog-kit:findall TEMPLATE GOAL RESULT)` | unify `RESULT` with the list of `TEMPLATE` instances over every proof of `GOAL` | `findall/3` is the aggregation escape hatch out of pure relational search. It succeeds exactly once — with the empty list when the inner goal has no proof. @@ -134,8 +134,8 @@ signals `prolog-instantiation-error` (ISO semantics) rather than silently failing. ```lisp -(cl-prolog:query-prolog *family* - (list 'cl-prolog:findall '?d '(ancestor abraham ?d) '?ds)) +(cl-prolog-kit:query-prolog *family* + (list 'cl-prolog-kit:findall '?d '(ancestor abraham ?d) '?ds)) ;; => (((?DS ISAAC JACOB JOSEPH))) ``` @@ -149,7 +149,7 @@ cross-checks the two, catching drift in either direction: ```lisp (defparameter *sgr-channel-grammar* - (cl-prolog:prolog + (cl-prolog-kit:prolog ((sgr-channel 38 :fg)) ((sgr-channel 39 :fg)) ((sgr-channel 48 :bg)) @@ -158,12 +158,12 @@ cross-checks the two, catching drift in either direction: ((sgr-channel 59 :underline-color)))) ;; Which parameters drive the foreground channel, in definition order? -(mapcar (lambda (s) (cl-prolog:solution-binding '?param s)) - (cl-prolog:query-prolog *sgr-channel-grammar* '(sgr-channel ?param :fg))) +(mapcar (lambda (s) (cl-prolog-kit:solution-binding '?param s)) + (cl-prolog-kit:query-prolog *sgr-channel-grammar* '(sgr-channel ?param :fg))) ;; => (38 39) ;; A basic color parameter is not part of the channel-selection grammar. -(cl-prolog:prolog-succeeds-p *sgr-channel-grammar* '(sgr-channel 30 :fg)) +(cl-prolog-kit:prolog-succeeds-p *sgr-channel-grammar* '(sgr-channel 30 :fg)) ;; => NIL ``` @@ -176,12 +176,12 @@ engine usage: the plain facts are the *data* (the grammar), the query is the ## See also -- [nerima-lisp/cl-prolog](https://github.com/nerima-lisp/cl-prolog) — the +- [nerima-lisp/cl-prolog-kit](https://github.com/nerima-lisp/cl-prolog-kit) — the engine's own documentation: the full Rule DSL, builtin goal vocabulary, querying semantics, and how to extend it with `define-foreign-predicate` - [API Reference](../reference/api.md) — full public symbol map for the core toolkit - [Text Layout and Unicode Width](text-layout.md) — width classification the engine can specify - [ANSI Helpers](ansi-helpers.md) — SGR emission that the oracle above cross-checks -- `contrib/cl-tty-kit-cl-prolog-csi-grammar` — a DCG grammar for the ECMA-48 +- `contrib/cl-tty-kit-cl-prolog-kit-csi-grammar` — a DCG grammar for the ECMA-48 CSI byte shape, built on this same engine (opt-in, not part of the core build or CI; see `contrib/README.md`) diff --git a/docs/src/project/development.md b/docs/src/project/development.md index e8ed721..a840cd7 100644 --- a/docs/src/project/development.md +++ b/docs/src/project/development.md @@ -21,7 +21,7 @@ org. This page covers only what is specific to this repository. ## Nix entry points -Nix is the supported way to get `cl-prolog`/`cl-weave` onto +Nix is the supported way to get `cl-prolog-kit`/`cl-weave` onto `CL_SOURCE_REGISTRY` (see [Getting Started](../getting-started.md#install-with-nix)); everything below assumes either `nix develop` or one of these wrappers. diff --git a/docs/src/project/release-process.md b/docs/src/project/release-process.md index 6e28915..c1828c0 100644 --- a/docs/src/project/release-process.md +++ b/docs/src/project/release-process.md @@ -73,7 +73,7 @@ Before tagging a release: under `examples/` — `t/package-readme-test.lisp` checks both mechanically, but review them by hand too. 7. Smoke-test the examples on a clean SBCL environment if possible. -8. If `flake.lock` moved (the `cl-prolog`/`cl-weave`/`paredit-cli`/`nixpkgs` +8. If `flake.lock` moved (the `cl-prolog-kit`/`cl-weave`/`paredit-cli`/`nixpkgs` inputs), confirm `nix flake check` still passes against the new pins before tagging — see [Contrib](../guide/contrib.md). `--all-systems` is not used: `systems` is `[ "x86_64-linux" ]` alone, so there is no second platform for it to diff --git a/docs/src/reference/api.md b/docs/src/reference/api.md index 3764e22..64bf3b9 100644 --- a/docs/src/reference/api.md +++ b/docs/src/reference/api.md @@ -6,8 +6,8 @@ and navigation; each group links to the guide page that carries the depth. !!! tip "Scope" The core toolkit is a single package, `cl-tty-kit`. The test suite's - embedded logic engine is [`nerima-lisp/cl-prolog`](https://github.com/nerima-lisp/cl-prolog) - itself, used directly under its own `cl-prolog` package — see + embedded logic engine is [`nerima-lisp/cl-prolog-kit`](https://github.com/nerima-lisp/cl-prolog-kit) + itself, used directly under its own `cl-prolog-kit` package — see [Logic Engine (Prolog)](../guide/logic-engine.md). ## Conditions diff --git a/flake.lock b/flake.lock index 9051b2c..25b4090 100644 --- a/flake.lock +++ b/flake.lock @@ -135,10 +135,11 @@ "cl-nix-forge_3": { "inputs": { "nixpkgs": [ + "cl-parser-kit", "cl-prolog", "nixpkgs" ], - "treefmt-nix": "treefmt-nix_3" + "treefmt-nix": "treefmt-nix_2" }, "locked": { "lastModified": 1785825792, @@ -156,12 +157,35 @@ } }, "cl-nix-forge_4": { + "inputs": { + "nixpkgs": [ + "cl-prolog-kit", + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix_4" + }, + "locked": { + "lastModified": 1785825792, + "narHash": "sha256-FjpTPYXj5BINxpgFbNqKQgeB6p/ANR/1N8T4lSHS7kU=", + "owner": "nerima-lisp", + "repo": "cl-nix-forge", + "rev": "df1e772cda1efcdb90297b49ca1a25b396b8bdd7", + "type": "github" + }, + "original": { + "owner": "nerima-lisp", + "ref": "v0.5.0", + "repo": "cl-nix-forge", + "type": "github" + } + }, + "cl-nix-forge_5": { "inputs": { "nixpkgs": [ "cl-weave", "nixpkgs" ], - "treefmt-nix": "treefmt-nix_5" + "treefmt-nix": "treefmt-nix_6" }, "locked": { "lastModified": 1785825792, @@ -181,9 +205,7 @@ "cl-parser-kit": { "inputs": { "cl-nix-forge": "cl-nix-forge_2", - "cl-prolog": [ - "cl-prolog" - ], + "cl-prolog": "cl-prolog", "cl-weave": [ "cl-weave" ], @@ -193,7 +215,7 @@ "paredit-cli": [ "paredit-cli" ], - "treefmt-nix": "treefmt-nix_2" + "treefmt-nix": "treefmt-nix_3" }, "locked": { "lastModified": 1785931427, @@ -214,15 +236,21 @@ "inputs": { "cl-nix-forge": "cl-nix-forge_3", "cl-weave": [ + "cl-parser-kit", "cl-weave" ], "nixpkgs": [ + "cl-parser-kit", "nixpkgs" ], "paredit-cli": [ + "cl-parser-kit", "paredit-cli" ], - "treefmt-nix": "treefmt-nix_4" + "treefmt-nix": [ + "cl-parser-kit", + "treefmt-nix" + ] }, "locked": { "lastModified": 1785918678, @@ -239,16 +267,45 @@ "type": "github" } }, - "cl-weave": { + "cl-prolog-kit": { "inputs": { "cl-nix-forge": "cl-nix-forge_4", + "cl-weave": [ + "cl-weave" + ], "nixpkgs": [ "nixpkgs" ], "paredit-cli": [ "paredit-cli" ], - "treefmt-nix": "treefmt-nix_6" + "treefmt-nix": "treefmt-nix_5" + }, + "locked": { + "lastModified": 1786948477, + "narHash": "sha256-3qn9W1Jmbxnr0Si77J7Klo26oX/zjgBVwb5ye74NsTY=", + "owner": "nerima-lisp", + "repo": "cl-prolog-kit", + "rev": "239368e1001bc3a8576d45770c9e91da11515d09", + "type": "github" + }, + "original": { + "owner": "nerima-lisp", + "ref": "v1.5.0", + "repo": "cl-prolog-kit", + "type": "github" + } + }, + "cl-weave": { + "inputs": { + "cl-nix-forge": "cl-nix-forge_5", + "nixpkgs": [ + "nixpkgs" + ], + "paredit-cli": [ + "paredit-cli" + ], + "treefmt-nix": "treefmt-nix_7" }, "locked": { "lastModified": 1785915502, @@ -303,7 +360,7 @@ "nixpkgs" ], "rust-overlay": "rust-overlay", - "treefmt-nix": "treefmt-nix_7" + "treefmt-nix": "treefmt-nix_8" }, "locked": { "lastModified": 1785902408, @@ -329,11 +386,11 @@ "cl-host-kit": "cl-host-kit", "cl-nix-forge": "cl-nix-forge", "cl-parser-kit": "cl-parser-kit", - "cl-prolog": "cl-prolog", + "cl-prolog-kit": "cl-prolog-kit", "cl-weave": "cl-weave", "nixpkgs": "nixpkgs", "paredit-cli": "paredit-cli", - "treefmt-nix": "treefmt-nix_8" + "treefmt-nix": "treefmt-nix_9" } }, "rust-overlay": { @@ -383,6 +440,8 @@ "inputs": { "nixpkgs": [ "cl-parser-kit", + "cl-prolog", + "cl-nix-forge", "nixpkgs" ] }, @@ -403,8 +462,7 @@ "treefmt-nix_3": { "inputs": { "nixpkgs": [ - "cl-prolog", - "cl-nix-forge", + "cl-parser-kit", "nixpkgs" ] }, @@ -425,7 +483,8 @@ "treefmt-nix_4": { "inputs": { "nixpkgs": [ - "cl-prolog", + "cl-prolog-kit", + "cl-nix-forge", "nixpkgs" ] }, @@ -446,8 +505,7 @@ "treefmt-nix_5": { "inputs": { "nixpkgs": [ - "cl-weave", - "cl-nix-forge", + "cl-prolog-kit", "nixpkgs" ] }, @@ -469,6 +527,7 @@ "inputs": { "nixpkgs": [ "cl-weave", + "cl-nix-forge", "nixpkgs" ] }, @@ -489,7 +548,7 @@ "treefmt-nix_7": { "inputs": { "nixpkgs": [ - "paredit-cli", + "cl-weave", "nixpkgs" ] }, @@ -508,6 +567,27 @@ } }, "treefmt-nix_8": { + "inputs": { + "nixpkgs": [ + "paredit-cli", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1785360170, + "narHash": "sha256-XE1lKgQ3eIO3E7zWryqcRsax+mYXod/5RHBn4YaR9YE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "d1187f8bc71fb8aab02395869ec3f5c1920f75c0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_9": { "inputs": { "nixpkgs": [ "nixpkgs" diff --git a/flake.nix b/flake.nix index e79ebb9..d2a1fec 100644 --- a/flake.nix +++ b/flake.nix @@ -13,16 +13,16 @@ # inflating flake.lock and rebuilding identical derivations. # cl-tty-kit.asd names one real (non-test) sibling dependency, - # cl-codec-kit (declared further below, near cl-parser-kit); cl-prolog and + # cl-codec-kit (declared further below, near cl-parser-kit); cl-prolog-kit and # cl-weave are both :cl-tty-kit/test-only dependencies (see cl-tty-kit.asd # :depends-on and cl-tty-kit/test :depends-on). None of the three is # distributed by Quicklisp, and this project keeps no vendored copy of any: # these flake inputs are the only source of all three, put on # CL_SOURCE_REGISTRY by every app/check/devShell below. - inputs.cl-prolog.url = "github:nerima-lisp/cl-prolog/v1.4.3"; - inputs.cl-prolog.inputs.nixpkgs.follows = "nixpkgs"; - inputs.cl-prolog.inputs.cl-weave.follows = "cl-weave"; - inputs.cl-prolog.inputs.paredit-cli.follows = "paredit-cli"; + inputs.cl-prolog-kit.url = "github:nerima-lisp/cl-prolog-kit/v1.5.0"; + inputs.cl-prolog-kit.inputs.nixpkgs.follows = "nixpkgs"; + inputs.cl-prolog-kit.inputs.cl-weave.follows = "cl-weave"; + inputs.cl-prolog-kit.inputs.paredit-cli.follows = "paredit-cli"; inputs.cl-weave.url = "github:nerima-lisp/cl-weave/v1.3.0"; inputs.cl-weave.inputs.nixpkgs.follows = "nixpkgs"; @@ -78,11 +78,11 @@ # contrib/cl-parser-kit-csi-grammar.lisp's dependency: an opt-in second, # independent declarative specification of the ECMA-48 CSI byte-class - # grammar (see contrib/cl-prolog-csi-grammar.lisp for the first, built on - # cl-prolog's DCG support instead). Never part of the core build/CI. + # grammar (see contrib/cl-prolog-kit-csi-grammar.lisp for the first, built on + # cl-prolog-kit's DCG support instead). Never part of the core build/CI. inputs.cl-parser-kit.url = "github:nerima-lisp/cl-parser-kit/v1.1.1"; inputs.cl-parser-kit.inputs.nixpkgs.follows = "nixpkgs"; - inputs.cl-parser-kit.inputs.cl-prolog.follows = "cl-prolog"; + inputs.cl-parser-kit.inputs.cl-prolog-kit.follows = "cl-prolog-kit"; inputs.cl-parser-kit.inputs.cl-weave.follows = "cl-weave"; inputs.cl-parser-kit.inputs.paredit-cli.follows = "paredit-cli"; @@ -100,7 +100,7 @@ { self, nixpkgs, - cl-prolog, + cl-prolog-kit, cl-weave, cl-codec-kit, cl-concurrent-kit, @@ -161,7 +161,7 @@ # system loading, not an optional contrib layer). cl-boundary-kit, # cl-date-kit and cl-host-kit are here only because ASDF must load # cl-concurrent-kit's own closure to load cl-concurrent-kit -- no - # cl-tty-kit source references any of the three. cl-prolog and cl-weave + # cl-tty-kit source references any of the three. cl-prolog-kit and cl-weave # are test-only; cl-parser-kit is only a contrib/ dependency, but # sharing one registry string keeps every entry point able to load # contrib/ interactively without a separate CL_SOURCE_REGISTRY variant @@ -171,7 +171,7 @@ # express the same ASDF closure to two different consumers, and a # dependency added to one and not the other fails only at whichever # entry point the other serves. - clSourceRegistryFor = "${cl-codec-kit}//:${cl-concurrent-kit}//:${cl-boundary-kit}//:${cl-date-kit}//:${cl-host-kit}//:${cl-prolog}//:${cl-weave}//:${cl-parser-kit}//:"; + clSourceRegistryFor = "${cl-codec-kit}//:${cl-concurrent-kit}//:${cl-boundary-kit}//:${cl-date-kit}//:${cl-host-kit}//:${cl-prolog-kit}//:${cl-weave}//:${cl-parser-kit}//:"; # cl-codec-kit as a buildASDFSystem lib for cl-tty-kit's own :depends-on # (see cl-tty-kit.asd). Built directly from the flake = false source @@ -246,7 +246,7 @@ # Runs a repository script against the current working directory (so # local edits are picked up without rebuilding a Nix package), with - # CL_SOURCE_REGISTRY pointed at this flake's own cl-prolog/cl-weave + # CL_SOURCE_REGISTRY pointed at this flake's own cl-prolog-kit/cl-weave # inputs so cl-tty-kit.asd's :depends-on resolves without any vendored # copy on disk. # `meta.description` is what `nix flake show` renders and what @@ -323,7 +323,7 @@ { # lispLibs carries cl-codec-kit and cl-concurrent-kit, # :cl-tty-kit's two real (non-test) :depends-on entries (see - # cl-tty-kit.asd) -- cl-prolog and cl-weave remain + # cl-tty-kit.asd) -- cl-prolog-kit and cl-weave remain # :cl-tty-kit/test-only dependencies, resolved instead through # CL_SOURCE_REGISTRY (clSourceRegistryFor) everywhere else. cl-tty-kit = pkgs.sbcl.buildASDFSystem { @@ -434,7 +434,7 @@ treefmtEval.${system}.config.build.wrapper paredit-cli.packages.${system}.default ]; - # The only place cl-prolog/cl-weave come from: cl-tty-kit.asd's + # The only place cl-prolog-kit/cl-weave come from: cl-tty-kit.asd's # :depends-on cannot resolve either without this. shellHook = '' export CL_SOURCE_REGISTRY="$PWD//:${clSourceRegistryFor}''${CL_SOURCE_REGISTRY:-}" diff --git a/run-tests.lisp b/run-tests.lisp index d1fa01b..fcc0636 100644 --- a/run-tests.lisp +++ b/run-tests.lisp @@ -9,7 +9,7 @@ ;;;; ;;;; scripts/bootstrap.lisp registers the project tree with ASDF, so this runs ;;;; from a plain checkout with no CL_SOURCE_REGISTRY set for cl-tty-kit -;;;; itself. Its test-only dependencies (cl-prolog, cl-weave) still come from +;;;; itself. Its test-only dependencies (cl-prolog-kit, cl-weave) still come from ;;;; the environment, which flake.nix supplies. (require :asdf) diff --git a/scripts/source-registry-smoke.lisp b/scripts/source-registry-smoke.lisp index 658000f..9b84ac2 100644 --- a/scripts/source-registry-smoke.lisp +++ b/scripts/source-registry-smoke.lisp @@ -25,7 +25,7 @@ (merge-pathnames #P"../cl-date-kit/" sibling-root) (merge-pathnames #P"../cl-host-kit/" sibling-root) (merge-pathnames #P"../cl-weave/" sibling-root) - (merge-pathnames #P"../cl-prolog/" sibling-root) + (merge-pathnames #P"../cl-prolog-kit/" sibling-root) (merge-pathnames #P"../cl-parser-kit/" sibling-root))))) (asdf/source-registry:initialize-source-registry `(:source-registry diff --git a/t/helpers-prolog-cases.lisp b/t/helpers-prolog-cases.lisp index 2df787d..7fba2df 100644 --- a/t/helpers-prolog-cases.lisp +++ b/t/helpers-prolog-cases.lisp @@ -4,11 +4,11 @@ ;;; actual test files small and lets the suite enumerate behaviors one by one. ;;; ;;; AND/OR/NOT/= are ordinary Common Lisp symbols inherited from #:CL, so they -;;; dispatch to nerima-lisp/cl-prolog's builtins from any package without -;;; qualification. CALL/FINDALL/TRUE/FAIL are cl-prolog-specific exports with no +;;; dispatch to nerima-lisp/cl-prolog-kit's builtins from any package without +;;; qualification. CALL/FINDALL/TRUE/FAIL are cl-prolog-kit-specific exports with no ;;; CL equivalent, so a bare (unqualified) symbol of that name read in this file -;;; is a different symbol than CL-PROLOG:CALL and the engine reports the goal as -;;; an undefined procedure -- these four are written CL-PROLOG:CALL etc. +;;; is a different symbol than CL-PROLOG-KIT:CALL and the engine reports the goal as +;;; an undefined procedure -- these four are written CL-PROLOG-KIT:CALL etc. ;;; throughout. (defparameter +prolog-query-cases+ @@ -26,7 +26,7 @@ "an unprovable goal yields no solutions"))) (defparameter +prolog-primitive-cases+ - '((cl-prolog:prolog-succeeds-p + '((cl-prolog-kit:prolog-succeeds-p (ancestor abraham joseph) t "provable-p reports a reachable relation") @@ -47,19 +47,19 @@ (jacob joseph) "disjunction enumerates the solutions of each branch in order") (%solve-variable - (cl-prolog:call (ancestor abraham ?x)) + (cl-prolog-kit:call (ancestor abraham ?x)) (isaac jacob joseph) "call/1 proves a goal term like an ordinary relation") (%solve-result - (cl-prolog:findall ?a (ancestor ?a joseph) ?result) + (cl-prolog-kit:findall ?a (ancestor ?a joseph) ?result) ((jacob abraham isaac)) "findall/3 aggregates every solution into a single list in proof order") (%solve-result - (cl-prolog:findall ?x (parent joseph ?x) ?result) + (cl-prolog-kit:findall ?x (parent joseph ?x) ?result) (()) "findall/3 yields the empty list when the goal has no proof") (%not-provable-p - (cl-prolog:fail) + (cl-prolog-kit:fail) t "fail/0 never succeeds") (%not-provable-p @@ -70,11 +70,11 @@ (= abraham isaac) t "the = primitive fails when its arguments don't unify") - (cl-prolog:prolog-succeeds-p - (cl-prolog:true) + (cl-prolog-kit:prolog-succeeds-p + (cl-prolog-kit:true) t "true/0 always succeeds") (%not-provable-p - (cl-prolog:findall ?x (parent abraham ?x) (mismatch)) + (cl-prolog-kit:findall ?x (parent abraham ?x) (mismatch)) t "findall/3 fails when RESULT doesn't unify with the collected items"))) diff --git a/t/helpers-prolog.lisp b/t/helpers-prolog.lisp index e71ed86..289ea9c 100644 --- a/t/helpers-prolog.lisp +++ b/t/helpers-prolog.lisp @@ -1,7 +1,7 @@ (in-package #:cl-tty-kit/test) (defun %genealogy-db () - (cl-prolog:prolog + (cl-prolog-kit:prolog ((parent abraham isaac)) ((parent isaac jacob)) ((parent jacob joseph)) @@ -9,15 +9,15 @@ ((ancestor ?a ?b) (parent ?a ?c) (ancestor ?c ?b)))) (defun %many-solutions-db () - (cl-prolog:prolog + (cl-prolog-kit:prolog ((value one)) ((value two)) ((value three)))) (defun %project-variable (database goal variable) "Return VARIABLE's binding from every solution of GOAL against DATABASE." - (mapcar (lambda (solution) (cl-prolog:solution-binding variable solution)) - (cl-prolog:query-prolog database goal))) + (mapcar (lambda (solution) (cl-prolog-kit:solution-binding variable solution)) + (cl-prolog-kit:query-prolog database goal))) (defun %normalize-solutions (solutions) (sort (copy-list solutions) @@ -33,7 +33,7 @@ SET-P (resolution order is not significant) or in proof order otherwise." (expect actual :to-equal expected)))) (defun %not-provable-p (database goal) - (not (cl-prolog:prolog-succeeds-p database goal))) + (not (cl-prolog-kit:prolog-succeeds-p database goal))) (defun %solve-variable (database goal) (%project-variable database goal '?x)) diff --git a/t/prolog-db-test.lisp b/t/prolog-db-test.lisp index afdaa54..90a9a75 100644 --- a/t/prolog-db-test.lisp +++ b/t/prolog-db-test.lisp @@ -1,6 +1,6 @@ (in-package #:cl-tty-kit/test) -;;; cl-prolog's rulebase is an immutable value by default (see the Rule DSL +;;; cl-prolog-kit's rulebase is an immutable value by default (see the Rule DSL ;;; docs on EXTEND-RULEBASE) rather than the retired hand-rolled engine's ;;; mutable clause-db, so the invariants worth checking here are different: ;;; functional extension leaves the base untouched, and an undefined relation @@ -8,25 +8,25 @@ (describe "extend-rulebase" (it "leaves the base rulebase unaffected" - (let* ((base (cl-prolog:prolog ((color apple red))))) - (cl-prolog:extend-rulebase base ((color lime green))) - (expect (mapcar (lambda (solution) (cl-prolog:solution-binding '?color solution)) - (cl-prolog:query-prolog base '(color apple ?color))) + (let* ((base (cl-prolog-kit:prolog ((color apple red))))) + (cl-prolog-kit:extend-rulebase base ((color lime green))) + (expect (mapcar (lambda (solution) (cl-prolog-kit:solution-binding '?color solution)) + (cl-prolog-kit:query-prolog base '(color apple ?color))) :to-equal '(red)))) (it "sees its own additional clauses" - (let* ((base (cl-prolog:prolog ((color apple red)))) - (extended (cl-prolog:extend-rulebase base ((color lime green))))) - (expect (mapcar (lambda (solution) (cl-prolog:solution-binding '?color solution)) - (cl-prolog:query-prolog extended '(color lime ?color))) + (let* ((base (cl-prolog-kit:prolog ((color apple red)))) + (extended (cl-prolog-kit:extend-rulebase base ((color lime green))))) + (expect (mapcar (lambda (solution) (cl-prolog-kit:solution-binding '?color solution)) + (cl-prolog-kit:query-prolog extended '(color lime ?color))) :to-equal '(green)))) (it "also sees the base's clauses" - (let* ((base (cl-prolog:prolog ((color apple red)))) - (extended (cl-prolog:extend-rulebase base ((color lime green))))) - (expect (mapcar (lambda (solution) (cl-prolog:solution-binding '?color solution)) - (cl-prolog:query-prolog extended '(color apple ?color))) + (let* ((base (cl-prolog-kit:prolog ((color apple red)))) + (extended (cl-prolog-kit:extend-rulebase base ((color lime green))))) + (expect (mapcar (lambda (solution) (cl-prolog-kit:solution-binding '?color solution)) + (cl-prolog-kit:query-prolog extended '(color apple ?color))) :to-equal '(red))))) (describe "an undefined relation" (it "signals a catchable prolog-existence-error instead of failing silently" - (expect (lambda () (cl-prolog:query-prolog (%genealogy-db) '(no-such-relation abraham))) - :to-throw 'cl-prolog:prolog-existence-error))) + (expect (lambda () (cl-prolog-kit:query-prolog (%genealogy-db) '(no-such-relation abraham))) + :to-throw 'cl-prolog-kit:prolog-existence-error))) diff --git a/t/prolog-primitives-test.lisp b/t/prolog-primitives-test.lisp index 6539e42..743d2a7 100644 --- a/t/prolog-primitives-test.lisp +++ b/t/prolog-primitives-test.lisp @@ -6,26 +6,26 @@ (it description (expect (funcall predicate (%genealogy-db) goal) :to-equal expected)))) ;; Unlike the retired engine's hand-written primitives (which reported "expects - ;; N arguments" for a wrong arity), cl-prolog's builtins are registered per + ;; N arguments" for a wrong arity), cl-prolog-kit's builtins are registered per ;; exact predicate indicator: a name called at an arity it does not support ;; denotes a different, undefined procedure and signals the catchable ISO ;; PROLOG-EXISTENCE-ERROR, same as calling any other undefined relation. (it "a wrong-arity findall call signals prolog-existence-error" (let ((db (%genealogy-db))) - (expect (lambda () (cl-prolog:query-prolog db (list 'cl-prolog:findall '?x '(parent ?x ?y)))) - :to-throw 'cl-prolog:prolog-existence-error))) + (expect (lambda () (cl-prolog-kit:query-prolog db (list 'cl-prolog-kit:findall '?x '(parent ?x ?y)))) + :to-throw 'cl-prolog-kit:prolog-existence-error))) (it "a wrong-arity = call signals prolog-existence-error" - (expect (lambda () (cl-prolog:query-prolog (%genealogy-db) '(= ?x))) - :to-throw 'cl-prolog:prolog-existence-error)) + (expect (lambda () (cl-prolog-kit:query-prolog (%genealogy-db) '(= ?x))) + :to-throw 'cl-prolog-kit:prolog-existence-error)) (it "a wrong-arity true call signals prolog-existence-error" - (expect (lambda () (cl-prolog:query-prolog (%genealogy-db) (list 'cl-prolog:true 'extra))) - :to-throw 'cl-prolog:prolog-existence-error)) + (expect (lambda () (cl-prolog-kit:query-prolog (%genealogy-db) (list 'cl-prolog-kit:true 'extra))) + :to-throw 'cl-prolog-kit:prolog-existence-error)) ;; CALL/N is ISO meta-call: extra arguments are appended to the inner goal ;; rather than making CALL itself arity-mismatched, so (call G extra) proves ;; G with one more argument -- here PARENT/3, which the rulebase never ;; defines, so it still signals PROLOG-EXISTENCE-ERROR, just against PARENT. (it "call/n appends its extra argument to the inner goal" (expect (lambda () - (cl-prolog:query-prolog (%genealogy-db) - (list 'cl-prolog:call '(parent abraham isaac) 'extra))) - :to-throw 'cl-prolog:prolog-existence-error))) + (cl-prolog-kit:query-prolog (%genealogy-db) + (list 'cl-prolog-kit:call '(parent abraham isaac) 'extra))) + :to-throw 'cl-prolog-kit:prolog-existence-error))) diff --git a/t/prolog-queries-test.lisp b/t/prolog-queries-test.lisp index 80c8170..f3da835 100644 --- a/t/prolog-queries-test.lisp +++ b/t/prolog-queries-test.lisp @@ -5,32 +5,32 @@ (destructuring-bind (goal template expected description &key set-p) case (it description (%check-query (%genealogy-db) goal template expected :set-p set-p)))) - ;; NOTE: unlike cl-tty-kit's retired hand-rolled engine, cl-prolog does not + ;; NOTE: unlike cl-tty-kit's retired hand-rolled engine, cl-prolog-kit does not ;; proactively guard against a directly self-referential (circular) host ;; goal term at the query level -- QUERY-PROLOG hangs rather than signaling, ;; so that case is intentionally not exercised here. Only pass well-formed, ;; finite goal terms to QUERY-PROLOG/PROLOG-SUCCEEDS-P. (it "signals prolog-depth-limit-exceeded on an infinite goal past max-depth" - (let ((db (cl-prolog:prolog ((loop ?x) (loop (s ?x)))))) - (expect (lambda () (cl-prolog:query-prolog db '(loop ?x) :max-depth 5)) - :to-throw 'cl-prolog:prolog-depth-limit-exceeded))) + (let ((db (cl-prolog-kit:prolog ((loop ?x) (loop (s ?x)))))) + (expect (lambda () (cl-prolog-kit:query-prolog db '(loop ?x) :max-depth 5)) + :to-throw 'cl-prolog-kit:prolog-depth-limit-exceeded))) (it "signals invalid-max-depth-error with the offending value for a negative max-depth" (expect (lambda () - (cl-prolog:prolog-succeeds-p (%genealogy-db) '(parent abraham isaac) + (cl-prolog-kit:prolog-succeeds-p (%genealogy-db) '(parent abraham isaac) :max-depth -1)) :to-throw (lambda (condition) - (and (typep condition 'cl-prolog:invalid-max-depth-error) - (= -1 (cl-prolog:invalid-max-depth-error-value condition)))))) - ;; Unlike the retired engine's hard "result limit" budget, cl-prolog's :LIMIT + (and (typep condition 'cl-prolog-kit:invalid-max-depth-error) + (= -1 (cl-prolog-kit:invalid-max-depth-error-value condition)))))) + ;; Unlike the retired engine's hard "result limit" budget, cl-prolog-kit's :LIMIT ;; is a benign cap: querying for more solutions than exist under a :LIMIT ;; simply returns what was found, with no error. (it ":limit truncates instead of erroring" - (expect (mapcar (lambda (solution) (cl-prolog:solution-binding '?x solution)) - (cl-prolog:query-prolog (%many-solutions-db) '(value ?x) :limit 2)) + (expect (mapcar (lambda (solution) (cl-prolog-kit:solution-binding '?x solution)) + (cl-prolog-kit:query-prolog (%many-solutions-db) '(value ?x) :limit 2)) :to-equal '(one two))) (it "signals type-error with the offending value for a negative limit" - (expect (lambda () (cl-prolog:query-prolog (%many-solutions-db) '(value ?x) :limit -1)) + (expect (lambda () (cl-prolog-kit:query-prolog (%many-solutions-db) '(value ?x) :limit -1)) :to-throw (lambda (condition) (and (typep condition 'type-error) diff --git a/t/prolog-unification-test.lisp b/t/prolog-unification-test.lisp index a110331..73650d7 100644 --- a/t/prolog-unification-test.lisp +++ b/t/prolog-unification-test.lisp @@ -3,24 +3,24 @@ (describe "unify" (it "unifies a shared free variable across two terms" (flet ((unified (left right) - (multiple-value-bind (env ok) (cl-prolog:unify left right) - (and ok (cl-prolog:logic-substitute left env))))) + (multiple-value-bind (env ok) (cl-prolog-kit:unify left right) + (and ok (cl-prolog-kit:logic-substitute left env))))) (expect (unified '(?x b) '(a ?y)) :to-equal '(a b)) (expect (unified '(?x ?x) '(a a)) :to-equal '(a a)))) (it "rejects binding one variable to two distinct constants" - (multiple-value-bind (env ok) (cl-prolog:unify '(?x ?x) '(a b)) + (multiple-value-bind (env ok) (cl-prolog-kit:unify '(?x ?x) '(a b)) (declare (ignore env)) (expect (not ok)))) (it "the occurs check rejects an infinite term" - (multiple-value-bind (env ok) (cl-prolog:unify '?x '(f ?x)) + (multiple-value-bind (env ok) (cl-prolog-kit:unify '?x '(f ?x)) (declare (ignore env)) (expect (not ok)))) (it "a circular host term fails unification instead of looping" ;; A directly circular host cons -- built by hand, never through the reader ;; or the engine's own construction -- unifies safely rather than looping or - ;; erroring: cl-prolog compares cyclic structure coinductively. + ;; erroring: cl-prolog-kit compares cyclic structure coinductively. (let ((term (list 'loop))) (setf (rest term) term) - (multiple-value-bind (env ok) (cl-prolog:unify term '(loop)) + (multiple-value-bind (env ok) (cl-prolog-kit:unify term '(loop)) (declare (ignore env)) (expect (not ok)))))) diff --git a/t/sgr-prolog-oracle-test.lisp b/t/sgr-prolog-oracle-test.lisp index a5df2dc..546fe01 100644 --- a/t/sgr-prolog-oracle-test.lisp +++ b/t/sgr-prolog-oracle-test.lisp @@ -6,10 +6,10 @@ ;;; The imperative SGR decoder in src/sgr-parse.lisp classifies the colour ;;; parameters with a hand-written CASE. Here the same grammar is stated ;;; declaratively -- one relational fact per parameter -- and resolved by -;;; nerima-lisp/cl-prolog. Cross-checking the two catches a drift in either +;;; nerima-lisp/cl-prolog-kit. Cross-checking the two catches a drift in either ;;; direction: the decoder is the fast path, the relation is the independent ;;; specification. This keeps the data (the grammar) apart from the logic (the -;;; decoder) and exercises CL-PROLOG:QUERY-PROLOG / PROLOG-SUCCEEDS-P as +;;; decoder) and exercises CL-PROLOG-KIT:QUERY-PROLOG / PROLOG-SUCCEEDS-P as ;;; first-class code. ;;; ;;; (sgr-channel PARAM CHANNEL): PARAM touches CHANNEL. 38/48/58 set an extended @@ -17,7 +17,7 @@ ;;; -------------------------------------------------------------------------- (defun %sgr-channel-grammar () - (cl-prolog:prolog + (cl-prolog-kit:prolog ((sgr-channel 38 :fg)) ((sgr-channel 39 :fg)) ((sgr-channel 48 :bg)) @@ -50,4 +50,4 @@ :to-equal '(58 59))) ;; A basic colour parameter is not part of the channel-selection grammar. (it "a basic colour parameter is not part of the channel-selection grammar" - (expect (not (cl-prolog:prolog-succeeds-p (%sgr-channel-grammar) '(sgr-channel 30 :fg)))))) + (expect (not (cl-prolog-kit:prolog-succeeds-p (%sgr-channel-grammar) '(sgr-channel 30 :fg))))))