Bison Mode by Eric Beuscher, 1998:
Handy imenu function for jumping around to different rules in a bison/yacc file. Call this in your .y file however you like.
(setq imenu-create-index-function
(lambda ()
(let ((end))
(beginning-of-buffer)
(re-search-forward "^%%")
(forward-line 1)
(setq end (save-excursion (re-search-forward "^%%") (point)))
(loop while (re-search-forward "^\\([a-z].*?\\)\\s-*\n?\\s-*:" end t)
collect (cons (match-string 1) (point))))))
See also FlexMode.