summaryrefslogtreecommitdiff
path: root/main.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2026-01-15 01:55:29 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2026-01-15 01:55:29 -0300
commitf753bfdffbd7ce0975b97ad44098b857f25c39a9 (patch)
tree1c6e82febdadc583eb86da2f38625d4f508a47c7 /main.lisp
parent9566e92321a1ed29a7f5903a3ba4ab16de3783b9 (diff)
downloadmonparser-f753bfdffbd7ce0975b97ad44098b857f25c39a9.tar.gz
monparser-f753bfdffbd7ce0975b97ad44098b857f25c39a9.zip
Improve usability
Diffstat (limited to 'main.lisp')
-rw-r--r--main.lisp15
1 files changed, 9 insertions, 6 deletions
diff --git a/main.lisp b/main.lisp
index 3e6f255..683b70f 100644
--- a/main.lisp
+++ b/main.lisp
@@ -18,9 +18,12 @@
(defmacro defparser (name args parser)
(let ((message (format nil "In ~a:~&" name)))
- (cond ((equal args :const)
- `(defparameter ,name (append-on-failure ,parser ,message)))
- ((listp args)
- `(defun ,name ,args (append-on-failure ,parser ,message)))
- (t (error
- (format nil "Cannot define ~a: ~a is not :const or a list." name args))))))
+ (if (and (listp args) (every #'symbolp args))
+ (let (definition)
+ (when (= (length args) 0)
+ (push `(defparameter ,name (,name)) definition))
+ (push `(defun ,name (,@args) (append-on-failure ,parser ,message))
+ definition)
+ (push 'progn definition)
+ definition)
+ (error "Malformed argument list."))))