blob: e186a4eecdd2fbaee0c45b92b0fd9a6d49e06296 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
(defpackage #:cmd
(:use #:openlisp)
(:export
#:parse
#:create-tab
#:fun
#:lookup)
)
(in-package #:cmd)
(defclass <buf> () ((buf :initarg b :reader buf)
(f :initarg f :reader f)))
(defconstant +ht+ (convert 9 <character>))
(defun parse (p)
(let ((toks (string-split (list #\Space +ht+) p)))
(create (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)
(create (class <tab>) 'f f 'c c 'n n))
(defgeneric lookup (buf tabs))
(defmethod lookup ((buf <buf>) tabs)
(let ((cmd (buf buf)))
(find-if (lambda (tab)
(let ((c (cmd tab)))
(string= c cmd)))
tabs)))
(provide "cmd")
|