Function: peg-detect-cycles
peg-detect-cycles is a byte-compiled function defined in peg.el.gz.
Signature
(peg-detect-cycles EXP PATH)
Documentation
Signal an error on a cycle.
Otherwise traverse EXP recursively and return T if EXP can match without consuming input. Return nil if EXP definitely consumes input. PATH is the list of rules that we have visited so far.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/peg.el.gz
;; Left recursion is presumably a common mistake when using PEGs.
;; Here we try to detect such mistakes. Essentially we traverse the
;; graph as long as we can without consuming input. When we find a
;; recursive call we signal an error.
(defun peg-detect-cycles (exp path)
"Signal an error on a cycle.
Otherwise traverse EXP recursively and return T if EXP can match
without consuming input. Return nil if EXP definitely consumes
input. PATH is the list of rules that we have visited so far."
(apply #'peg--detect-cycles path exp))