From d3989d23895ff0039c18ee582dbaad80ebc1b8e8 Mon Sep 17 00:00:00 2001 From: Attila Lendvai <attila.lendvai@gmail.com> Date: Sun, 22 Oct 2006 13:57:44 +0300 Subject: [PATCH] Extended parse-body with a :whole arg, report multiple docstring error. --- macros.lisp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/macros.lisp b/macros.lisp index 539595c..495430a 100644 --- a/macros.lisp +++ b/macros.lisp @@ -24,19 +24,21 @@ Example: ,(let ,(mapcar #'list names gensyms) ,@forms))))) -(defun parse-body (body &key documentation) - "Parses BODY into documentation string, declarations, and remaining forms. -Documentation strings are recognized only if DOCUMENTATION is true. Returns -three values: list of remaining forms, list of declarations, and documentation -string if any." +(defun parse-body (body &key documentation whole) + "Parses BODY into (values remaining-forms declarations doc-string). +Documentation strings are recognized only if DOCUMENTATION is true. +Syntax errors in body are signalled and WHOLE is used in the signal +arguments when given." (let ((doc nil) (decls nil) (current nil)) (tagbody :declarations (setf current (car body)) - (when (and documentation (stringp current) (not doc) (cdr body)) - (setf doc (pop body)) + (when (and documentation (stringp current) (cdr body)) + (if doc + (error "Too many documentation strings in ~S." (or whole body)) + (setf doc (pop body))) (go :declarations)) (when (starts-with 'declare current) (push (pop body) decls) -- GitLab