• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/progmodes/

Lines Matching +defs:mode +defs:class

1 ;;; antlr-mode.el --- major mode for ANTLR grammar files
9 ;; X-URL: http://antlr-mode.sourceforge.net/
35 ;; For details, check <http://antlr-mode.sourceforge.net/> or, if you prefer
37 ;; `antlr-mode'. ANTLR is a LL(k)-based recognition tool which generates
53 ;; definitions at beginning of grammar class.
60 ;; profiling in a class init action shows half the time is spent in
63 ;; Questions/problems: is sather-mode.el the standard mode for sather, is it
65 ;; this mode must not depend on a Sather mode.
68 ;; Problems: code size, this mode would depend on font-lock internals.
72 ;; This file requires Emacs-20.3, XEmacs-20.4 or higher and package cc-mode.
74 ;; If antlr-mode is not part of your distribution, put this file into your
76 ;; (autoload 'antlr-mode "antlr-mode" nil t)
77 ;; (setq auto-mode-alist (cons '("\\.g\\'" . antlr-mode) auto-mode-alist))
78 ;; (add-hook 'speedbar-load-hook ; would be too late in antlr-mode.el
81 ;; I strongly recommend to use font-lock with a support mode like fast-lock,
88 (provide 'antlr-mode)
103 (mode :BOTH) code)
105 (if (memq (car args) '(:EMACS :XEMACS :BOTH)) (setq mode (pop args)))
107 (or args (error "Used selector %s without elements" mode))
108 (or (eq ignore mode)
112 ((or (null args) (eq ignore mode)) (nreverse code))
180 (require 'cc-mode)
190 ;; cc-mode-5.30 => antlr-mode compiled with older cc-mode would fail (macro
191 ;; call) when used with newer cc-mode. Also, antlr-mode compiled with newer
192 ;; cc-mode would fail (undefined `c-forward-sws') when used with older cc-mode.
195 ;; cc-mode.
205 "Major mode for ANTLR grammar files."
207 :link '(emacs-commentary-link "antlr-mode.el")
208 :link '(url-link "http://antlr-mode.sourceforge.net/")
212 "ANTLR major mode version number.
213 Check <http://antlr-mode.sourceforge.net/> for the newest.")
221 "Major mode corresponding to ANTLR's \"language\" option.
223 buffer-local variable yourself is in `antlr-mode-hook' or in the \"local
228 '((java-mode "Java" nil "\"Java\"" "Java")
229 (c++-mode "C++" "\"Cpp\"" "Cpp"))
234 MAJOR-MODE, the major mode of the code in the grammar's actions, is the
240 :type '(repeat (group :value (java-mode "")
241 (function :tag "Major mode")
282 '((antlr-mode nil 4 nil)
283 (java-mode "antlr" 4 nil))
286 The first element whose MAJOR-MODE is nil or equal to `major-mode' and
288 set `tab-width' and `indent-tabs-mode'. This is useful to support both
291 :type '(repeat (group :value (antlr-mode nil 8 nil)
293 (function :tag "Major mode"))
296 (boolean :tag "Indent-tabs-mode"))))
299 "*If non-nil, cc-mode indentation style used for `antlr-mode'.
314 '((java-mode . "\\(package\\|import\\)\\>")
315 (c++-mode . "#\\(assert\\|cpu\\|define\\|endif\\|el\\(if\\|se\\)\\|i\\(dent\\|f\\(def\\|ndef\\)?\\|mport\\|nclude\\(_next\\)?\\)\\|line\\|machine\\|pragma\\|system\\|un\\(assert\\|def\\)\\|warning\\)\\>"))
325 :type '(repeat (cons (function :tag "Major mode") regexp)))
333 block-close defun-close class-close brace-list-close arglist-close
342 "*Non-nil, if the major mode menu should include option submenus.
424 ("namespace" antlr-c++-mode-extra
427 ("namespaceStd" antlr-c++-mode-extra
430 ("namespaceAntlr" antlr-c++-mode-extra
433 ("genHashLines" antlr-c++-mode-extra
485 "Additional string for grammar class definition"))
490 ("namespace" antlr-c++-mode-extra
493 ("namespaceStd" antlr-c++-mode-extra
496 ("namespaceAntlr" antlr-c++-mode-extra
499 ("genHashLines" antlr-c++-mode-extra
550 defined in future versions of this mode. The phase `before-input'
554 this mode.
623 '((java-mode ("%sTokenTypes.java") ("%s.java"))
624 (c++-mode ("%sTokenTypes.hpp") ("%s.cpp" "%s.hpp")))
636 CLASS/%s the generated file for each grammar class CLASS.")
646 grammar file if the file GRAMMAR.g contains a grammar class which
647 extends a class other than \"Lexer\", \"Parser\" or \"TreeParser\".
658 grammar file in the current directory defines the class SUPER or if it
661 of above mentioned class SUPER.")
696 (defvar antlr-mode-map
722 "Keymap used in `antlr-mode' buffers.")
724 (easy-menu-define antlr-mode-menu antlr-mode-map
725 "Major mode menu."
784 While calculating the decoration level for actions, `major-mode' is
786 \((java-mode \. 2) (c++-mode \. 0))
814 '((java-mode
818 (c++-mode
842 '((((class color) (background light))
852 '((((class color) (background light))
862 '((((class color) (background light))
872 '((((class color) (background light))
881 '((((class color) (background light)) (:foreground "blue4")))
889 '((((class color) (background light)) (:foreground "orange4")))
898 '((((class color) (background light))
916 (defvar antlr-class-header-regexp
917 "\\(class\\)[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]+\\(extends\\)[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]*;"
918 "Regexp matching class headers.")
933 (antlr-re-search-forward antlr-class-header-regexp limit))
989 (defvar antlr-mode-hook nil
990 "Hook called by `antlr-mode'.")
992 (defvar antlr-mode-syntax-table nil
993 "Syntax table used in `antlr-mode' buffers.
994 If non-nil, it will be initialized in `antlr-mode'.")
999 Initialized by `antlr-mode-syntax-table', changed by SYNTAX-ALIST in
1004 (defvar antlr-mode-abbrev-table nil
1005 "Abbreviation table used in `antlr-mode' buffers.")
1006 (define-abbrev-table 'antlr-mode-abbrev-table ())
1239 (eval (let ((major-mode antlr-language)) ; dynamic
1271 (if (looking-at antlr-class-header-regexp)
1302 This also includes the options and tokens part of a grammar class
1306 (class nil))
1309 (setq class t)
1311 (if class
1312 ;; Problem: an action only belongs to a class def, not a normal rule.
1346 A grammar class header and the file prelude are also considered as a
1406 A grammar class header and the file prelude are also considered as a
1414 A grammar class header and the file prelude are also considered as a
1425 A grammar class header and the file prelude are also considered as a
1436 A grammar class header is also considered as a rule. With optional
1718 If the result is 2, point is at the beginning of the class after the
1719 class definition. If the result is 3 or 4, point is at the beginning of
1733 (let (boc) ; beginning of class
1736 (antlr-re-search-forward antlr-class-header-regexp
1750 ((looking-at antlr-class-header-regexp) ; rule = class def?
1759 (set-syntax-table antlr-mode-syntax-table)
2055 Call `antlr-mode' if the new language would be different from the value
2056 of `antlr-language', keeping the value of variable `font-lock-mode'.
2063 (let ((font-lock (and (boundp 'font-lock-mode) font-lock-mode)))
2064 (if font-lock (font-lock-mode 0))
2065 (antlr-mode)
2066 (and font-lock (null font-lock-mode) (font-lock-mode 1)))))))
2068 (defun antlr-c++-mode-extra (phase option &rest dummies)
2072 `antlr-language' has not the value `c++-mode'.
2076 (not (eq antlr-language 'c++-mode))
2097 Each CLASS is a grammar class with its export vocabulary CLASS-EVOCAB.
2098 Each SUPER is a super-grammar class where USE-EVOCAB-P indicates whether
2105 (while (antlr-re-search-forward antlr-class-header-regexp nil)
2106 ;; parse class definition --------------------------------------------
2107 (let* ((class (match-string 2))
2109 ;; export vocab defaults to class name (first grammar in file)
2111 (evocab (or default-vocab class))
2137 ;; remember class with export vocabulary:
2138 (push (cons class evocab) classes)
2156 `antlr-file-dependencies'. For each grammar class CLASS, FILE is a
2177 (normal-mode t) ; necessary for major-mode, syntax
2179 (when (eq major-mode 'antlr-mode)
2183 (dolist (class-def (caadr file-deps))
2184 (let ((file-evocab (cons file (cdr class-def)))
2185 (class-spec (assoc (car class-def) classes)))
2186 (if class-spec
2187 (nconc (cdr class-spec) (list file-evocab))
2188 (push (list (car class-def) file-evocab)
2214 ;; analyzer of the same class twice in a file will lead to an error anyway...
2245 nil #'(lambda (mode-name) "*Antlr-Run*"))))
2302 (dolist (class-def (caadr dep))
2304 (dolist (class-file (cadr lang))
2305 (insert sep (format class-file (car class-def)))
2348 If the `major-mode' of the current buffer has the value `makefile-mode',
2363 (if (null (eq major-mode 'makefile-mode))
2422 ;; check whether to use indentation engine of cc-mode ------------------
2426 (cond ((> syntax 1) ; block in action => use cc-mode
2441 ;;; ((= indent 1) ; exception part => use cc-mode
2443 ;;; ((save-restriction ; not in option part => cc-mode
2451 ;; Use the indentation engine of cc-mode
2464 ;; the usual major-mode indent stuff ---------------------------------
2478 command, insert ARG tabs or spaces according to `indent-tabs-mode'.
2519 "Like `c-init-language-vars-for' when using cc-mode before v5.29."
2521 (if (eq antlr-language 'c++-mode)
2522 (cdr '(setq ;' from `c++-mode' v5.20, v5.28
2526 c-class-key c-C++-class-key
2532 (cdr '(setq ; from `java-mode' v5.20, v5.28
2536 c-class-key c-Java-class-key
2541 c-inexpr-class-key c-Java-inexpr-class-key ; v5.28
2571 (defun antlr-mode ()
2572 "Major mode for editing ANTLR grammar files.
2573 \\{antlr-mode-map}"
2576 (c-initialize-cc-mode) ; cc-mode is required
2580 (setq major-mode 'antlr-mode
2581 mode-name "Antlr")
2582 (setq local-abbrev-table antlr-mode-abbrev-table)
2583 (unless antlr-mode-syntax-table
2584 (setq antlr-mode-syntax-table (make-syntax-table))
2585 (c-populate-syntax-table antlr-mode-syntax-table))
2586 (set-syntax-table antlr-mode-syntax-table)
2590 (copy-syntax-table antlr-mode-syntax-table))
2595 (use-local-map antlr-mode-map)
2601 (setq mode-name
2605 (setq c-buffer-is-cc-mode antlr-language)
2606 (cond ((fboundp 'c-init-language-vars-for) ; cc-mode 5.30.5+
2608 ((fboundp 'c-init-c-language-vars) ; cc-mode 5.30 to 5.30.4
2611 ((fboundp 'c-init-language-vars) ; cc-mode 5.29
2614 (t ; cc-mode upto 5.28
2624 (setq require-final-newline mode-require-final-newline)
2633 (easy-menu-add antlr-mode-menu)
2643 (run-mode-hooks 'antlr-mode-hook))
2645 ;; A smarter version of `group-buffers-menu-by-mode-then-alphabetically' (in
2648 (put 'antlr-mode 'mode-name "Antlr")
2653 Used in `antlr-mode'. Also a useful function in `java-mode-hook'."
2658 (and (or (null (car elem)) (eq (car elem) major-mode))
2662 indent-tabs-mode (cadddr elem)
2668 ;;; antlr-mode.el ends here