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 TOKENREFS-ONLY)

Documentation

Return imenu index-alist for ANTLR grammar files.

IF TOKENREFS-ONLY is non-nil, just return alist with tokenref names.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/antlr-mode.el.gz
(defun antlr-imenu-create-index-function (&optional tokenrefs-only)
  "Return imenu index-alist for ANTLR grammar files.
IF TOKENREFS-ONLY is non-nil, just return alist with tokenref names."
  (let ((items nil)
	(classes nil)
	(continue t))
    ;; The generic imenu function searches backward, which is slower
    ;; and more likely not to work during editing.
    (with-syntax-table antlr-action-syntax-table
      (antlr-invalidate-context-cache)
      (goto-char (point-min))
      (antlr-skip-file-prelude t)
      (while continue
	(if (looking-at "{") (antlr-skip-sexps 1))
	(if (looking-at antlr-class-header-regexp)
	    (or tokenrefs-only
		(push (cons (match-string 2)
			    (if imenu-use-markers
				(copy-marker (match-beginning 2))
			      (match-beginning 2)))
		      classes))
	  (if (looking-at "p\\(ublic\\|rotected\\|rivate\\)")
	      (antlr-skip-sexps 1))
	  (when (looking-at "\\sw+")
	    (if tokenrefs-only
		(if (antlr-upcase-p (char-after (point)))
		    (push (list (match-string 0)) items))
	      (push (cons (match-string 0)
			  (if imenu-use-markers
			      (copy-marker (match-beginning 0))
			    (match-beginning 0)))
		    items))))
	(if (setq continue (antlr-search-forward ";"))
	    (antlr-skip-exception-part t))))
    (if classes
	(cons (cons "Classes" (nreverse classes)) (nreverse items))
      (nreverse items))))