(in-package :mma) (defun parse-alternatives (end &aux (temp (parse-rule end)) res) ; E::=e1 \| e2 n-ary (Alternatives) (cond ((eolp end) temp) (temp (cond ((guess-token '|\|| ) ;;check first to avoid consing (setq res (cons temp nil)) (loop (cond ((eolp end)(return(parse-nary1 res 'Alternatives))) ((guess-token '|\||) (rt) (setq res (cons (parse-rule end) res))) (t (return(parse-nary1 res 'Alternatives))) ))) (t temp))) (t nil) ; not an Alternatives-expression )) ;;patched (defun parse-replace( end &aux(temp(parse-alternatives end))) (cond (temp (parse-replace1 temp end)) (t nil)))