Function: antlr-imenu-create-index-function
antlr-imenu-create-index-function is a byte-compiled function defined
in antlr-mode.el.gz.
Signature
(antlr-imenu-create-index-function &optional REFS-ONLY)
Documentation
Return imenu index-alist for ANTLR grammar files.
IF REFS-ONLY is non-nil, just return alist with ref names,
with value upcase, only return alist with tokenref names.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/antlr-mode.el.gz
;; TODO: version dependent?
(defun antlr-imenu-create-index-function (&optional refs-only)
"Return imenu index-alist for ANTLR grammar files.
IF REFS-ONLY is non-nil, just return alist with ref names,
with value `upcase', only return alist with tokenref names."
(let ((items nil)
(classes nil)
(continue t))
;; Using `imenu-progress-message' would require imenu for compilation, but
;; nobody is missing these messages. The generic imenu function searches
;; backward, which is slower and more likely not to work during editing.
(goto-char (point-min))
(antlr-skip-file-prelude t)
(while continue
(if (looking-at "\\(class\\|lexer[ \t]+grammar\\|parser[ \t]+grammar\\|tree[ \t]+grammar\\|grammar\\|mode\\|import\\)[ \t]+\\([A-Za-z\300-\326\330-\337]\\(?:\\sw\\|\\s_\\)*\\)") ; TODO: import is (hopefully) temp
(and (not refs-only)
(memq (char-after (match-beginning 1)) '(?c ?m)) ;class, mode
(push (cons (match-string-no-properties 2)
(if imenu-use-markers
(copy-marker (match-beginning 2))
(match-beginning 2)))
classes))
(if (looking-at "p\\(ublic\\|rotected\\|rivate\\)\\_>\\|fragment\\_>")
(antlr-skip-sexps 1))
(when (looking-at "\\(?:\\sw\\|\\s_\\)+")
(when (or (not (eq refs-only 'upcase))
(antlr-upcase-p (char-after (point))))
(push (cons (match-string-no-properties 0)
(if (and imenu-use-markers (not refs-only))
(copy-marker (match-beginning 0))
(match-beginning 0)))
items))))
(if (setq continue (antlr-search-forward ";" antlr-skip-line-regexp))
(antlr-skip-rule-postlude t)))
(if classes
(cons (cons (if (eq antlr-tool-version 'antlr-v2) "Classes" "Modes")
(nreverse classes))
(nreverse items))
(nreverse items))))