Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- :ASSIGN extended to be used with multiple value returning functions.

- README updated. (For both new :ASSIGN syntax and previous commit
  about :OPTINAL, :MANY and :SOME aliases.)
  • Loading branch information...
commit f00893bf7555667a954536d8befceffceb821914 1 parent f7874af
Volkan YAZICI authored
Showing with 13 additions and 4 deletions.
  1. +7 −1 README
  2. +6 −3 meta-sexp.lisp
8 README
View
@@ -141,10 +141,15 @@ SPACE? TAB? UPPER? WHITE-SPACE?
Calls specified RENDERER (that is defined with DEFRENDERER) with
supplied arguments.
+(:OPTIONAL FORM FORM ...)
(:? FORM FORM ...)
May appear once. (Similar to `?' in regular expressions.)
+
+(:MANY FORM FORM ...)
(:* FORM FORM ...)
May appear none or more. (Similar to `*' in regular expressions.)
+
+(:SOME FORM FORM ...)
(:+ FORM FORM ...)
Must appear at least once. (Similar to `{1,}' in regular expressions.)
@@ -156,8 +161,9 @@ SPACE? TAB? UPPER? WHITE-SPACE?
specified type/form.
(:ASSIGN VAR FORM)
+(:ASSIGN (VAR1 VAR2 ...) FORM)
Assigns returned value of FORM to VAR, and returns assigned
- value.
+ value. (Latter form works similar to MULTIPLE-VALUE-SETQ.)
(:LIST-PUSH ITEM-VAR LIST-ACCUM)
(:CHAR-PUSH CHAR-VAR CHAR-ACCUM)
9 meta-sexp.lisp
View
@@ -132,7 +132,7 @@
(:and `(and ,@(compile-exprs (cdr form))))
(:or `(or ,@(compile-exprs (cdr form))))
(:not (compile-expr `(:checkpoint (not ,(compile-expr (cadr form))))))
- (:return `(signal 'parser-return :value (values ,@(cdr form))))
+ (:return `(signal 'parser-return :value (list ,@(cdr form))))
(:render `(,(cadr form) ,@(nconc (list ctx) (cddr form))))
((:? :optional) `(prog1 t ,(compile-expr `(:and ,@(cdr form)))))
((:* :many) `(not (do () ((not ,(compile-expr `(:and ,@(cdr form))))))))
@@ -144,7 +144,10 @@
(compile-expr
`(:or ,@(mapcar #'(lambda (form) `(:rule ,form)) (cdadr form))))
`(match-rule ,ctx ,(cadr form) ,(cddr form))))
- (:assign `(setq ,(cadr form) ,(compile-expr (caddr form))))
+ (:assign
+ (if (consp (cadr form))
+ `(multiple-value-setq ,(cadr form) ,(compile-expr (caddr form)))
+ `(setq ,(cadr form) ,(compile-expr (caddr form)))))
(:list-push `(list-accum-push ,(cadr form) ,(caddr form)))
(:list-reset `(reset-list-accum ,(cadr form)))
(:char-push
@@ -190,7 +193,7 @@
,(compile-grammar ctx `(:checkpoint (:and ,@body))))
(compile-grammar ctx `(:checkpoint (:and ,@body))))
(parser-return (data)
- (return-from ,name (parser-return-value data)))))))
+ (return-from ,name (apply #'values (parser-return-value data))))))))
(defmacro defrenderer (name (&rest args) (&optional attachment) &body body)
(with-unique-names (ctx)
Please sign in to comment.
Something went wrong with that request. Please try again.