Function: antlr-option-kind
antlr-option-kind is a byte-compiled function defined in
antlr-mode.el.gz.
Signature
(antlr-option-kind REQUESTED)
Documentation
Return level and location for option to insert near point.
Call function antlr-option-level with argument REQUESTED. If the
result is nil, return (REQUESTED . error). If the result has the
non-nil value LEVEL, return (LEVEL . LOCATION) where LOCATION looks
like (AREA . PLACE), see antlr-option-location.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/antlr-mode.el.gz
;;;===========================================================================
;;; Insert option: determine section-kind
;;;===========================================================================
(defun antlr-option-kind (requested)
"Return level and location for option to insert near point.
Call function `antlr-option-level' with argument REQUESTED. If the
result is nil, return \(REQUESTED . error). If the result has the
non-nil value LEVEL, return \(LEVEL . LOCATION) where LOCATION looks
like \(AREA . PLACE), see `antlr-option-location'."
(save-excursion
(save-restriction
(let ((min0 (point-min)) ; before `widen'!
(max0 (point-max))
(orig (point))
(level (antlr-option-level requested)) ; calls `widen'!
pos)
(cond ((null level)
(setq level requested))
((eq level 1) ; file options
(goto-char (point-min))
(setq pos (antlr-skip-file-prelude 'header-only)))
((not (eq level 3)) ; grammar or subrule options
(setq pos (point))
(antlr-c-forward-sws))
((looking-at "^\\(private[ \t\n]\\|public[ \t\n]\\|protected[ \t\n]\\)?[ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]*\\(!\\)?[ \t\n]*\\(\\[\\)?")
;; rule options, with complete rule header
(goto-char (or (match-end 4) (match-end 3)))
(setq pos (antlr-skip-sexps (if (match-end 5) 1 0)))
(when (looking-at "returns[ \t\n]*\\[")
(goto-char (1- (match-end 0)))
(setq pos (antlr-skip-sexps 1)))))
(cons level
(cond ((null pos) 'error)
((looking-at "options[ \t\n]*{")
(goto-char (match-end 0))
(setq pos (ignore-errors (scan-lists (point) 1 1)))
(antlr-option-location orig min0 max0
(point)
(if pos (1- pos) (point-max))
t))
(t
(antlr-option-location orig min0 max0
pos (point)
nil))))))))