about summary refs log tree commit diff stats
path: root/ccmd.lisp
diff options
context:
space:
mode:
authorDarren Bane <dbane@tilde.institute>2020-07-30 23:01:26 +0100
committerDarren Bane <dbane@tilde.institute>2020-07-30 23:01:26 +0100
commit628c87c1a75e48c34888031f2aca3695b5a704cf (patch)
tree52d0841ee0bd19c2dbe46871d4108379bef29465 /ccmd.lisp
parentbd88ae0b1da3e48032a251ce779f347329a52ed7 (diff)
downloadlsp-628c87c1a75e48c34888031f2aca3695b5a704cf.tar.gz
Maybe CL is better after all
Diffstat (limited to 'ccmd.lisp')
-rw-r--r--ccmd.lisp28
1 files changed, 28 insertions, 0 deletions
diff --git a/ccmd.lisp b/ccmd.lisp
new file mode 100644
index 0000000..a3eeabd
--- /dev/null
+++ b/ccmd.lisp
@@ -0,0 +1,28 @@
+(require "split-sequence")
+(defpackage #:ccmd
+  (:use #:common-lisp #:split-sequence)
+  (:export
+    #:parse
+    #:create-tab
+    #:fun
+    #:lookup)
+  )
+(in-package #:ccmd)
+(defclass <buf> () ((buf :initarg b :reader buf) (f :initarg f :reader f)))
+(defun parse (p)
+  (let ((toks (split-sequence-if (lambda (c) (member c '(#\Space #\Tab))) p)))
+    (format *error-output* "parse: p ~A toks ~A~%" p toks)
+    (make-instance (find-class '<buf>) 'b (car toks) 'f toks)))
+(defclass <tab> () ((fun :initarg f :reader fun)
+                    (cmd :initarg c :reader cmd)
+                    (narg :initarg n :reader narg)))
+(defun create-tab (f c n)
+  (make-instance (find-class '<tab>) 'f f 'c c 'n n))
+(defgeneric lookup (buf tab))
+(defmethod lookup ((buf <buf>) tabs)
+  (let ((cmd (buf buf)))
+    (find-if (lambda (tab)
+               (let ((c (cmd tab)))
+                 (string= c cmd)))
+             tabs)))
+(provide "ccmd")