aboutsummaryrefslogtreecommitdiffstats
path: root/util.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'util.lisp')
-rw-r--r--util.lisp10
1 files changed, 10 insertions, 0 deletions
diff --git a/util.lisp b/util.lisp
index aee8efe..ae34184 100644
--- a/util.lisp
+++ b/util.lisp
@@ -228,3 +228,13 @@ determine whether CHAR must be escaped."
character set."
(escape-string string :test #'non-7bit-ascii-escape-char-p))
+(defun extract-declarations (body)
+ "Given a FORM, the declarations - if any - will be exctracted
+ from the head of the FORM, and will return two values the declarations,
+ and the remaining of FORM"
+ (do ((sexp (first body) (first forms))
+ (forms (rest body) (rest forms))
+ (declarations nil))
+ ((not (eq (first sexp) 'cl:declare))
+ (values declarations (append (if (null sexp) sexp (list sexp)) forms)))
+ (push sexp declarations)))