Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:

Expand Down
6 changes: 3 additions & 3 deletions cl-tty-kit.asd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
18 changes: 9 additions & 9 deletions contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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`
Expand Down Expand Up @@ -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

Expand All @@ -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):

Expand Down
2 changes: 1 addition & 1 deletion contrib/cl-parser-kit-csi-grammar.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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."
Expand Down
4 changes: 2 additions & 2 deletions contrib/cl-tty-kit-cl-parser-kit-csi-grammar.asd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
;;;;
Expand Down
16 changes: 0 additions & 16 deletions contrib/cl-tty-kit-cl-prolog-csi-grammar.asd

This file was deleted.

16 changes: 16 additions & 0 deletions contrib/cl-tty-kit-cl-prolog-kit-csi-grammar.asd
Original file line number Diff line number Diff line change
@@ -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")))
2 changes: 1 addition & 1 deletion contrib/cl-tty-kit-weave-mutation-tests.asd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
;;;;
Expand Down
4 changes: 2 additions & 2 deletions contrib/cl-tty-kit-weave-tests.asd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion contrib/literate/tty-relations.clw
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions contrib/verify-contrib.lisp
Original file line number Diff line number Diff line change
@@ -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).

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions contrib/weave-property-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/notes/feature-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions docs/src/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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*`.

Expand Down
Loading