Function: antlr-next-rule
antlr-next-rule is a byte-compiled function defined in
antlr-mode.el.gz.
Signature
(antlr-next-rule ARG SKIP-COMMENT)
Documentation
Move forward to next end of rule. Do it ARG many times.
A grammar class header and the file prelude are also considered as a rule. Negative argument ARG means move back to ARGth preceding end of rule. The behavior is not defined when ARG is zero. If SKIP-COMMENT is non-nil, move to beginning of the rule.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/antlr-mode.el.gz
(defun antlr-next-rule (arg skip-comment)
"Move forward to next end of rule. Do it ARG many times.
A grammar class header and the file prelude are also considered as a
rule. Negative argument ARG means move back to ARGth preceding end of
rule. The behavior is not defined when ARG is zero. If SKIP-COMMENT
is non-nil, move to beginning of the rule."
;; WARNING: Should only be used with `antlr-action-syntax-table'!
;; PRE: ARG<>0
(let ((pos (point))
(beg (point)))
;; first look whether point is in exception part
(if (antlr-search-backward ";")
(progn
(setq beg (point))
(forward-char)
(antlr-skip-exception-part skip-comment))
(antlr-skip-file-prelude skip-comment))
(if (< arg 0)
(unless (and (< (point) pos) (zerop (cl-incf arg)))
;; if we have moved backward, we already moved one defun backward
(goto-char beg) ; rewind (to ";" / point)
(while (and arg (<= (cl-incf arg) 0))
(if (antlr-search-backward ";")
(setq beg (point))
(when (>= arg -1)
;; try file prelude:
(setq pos (antlr-skip-file-prelude skip-comment))
(if (zerop arg)
(if (>= (point) beg)
(goto-char (if (>= pos beg) (point-min) pos)))
(goto-char (if (or (>= (point) beg) (= (point) pos))
(point-min) pos))))
(setq arg nil)))
(when arg ; always found a ";"
(forward-char)
(antlr-skip-exception-part skip-comment)))
(if (<= (point) pos) ; moved backward?
(goto-char pos) ; rewind
(cl-decf arg)) ; already moved one defun forward
(unless (zerop arg)
(while (>= (cl-decf arg) 0)
(antlr-search-forward ";"))
(antlr-skip-exception-part skip-comment)))))