changelog shortlog graph tags branches files raw help

Mercurial > core / changeset: added keyword-opts (experimental)

changeset 653: 119532882cb1
parent 652: 328e1ff73938
child 654: 3dd1924ad5ea
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 15 Sep 2024 19:34:00 -0400
files: lisp/lib/cli/clap/cmd.lisp lisp/lib/cli/clap/opt.lisp lisp/lib/cli/clap/pkg.lisp lisp/lib/cli/clap/util.lisp lisp/lib/skel/core/vm.lisp skelfile
description: added keyword-opts (experimental)
     1.1--- a/lisp/lib/cli/clap/cmd.lisp	Sat Sep 14 23:55:38 2024 -0400
     1.2+++ b/lisp/lib/cli/clap/cmd.lisp	Sun Sep 15 19:34:00 2024 -0400
     1.3@@ -182,7 +182,14 @@
     1.4                (clap-unknown-argument a 'cli-opt)))))
     1.5      ;; OPT GROUP
     1.6      else if (opt-group-p a)
     1.7-     collect (make-cli-node 'group nil)
     1.8+     collect 
     1.9+        (make-cli-node 'group nil)
    1.10+     ;; OPT KEYWORD (experimental)
    1.11+     else if (opt-keyword-p a)
    1.12+     collect (if-let ((o (car (find-opts self (string-left-trim ":" a) :recurse t))))
    1.13+               (prog1 (%compose-keyword-opt o (pop args))
    1.14+                 (setq skip t))
    1.15+               (make-cli-node 'arg a))
    1.16      else ;; CMD or ARG
    1.17      collect
    1.18         (let ((cmd (find-cmd self a)))
     2.1--- a/lisp/lib/cli/clap/opt.lisp	Sat Sep 14 23:55:38 2024 -0400
     2.2+++ b/lisp/lib/cli/clap/opt.lisp	Sun Sep 15 19:34:00 2024 -0400
     2.3@@ -53,6 +53,10 @@
     2.4   (setf (cli-opt-val o) val)
     2.5   (make-cli-node 'opt o))
     2.6 
     2.7+(defun %compose-keyword-opt (o val)
     2.8+  (setf (cli-opt-val o) val)
     2.9+  (make-cli-node 'opt o))
    2.10+
    2.11 (defmethod handle-unknown-argument ((self cli-opt) arg))
    2.12 (defmethod handle-missing-argument ((self cli-opt) arg))
    2.13 (defmethod handle-invalid-argument ((self cli-opt) arg))
     3.1--- a/lisp/lib/cli/clap/pkg.lisp	Sat Sep 14 23:55:38 2024 -0400
     3.2+++ b/lisp/lib/cli/clap/pkg.lisp	Sun Sep 15 19:34:00 2024 -0400
     3.3@@ -14,7 +14,8 @@
     3.4   (:export :args :arg0 :long-opt-p
     3.5    :short-opt-p :opt-group-p :opt-string-prefix-eq :cli-opt-kind-p
     3.6    :default-thunk
     3.7-   :long-opt-has-eq-p))
     3.8+   :long-opt-has-eq-p
     3.9+   :opt-keyword-p))
    3.10 
    3.11 (defpackage :cli/clap/macs
    3.12   (:use :cl :std :log :sb-ext :cli/clap/util :cli/clap/vars)
    3.13@@ -61,7 +62,8 @@
    3.14    :pasre-num-op :parse-file-op :parse-dir-op :cli
    3.15    :cli-cd :with-cli :opts :cmds :debug-opts
    3.16    :cli-opt :cli-cmd :cli-opt-val :cli-opt-lock :cli-opt-name
    3.17-   :active-cmds))
    3.18+   :active-cmds
    3.19+   :%compose-keyword-opt))
    3.20 
    3.21 (defpackage :cli/clap/simple
    3.22   (:use :cl :std :log :sb-ext)
     4.1--- a/lisp/lib/cli/clap/util.lisp	Sat Sep 14 23:55:38 2024 -0400
     4.2+++ b/lisp/lib/cli/clap/util.lisp	Sun Sep 15 19:34:00 2024 -0400
     4.3@@ -34,6 +34,10 @@
     4.4   (declare (simple-string str))
     4.5   (equalp str *cli-group-separator*))
     4.6 
     4.7+(defun opt-keyword-p (str)
     4.8+  (declare (simple-string str))
     4.9+  (char= (aref str 0) #\:))
    4.10+
    4.11 (defun opt-string-prefix-eq (ch str)
    4.12   (declare (simple-string str) (character ch))
    4.13   (char= ch (aref str 0)))
     5.1--- a/lisp/lib/skel/core/vm.lisp	Sat Sep 14 23:55:38 2024 -0400
     5.2+++ b/lisp/lib/skel/core/vm.lisp	Sun Sep 15 19:34:00 2024 -0400
     5.3@@ -36,6 +36,16 @@
     5.4 
     5.5 (defvar *skel-arena* (new-skel-arena))
     5.6 
     5.7+(defvar *skel-ops* nil)
     5.8+
     5.9+(defvar *skel-scope*
    5.10+  (let ((scope (sb-lockless:make-so-map/fixnum)))
    5.11+    (set-so-scope scope 0 *skel-ops*)
    5.12+    (set-so-scope scope 1 nil)
    5.13+    scope))
    5.14+
    5.15+(defvar *skel-stack*)
    5.16+
    5.17 (defstruct (skel-op (:constructor make-skel-op (scope function)))
    5.18   (scope nil :type list :read-only t)
    5.19   (function #'identity :type function :read-only t))
    5.20@@ -43,8 +53,6 @@
    5.21 (declaim (inline %sk-call))
    5.22 (defun %sk-call (op) (funcall (skel-op-function op)))
    5.23 
    5.24-(defvar *skel-ops* nil)
    5.25-
    5.26 ;; TODO 2024-08-28: do we need to store arity or can we get by without it
    5.27 ;; being stored here?
    5.28 (defmacro define-skel-op (name scope lambda-list &body body)
    5.29@@ -70,14 +78,6 @@
    5.30   (ip 0 :type (integer 0 #.*skel-stack-size*)) ;; to be atomic type needs to be (unsigned-byte 64)
    5.31   (stack (make-skel-stack) :type (vector skel-op)))
    5.32 
    5.33-(defvar *skel-scope*
    5.34-  (let ((scope (sb-lockless:make-so-map/fixnum)))
    5.35-    (set-so-scope scope 0 *skel-ops*)
    5.36-    (set-so-scope scope 1 nil)
    5.37-    scope))
    5.38-
    5.39-(defvar *skel-stack*)
    5.40-
    5.41 (defmacro with-skel-vm ((vm-sym &optional (vm (make-skel-vm))
    5.42                                           (scope *skel-scope*)
    5.43                                           (arena *skel-arena*))
     6.1--- a/skelfile	Sat Sep 14 23:55:38 2024 -0400
     6.2+++ b/skelfile	Sun Sep 15 19:34:00 2024 -0400
     6.3@@ -9,18 +9,18 @@
     6.4 :tags ("core" "lisp" "rust" "emacs" "c")
     6.5 :include ("lisp.sk" "rust.sk" "emacs.sk")
     6.6 :vc (:hg "https://vc.compiler.company/core")
     6.7-:scripts ((:lisp "x.lisp"))
     6.8 :env ((cc "clang"))
     6.9 :components ((:dir-locals ".dir-locals")
    6.10              (:org "readme"))
    6.11 :rules
    6.12 ((all (%stash
    6.13        psl.dat parquet.json rgb.txt
    6.14-       compile save-std save-prelude save-user
    6.15-       save-infra save-core save-tests build-rdb
    6.16-       build-core
    6.17-       build-skel build-organ build-homer build-packy
    6.18-       fasl rust-bin build-tree-sitter-alien))
    6.19+       save-std save-prelude save-user
    6.20+       save-infra save-core save-tests
    6.21+       build-tree-sitter-alien build-core fasl
    6.22+       ;; build-skel build-organ build-homer build-packy build-rdb
    6.23+       ;; rust-bin
    6.24+       ))
    6.25  (clean ()
    6.26         #$rm -vrf .stash$#
    6.27         #$find emacs -name '*.elc' -type f -delete$#
    6.28@@ -95,18 +95,26 @@
    6.29                      (ql:quickload :bin/packy)
    6.30                      (asdf:make :bin/packy))
    6.31                 #$mv lisp/bin/packy .stash/packy$#))
    6.32- (compile () #$./x.lisp compile$#)
    6.33  (std () (:save () (with-sbcl (:noinform t :quit t)
    6.34                      (ql:quickload :std)
    6.35                      (in-package :std-user)
    6.36                      (compile-lisp :std :save ".stash/std.core"))))
    6.37  (prelude ()
    6.38-          (:save () #$./x.lisp save prelude$#)
    6.39-          (:compile () #$./x.lisp make prelude$#))
    6.40+          (:save () (with-sbcl (:noinform t :quit t)
    6.41+                      (ql:quickload :prelude)
    6.42+                      (in-package :std-user)
    6.43+                      (compile-lisp :prelude :save ".stash/prelude.core")))
    6.44+          (:compile () (compile-lisp :prelude :force t :verbose t)))
    6.45  (user ()
    6.46-       (:save () #$./x.lisp save user$#)
    6.47-       (:compile () #$./x.lisp make user$#))
    6.48- (infra () (:save () #$./x.lisp save infra$#))
    6.49+       (:save () (with-sbcl (:noinform t :quit t)
    6.50+                   (ql:quickload :user)
    6.51+                   (in-package :user)
    6.52+                   (compile-lisp :user :save ".stash/user.core")))
    6.53+       (:compile () (compile-lisp :user :force t :verbose t)))
    6.54+ (infra () (:save () (with-sbcl (:noinform t :quit t)
    6.55+                       (ql:quickload :user)
    6.56+                       (in-package :user)
    6.57+                       (compile-lisp :user :save ".stash/infra.core" :compression 22))))
    6.58  (core ()
    6.59        (:build () (with-sbcl (:noinform t :quit t)
    6.60                     (ql:quickload :bin/core)
    6.61@@ -116,11 +124,21 @@
    6.62                    (ql:quickload (list :std :core))
    6.63                    (in-package :std-user)
    6.64                    (compile-lisp :core :save ".stash/core.core")))
    6.65-       (:compile () (compile-lisp :core :force t :verbose t)))
    6.66+       (:compile () (compile-lisp :core :force t :verbose t))
    6.67+       (:install () #$install -C -m 755 .stash/core /usr/local/bin/core
    6.68+                 echo "core -> /usr/local/bin/"
    6.69+                 links="skel homer packy rdb organ"
    6.70+                 for i in $links; do
    6.71+                 ln -sf /usr/local/bin/core /usr/local/bin/$i
    6.72+                 echo "$i -> core -> /usr/local/bin/"
    6.73+                 done$#))
    6.74  (tests ()
    6.75-        (:save () #$./x.lisp save tests$#)
    6.76-        (:compile () #$./x.lisp make core/tests$#))
    6.77- (bench () (:compile () #$./x.lisp make core/bench$#))
    6.78+        (:save () (with-sbcl (:noinform t :quit t)
    6.79+                    (ql:quickload :core/tests)
    6.80+                    (in-package :core/tests)
    6.81+                    (compile-lisp :core/tests :save ".stash/tests.core")))
    6.82+        (:compile () (compile-lisp :core/tests :force t :verbose t)))
    6.83+ (bench () (:compile () (compile-lisp :core/bench :force t :verbose t)))
    6.84  (fasl (compile-core compile-tests compile-bench compile-user compile-prelude))
    6.85  ;; rust
    6.86  (mailman () #$cd rust && cargo build -Z unstable-options --bin mailman --artifact-dir ../.stash/$#)
    6.87@@ -128,13 +146,9 @@
    6.88  (rust-bin (mailman alik))
    6.89  (alik-ui () #$trunk build --config rust/ui/alik/Trunk.toml$#)
    6.90  ;; install
    6.91- (install () #$d=/usr/local/bin
    6.92+ (install (install-core) 
    6.93+          #$d=/usr/local/share/lisp/
    6.94           cd .stash
    6.95-          for f in $(find . -type f ! -name "*.*")
    6.96-          do echo "$(basename $f) -> $d"
    6.97-          install -C -m 755 $f $d
    6.98-          done
    6.99-          d=/usr/local/share/lisp
   6.100           if [ -d $d ];
   6.101           then
   6.102           for f in $(find . -type f -name "*.core")
   6.103@@ -142,12 +156,10 @@
   6.104           install -C -m 755 $f $d
   6.105           done fi$#)
   6.106  (emacs () #$make -C emacs$#)
   6.107- (core-syms.sxp ()
   6.108-                (with-open-file (f "emacs/core-syms.sxp")
   6.109-                  (write `(defvar lisp-standard-function-names ,(standard-symbol-names #'fboundp)) :stream f)
   6.110-                  (write `(defvar lisp-standard-value-names ,(standard-symbol-names #'boundp)) :stream f)))
   6.111+ ;; TODO 2024-09-15: 
   6.112+ (core-syms.sxp () (with-open-file (f ".stash/symbols.sxp" :direction :output)))
   6.113  (dist () #$cd .stash
   6.114-       mkdir -pv core/bin core/share/lisp/fasl core/lib
   6.115+       mkdir -pv core core/bin core/share/lisp/fasl core/lib
   6.116        mv *.core core/share/lisp/
   6.117        mv *.fasl core/share/lisp/fasl/
   6.118        mv *.so core/lib/