diff --git a/peg.el b/peg.el index 0e4221eeb7..fa7e23619f 100644 --- a/peg.el +++ b/peg.el @@ -314,10 +314,14 @@ RULES is a list of rules of the form (NAME . PEXS), where PEXS is a sequence of PEG expressions, implicitly combined with `and'." (declare (indent 1) (debug (sexp form))) ;FIXME: `sexp' is not good enough! (let ((rules - ;; First, macroexpand the rules. - (mapcar (lambda (rule) - (cons (car rule) (peg-normalize `(and . ,(cdr rule))))) - rules)) + (progn + ;; Handle RULES as a variable. + (when (symbolp rules) + (setq rules (symbol-value rules))) + ;; Then macroexpand the rules. + (mapcar (lambda (rule) + (cons (car rule) (peg-normalize `(and . ,(cdr rule))))) + rules))) (ctx (assq :peg-rules macroexpand-all-environment))) (macroexpand-all `(cl-labels