diff options
| author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2026-01-15 01:55:29 -0300 |
|---|---|---|
| committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2026-01-15 01:55:29 -0300 |
| commit | f753bfdffbd7ce0975b97ad44098b857f25c39a9 (patch) | |
| tree | 1c6e82febdadc583eb86da2f38625d4f508a47c7 /main.lisp | |
| parent | 9566e92321a1ed29a7f5903a3ba4ab16de3783b9 (diff) | |
| download | monparser-f753bfdffbd7ce0975b97ad44098b857f25c39a9.tar.gz monparser-f753bfdffbd7ce0975b97ad44098b857f25c39a9.zip | |
Improve usability
Diffstat (limited to 'main.lisp')
| -rw-r--r-- | main.lisp | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -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.")))) |
