about summary refs log blame commit diff stats
path: root/cmd.lsp
blob: e186a4eecdd2fbaee0c45b92b0fd9a6d49e06296 (plain) (tree)



























                                                     
(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")