summaryrefslogtreecommitdiff
path: root/base.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2026-08-28 06:16:12 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2026-08-28 06:16:12 -0300
commit401fd8f16664d81d84c2fd7ecbc2333d6f3ec108 (patch)
tree72f168f760a8bb521a73535b46feafd29b33c2c0 /base.lisp
parent0150531bb547fc5f2a193eb3fa51e654e67c73e5 (diff)
downloadmonparser-401fd8f16664d81d84c2fd7ecbc2333d6f3ec108.tar.gz
monparser-401fd8f16664d81d84c2fd7ecbc2333d6f3ec108.zip
Prepare for new tracing and tidy up testing
Main stuff was moved into base so that I can better incorporate tracing in the future. I'm thinking it will involve modifying new and bind.
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