# HG changeset patch # User Richard Westhaver # Date 1726443240 14400 # Node ID 119532882cb128c0362031b464b443a91e63c188 # Parent 328e1ff739383a7332c575dd35604b7a69738177 added keyword-opts (experimental) diff -r 328e1ff73938 -r 119532882cb1 lisp/lib/cli/clap/cmd.lisp --- a/lisp/lib/cli/clap/cmd.lisp Sat Sep 14 23:55:38 2024 -0400 +++ b/lisp/lib/cli/clap/cmd.lisp Sun Sep 15 19:34:00 2024 -0400 @@ -182,7 +182,14 @@ (clap-unknown-argument a 'cli-opt))))) ;; OPT GROUP else if (opt-group-p a) - collect (make-cli-node 'group nil) + collect + (make-cli-node 'group nil) + ;; OPT KEYWORD (experimental) + else if (opt-keyword-p a) + collect (if-let ((o (car (find-opts self (string-left-trim ":" a) :recurse t)))) + (prog1 (%compose-keyword-opt o (pop args)) + (setq skip t)) + (make-cli-node 'arg a)) else ;; CMD or ARG collect (let ((cmd (find-cmd self a))) diff -r 328e1ff73938 -r 119532882cb1 lisp/lib/cli/clap/opt.lisp --- a/lisp/lib/cli/clap/opt.lisp Sat Sep 14 23:55:38 2024 -0400 +++ b/lisp/lib/cli/clap/opt.lisp Sun Sep 15 19:34:00 2024 -0400 @@ -53,6 +53,10 @@ (setf (cli-opt-val o) val) (make-cli-node 'opt o)) +(defun %compose-keyword-opt (o val) + (setf (cli-opt-val o) val) + (make-cli-node 'opt o)) + (defmethod handle-unknown-argument ((self cli-opt) arg)) (defmethod handle-missing-argument ((self cli-opt) arg)) (defmethod handle-invalid-argument ((self cli-opt) arg)) diff -r 328e1ff73938 -r 119532882cb1 lisp/lib/cli/clap/pkg.lisp --- a/lisp/lib/cli/clap/pkg.lisp Sat Sep 14 23:55:38 2024 -0400 +++ b/lisp/lib/cli/clap/pkg.lisp Sun Sep 15 19:34:00 2024 -0400 @@ -14,7 +14,8 @@ (:export :args :arg0 :long-opt-p :short-opt-p :opt-group-p :opt-string-prefix-eq :cli-opt-kind-p :default-thunk - :long-opt-has-eq-p)) + :long-opt-has-eq-p + :opt-keyword-p)) (defpackage :cli/clap/macs (:use :cl :std :log :sb-ext :cli/clap/util :cli/clap/vars) @@ -61,7 +62,8 @@ :pasre-num-op :parse-file-op :parse-dir-op :cli :cli-cd :with-cli :opts :cmds :debug-opts :cli-opt :cli-cmd :cli-opt-val :cli-opt-lock :cli-opt-name - :active-cmds)) + :active-cmds + :%compose-keyword-opt)) (defpackage :cli/clap/simple (:use :cl :std :log :sb-ext) diff -r 328e1ff73938 -r 119532882cb1 lisp/lib/cli/clap/util.lisp --- a/lisp/lib/cli/clap/util.lisp Sat Sep 14 23:55:38 2024 -0400 +++ b/lisp/lib/cli/clap/util.lisp Sun Sep 15 19:34:00 2024 -0400 @@ -34,6 +34,10 @@ (declare (simple-string str)) (equalp str *cli-group-separator*)) +(defun opt-keyword-p (str) + (declare (simple-string str)) + (char= (aref str 0) #\:)) + (defun opt-string-prefix-eq (ch str) (declare (simple-string str) (character ch)) (char= ch (aref str 0))) diff -r 328e1ff73938 -r 119532882cb1 lisp/lib/skel/core/vm.lisp --- a/lisp/lib/skel/core/vm.lisp Sat Sep 14 23:55:38 2024 -0400 +++ b/lisp/lib/skel/core/vm.lisp Sun Sep 15 19:34:00 2024 -0400 @@ -36,6 +36,16 @@ (defvar *skel-arena* (new-skel-arena)) +(defvar *skel-ops* nil) + +(defvar *skel-scope* + (let ((scope (sb-lockless:make-so-map/fixnum))) + (set-so-scope scope 0 *skel-ops*) + (set-so-scope scope 1 nil) + scope)) + +(defvar *skel-stack*) + (defstruct (skel-op (:constructor make-skel-op (scope function))) (scope nil :type list :read-only t) (function #'identity :type function :read-only t)) @@ -43,8 +53,6 @@ (declaim (inline %sk-call)) (defun %sk-call (op) (funcall (skel-op-function op))) -(defvar *skel-ops* nil) - ;; TODO 2024-08-28: do we need to store arity or can we get by without it ;; being stored here? (defmacro define-skel-op (name scope lambda-list &body body) @@ -70,14 +78,6 @@ (ip 0 :type (integer 0 #.*skel-stack-size*)) ;; to be atomic type needs to be (unsigned-byte 64) (stack (make-skel-stack) :type (vector skel-op))) -(defvar *skel-scope* - (let ((scope (sb-lockless:make-so-map/fixnum))) - (set-so-scope scope 0 *skel-ops*) - (set-so-scope scope 1 nil) - scope)) - -(defvar *skel-stack*) - (defmacro with-skel-vm ((vm-sym &optional (vm (make-skel-vm)) (scope *skel-scope*) (arena *skel-arena*)) diff -r 328e1ff73938 -r 119532882cb1 skelfile --- a/skelfile Sat Sep 14 23:55:38 2024 -0400 +++ b/skelfile Sun Sep 15 19:34:00 2024 -0400 @@ -9,18 +9,18 @@ :tags ("core" "lisp" "rust" "emacs" "c") :include ("lisp.sk" "rust.sk" "emacs.sk") :vc (:hg "https://vc.compiler.company/core") -:scripts ((:lisp "x.lisp")) :env ((cc "clang")) :components ((:dir-locals ".dir-locals") (:org "readme")) :rules ((all (%stash psl.dat parquet.json rgb.txt - compile save-std save-prelude save-user - save-infra save-core save-tests build-rdb - build-core - build-skel build-organ build-homer build-packy - fasl rust-bin build-tree-sitter-alien)) + save-std save-prelude save-user + save-infra save-core save-tests + build-tree-sitter-alien build-core fasl + ;; build-skel build-organ build-homer build-packy build-rdb + ;; rust-bin + )) (clean () #$rm -vrf .stash$# #$find emacs -name '*.elc' -type f -delete$# @@ -95,18 +95,26 @@ (ql:quickload :bin/packy) (asdf:make :bin/packy)) #$mv lisp/bin/packy .stash/packy$#)) - (compile () #$./x.lisp compile$#) (std () (:save () (with-sbcl (:noinform t :quit t) (ql:quickload :std) (in-package :std-user) (compile-lisp :std :save ".stash/std.core")))) (prelude () - (:save () #$./x.lisp save prelude$#) - (:compile () #$./x.lisp make prelude$#)) + (:save () (with-sbcl (:noinform t :quit t) + (ql:quickload :prelude) + (in-package :std-user) + (compile-lisp :prelude :save ".stash/prelude.core"))) + (:compile () (compile-lisp :prelude :force t :verbose t))) (user () - (:save () #$./x.lisp save user$#) - (:compile () #$./x.lisp make user$#)) - (infra () (:save () #$./x.lisp save infra$#)) + (:save () (with-sbcl (:noinform t :quit t) + (ql:quickload :user) + (in-package :user) + (compile-lisp :user :save ".stash/user.core"))) + (:compile () (compile-lisp :user :force t :verbose t))) + (infra () (:save () (with-sbcl (:noinform t :quit t) + (ql:quickload :user) + (in-package :user) + (compile-lisp :user :save ".stash/infra.core" :compression 22)))) (core () (:build () (with-sbcl (:noinform t :quit t) (ql:quickload :bin/core) @@ -116,11 +124,21 @@ (ql:quickload (list :std :core)) (in-package :std-user) (compile-lisp :core :save ".stash/core.core"))) - (:compile () (compile-lisp :core :force t :verbose t))) + (:compile () (compile-lisp :core :force t :verbose t)) + (:install () #$install -C -m 755 .stash/core /usr/local/bin/core + echo "core -> /usr/local/bin/" + links="skel homer packy rdb organ" + for i in $links; do + ln -sf /usr/local/bin/core /usr/local/bin/$i + echo "$i -> core -> /usr/local/bin/" + done$#)) (tests () - (:save () #$./x.lisp save tests$#) - (:compile () #$./x.lisp make core/tests$#)) - (bench () (:compile () #$./x.lisp make core/bench$#)) + (:save () (with-sbcl (:noinform t :quit t) + (ql:quickload :core/tests) + (in-package :core/tests) + (compile-lisp :core/tests :save ".stash/tests.core"))) + (:compile () (compile-lisp :core/tests :force t :verbose t))) + (bench () (:compile () (compile-lisp :core/bench :force t :verbose t))) (fasl (compile-core compile-tests compile-bench compile-user compile-prelude)) ;; rust (mailman () #$cd rust && cargo build -Z unstable-options --bin mailman --artifact-dir ../.stash/$#) @@ -128,13 +146,9 @@ (rust-bin (mailman alik)) (alik-ui () #$trunk build --config rust/ui/alik/Trunk.toml$#) ;; install - (install () #$d=/usr/local/bin + (install (install-core) + #$d=/usr/local/share/lisp/ cd .stash - for f in $(find . -type f ! -name "*.*") - do echo "$(basename $f) -> $d" - install -C -m 755 $f $d - done - d=/usr/local/share/lisp if [ -d $d ]; then for f in $(find . -type f -name "*.core") @@ -142,12 +156,10 @@ install -C -m 755 $f $d done fi$#) (emacs () #$make -C emacs$#) - (core-syms.sxp () - (with-open-file (f "emacs/core-syms.sxp") - (write `(defvar lisp-standard-function-names ,(standard-symbol-names #'fboundp)) :stream f) - (write `(defvar lisp-standard-value-names ,(standard-symbol-names #'boundp)) :stream f))) + ;; TODO 2024-09-15: + (core-syms.sxp () (with-open-file (f ".stash/symbols.sxp" :direction :output))) (dist () #$cd .stash - mkdir -pv core/bin core/share/lisp/fasl core/lib + mkdir -pv core core/bin core/share/lisp/fasl core/lib mv *.core core/share/lisp/ mv *.fasl core/share/lisp/fasl/ mv *.so core/lib/