;;; antlr-mode.el --- major mode for ANTLR grammar files
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
-;; Free Software Foundation, Inc.
-;;
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;; 2008, 2009, 2010 Free Software Foundation, Inc.
+
;; Author: Christoph.Wedler@sap.com
;; Keywords: languages, ANTLR, code generator
-;; Version: (see `antlr-version' below)
+;; Version: 2.2c
;; X-URL: http://antlr-mode.sourceforge.net/
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
-(provide 'antlr-mode)
+(eval-when-compile
+ (require 'cl))
+
(require 'easymenu)
+;; Just to get the rid of the byte compiler warning. The code for
+;; this function and its friends are too complex for their own good.
+(declare-function cond-emacs-xemacs-macfn "antlr-mode" (args &optional msg))
+
;; General Emacs/XEmacs-compatibility compile-time macros
-(eval-when-compile
- (require 'cl)
+(eval-when-compile
(defmacro cond-emacs-xemacs (&rest args)
(cond-emacs-xemacs-macfn
args "`cond-emacs-xemacs' must return exactly one element"))
(put 'save-buffer-state-x 'lisp-indent-function 0)
;; get rid of byte-compile warnings
-(eval-when-compile ; required and optional libraries
- (require 'cc-mode)
- (ignore-errors (require 'font-lock))
- (ignore-errors (require 'compile))
- ;;(ignore-errors (defun c-init-language-vars))) dangerous on Emacs!
- ;;(ignore-errors (defun c-init-c-language-vars))) dangerous on Emacs!
- ;;(ignore-errors (defun c-basic-common-init)) dangerous on Emacs!
- (defvar outline-level) (defvar imenu-use-markers)
- (defvar imenu-create-index-function))
+(eval-when-compile
+ (require 'cc-mode))
+
+(defvar outline-level)
+(defvar imenu-use-markers)
+(defvar imenu-create-index-function)
;; We cannot use `c-forward-syntactic-ws' directly since it is a macro since
;; cc-mode-5.30 => antlr-mode compiled with older cc-mode would fail (macro
:group 'antlr)
;; backward-compatibility alias
(put 'antlr-font-lock-default-face 'face-alias 'antlr-default)
+(put 'antlr-font-lock-default-face 'obsolete-face "22.1")
(defvar antlr-keyword-face 'antlr-keyword)
(defface antlr-keyword
(cond-emacs-xemacs
'((((class color) (background light))
- (:foreground "black" :EMACS :weight bold :XEMACS :bold t))))
+ (:foreground "black" :EMACS :weight bold :XEMACS :bold t))
+ (t :inherit font-lock-keyword-face)))
"ANTLR keywords."
:group 'antlr)
;; backward-compatibility alias
(put 'antlr-font-lock-keyword-face 'face-alias 'antlr-keyword)
+(put 'antlr-font-lock-keyword-face 'obsolete-face "22.1")
(defvar antlr-syntax-face 'antlr-keyword)
(defface antlr-syntax
(cond-emacs-xemacs
'((((class color) (background light))
- (:foreground "black" :EMACS :weight bold :XEMACS :bold t))))
+ (:foreground "black" :EMACS :weight bold :XEMACS :bold t))
+ (t :inherit font-lock-constant-face)))
"ANTLR syntax symbols like :, |, (, ), ...."
:group 'antlr)
;; backward-compatibility alias
(put 'antlr-font-lock-syntax-face 'face-alias 'antlr-syntax)
+(put 'antlr-font-lock-syntax-face 'obsolete-face "22.1")
(defvar antlr-ruledef-face 'antlr-ruledef)
(defface antlr-ruledef
(cond-emacs-xemacs
'((((class color) (background light))
- (:foreground "blue" :EMACS :weight bold :XEMACS :bold t))))
+ (:foreground "blue" :EMACS :weight bold :XEMACS :bold t))
+ (t :inherit font-lock-function-name-face)))
"ANTLR rule references (definition)."
:group 'antlr)
;; backward-compatibility alias
(put 'antlr-font-lock-ruledef-face 'face-alias 'antlr-ruledef)
+(put 'antlr-font-lock-ruledef-face 'obsolete-face "22.1")
(defvar antlr-tokendef-face 'antlr-tokendef)
(defface antlr-tokendef
(cond-emacs-xemacs
'((((class color) (background light))
- (:foreground "blue" :EMACS :weight bold :XEMACS :bold t))))
+ (:foreground "blue" :EMACS :weight bold :XEMACS :bold t))
+ (t :inherit font-lock-function-name-face)))
"ANTLR token references (definition)."
:group 'antlr)
;; backward-compatibility alias
(put 'antlr-font-lock-tokendef-face 'face-alias 'antlr-tokendef)
+(put 'antlr-font-lock-tokendef-face 'obsolete-face "22.1")
(defvar antlr-ruleref-face 'antlr-ruleref)
(defface antlr-ruleref
- '((((class color) (background light)) (:foreground "blue4")))
+ '((((class color) (background light)) (:foreground "blue4"))
+ (t :inherit font-lock-type-face))
"ANTLR rule references (usage)."
:group 'antlr)
;; backward-compatibility alias
(put 'antlr-font-lock-ruleref-face 'face-alias 'antlr-ruleref)
+(put 'antlr-font-lock-ruleref-face 'obsolete-face "22.1")
(defvar antlr-tokenref-face 'antlr-tokenref)
(defface antlr-tokenref
- '((((class color) (background light)) (:foreground "orange4")))
+ '((((class color) (background light)) (:foreground "orange4"))
+ (t :inherit font-lock-type-face))
"ANTLR token references (usage)."
:group 'antlr)
;; backward-compatibility alias
(put 'antlr-font-lock-tokenref-face 'face-alias 'antlr-tokenref)
+(put 'antlr-font-lock-tokenref-face 'obsolete-face "22.1")
(defvar antlr-literal-face 'antlr-literal)
(defface antlr-literal
(cond-emacs-xemacs
'((((class color) (background light))
- (:foreground "brown4" :EMACS :weight bold :XEMACS :bold t))))
+ (:foreground "brown4" :EMACS :weight bold :XEMACS :bold t))
+ (t :inherit font-lock-string-face)))
"ANTLR special literal tokens.
It is used to highlight strings matched by the first regexp group of
`antlr-font-lock-literal-regexp'."
:group 'antlr)
;; backward-compatibility alias
(put 'antlr-font-lock-literal-face 'face-alias 'antlr-literal)
+(put 'antlr-font-lock-literal-face 'obsolete-face "22.1")
(defcustom antlr-font-lock-literal-regexp "\"\\(\\sw\\(\\sw\\|-\\)*\\)\""
"Regexp matching literals with special syntax highlighting, or nil.
`((antlr-invalidate-context-cache)
("\\$setType[ \t]*(\\([A-Za-z\300-\326\330-\337]\\sw*\\))"
(1 antlr-tokendef-face))
- ("\\$\\sw+" (0 keyword-face))
+ ("\\$\\sw+" (0 antlr-keyword-face))
;; the tokens are already fontified as string/docstrings:
(,(lambda (limit)
(if antlr-font-lock-literal-regexp
(3 antlr-keyword-face)
(4 (if (member (match-string 4) '("Lexer" "Parser" "TreeParser"))
antlr-keyword-face
- type-face)))
+ font-lock-type-face)))
(,(lambda (limit)
(antlr-re-search-forward
"\\<\\(header\\|options\\|tokens\\|exception\\|catch\\|returns\\)\\>"
;; checkdoc-params: (dummies)
"Invalidate context cache for syntactical context information."
:XEMACS ; XEmacs bug workaround
- (save-excursion
- (set-buffer (get-buffer-create " ANTLR XEmacs bug workaround"))
+ (with-current-buffer (get-buffer-create " ANTLR XEmacs bug workaround")
(buffer-syntactic-context-depth)
nil)
:EMACS
(read initial)
initial))
(cdr value))))
- (message (cadr value))
+ (message "%s" (or (cadr value) ""))
(setq value nil)))
;; insert value ----------------------------------------------------------
(if (consp old)
"\\'"))
classes dependencies)
(unwind-protect
- (save-excursion
- (set-buffer temp-buffer)
+ (with-current-buffer temp-buffer
(widen) ; just in case...
(dolist (file grammar)
(when (and (file-regular-p file)
(let ((context (antlr-syntactic-context)))
(not (and (numberp context)
(or (zerop context)
- (memq last-command-char '(?\{ ?\}))))))))
+ (memq last-command-event '(?\{ ?\}))))))))
(self-insert-command (prefix-numeric-value arg))
(self-insert-command (prefix-numeric-value arg))
(antlr-indent-line)))
indent-tabs-mode (cadddr elem)
alist nil))))))
+(provide 'antlr-mode)
+
;;; Local IspellPersDict: .ispell_antlr
-;;; arch-tag: 5de2be79-3d13-4560-8fbc-f7d0234dcb5c
+;; arch-tag: 5de2be79-3d13-4560-8fbc-f7d0234dcb5c
;;; antlr-mode.el ends here