summaryrefslogtreecommitdiff
path: root/base.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'base.lisp')
-rw-r--r--base.lisp16
1 files changed, 16 insertions, 0 deletions
diff --git a/base.lisp b/base.lisp
index 7c72501..5531562 100644
--- a/base.lisp
+++ b/base.lisp
@@ -18,6 +18,22 @@
(deftype parser ()
`(function (cursor) result))
+(declaim (ftype (function (parser string) result) parse))
+(defun parse (parser data)
+ (funcall parser (make-cursor :data data)))
+
+(defmacro defparser (name args parser)
+ (let ((message (format nil "In ~a:~&" name)))
+ (if (and (listp args) (every #'symbolp args))
+ (let (definition)
+ (when (= (length args) 0)
+ (push `(defparameter ,name (,name)) definition))
+ (push `(defun ,name (,@args) ,parser)
+ definition)
+ (push 'progn definition)
+ definition)
+ (error "Malformed argument list."))))
+
(defmacro lazy (parser &rest args)
(let ((input (gensym)))
`(the parser