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 definition and the file prelude of Antlr v2 grammars 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 definition and the file prelude of Antlr v2
grammars 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."
;; PRE: ARG<>0
(let ((pos (point))
(beg (point)))
;; first look whether point is in rule postlude
(if (antlr-search-backward ";" antlr-skip-line-regexp)
(progn
(setq beg (point))
(forward-char)
(antlr-skip-rule-postlude 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 ";" antlr-skip-line-regexp)
(setq beg (point))
(when (>= arg -1)
;; try file prelude:
(setq pos (antlr-skip-file-prelude skip-comment)) ; header pos
(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-rule-postlude skip-comment)))
(if (<= (point) pos) ; moved backward?
(goto-char pos) ; rewind
(decf arg)) ; already moved one defun forward
(unless (zerop arg)
(while (>= (decf arg) 0)
(antlr-search-forward ";" antlr-skip-line-regexp))
(antlr-skip-rule-postlude skip-comment)))))