1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

peg.el: Fix bug#79502 a bit more

* lisp/progmodes/peg.el (peg--detect-cycles): Accept args.
(peg--detect-cycles) <funcall>: New method.
This commit is contained in:
Stefan Monnier 2025-09-27 22:57:02 -04:00
parent 021b7065bb
commit b9573f8f1a

View file

@ -837,7 +837,7 @@ input. PATH is the list of rules that we have visited so far."
(cl-defgeneric peg--detect-cycles (head _path &rest args)
(error "No detect-cycle method for: %S" (cons head args)))
(cl-defmethod peg--detect-cycles (path (_ (eql call)) name)
(cl-defmethod peg--detect-cycles (path (_ (eql call)) name &rest _args)
(if (member name path)
(error "Possible left recursion: %s"
(mapconcat (lambda (x) (format "%s" x))
@ -885,6 +885,13 @@ input. PATH is the list of rules that we have visited so far."
(cl-defmethod peg--detect-cycles (_path (_ (eql guard)) _e) t)
(cl-defmethod peg--detect-cycles (_path (_ (eql =)) _s) nil)
(cl-defmethod peg--detect-cycles (_path (_ (eql syntax-class)) _n) nil)
(cl-defmethod peg--detect-cycles (_path (_ (eql funcall)) &rest _args)
;; There might very well be a cycle here, and we may very well match
;; the empty string, but it's much too hard (and in general
;; impossible) to try and figure out.
nil)
(cl-defmethod peg--detect-cycles (_path (_ (eql action)) _form) t)
(defun peg-merge-errors (exps)