Mercurial > emacs
annotate lisp/progmodes/antlr-mode.el @ 64565:e4fcf58d872c
(widget-default-create, widget-after-change, widget-default-format-handler,
widget-checklist-add-item, widget-radio-add-item, widget-choose,
widget-specify-secret, widget-field-value-create, widget-field-value-get,
widget-editable-list-format-handler, widget-editable-list-entry-create,
widget-group-value-create, widget-documentation-link-add,
widget-documentation-string-value-create): "?\ " -> "?\s".
(widget-convert-text): Doc fix.
(widget-narrow-to-field, widget-field-find, widget-url-link-action,
widget-emacs-library-link-action, widget-color-notify): Fix typos in docstrings.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Thu, 21 Jul 2005 11:41:54 +0000 |
parents | 18a818a2ee7c |
children | 629afbe74e61 f9a65d7ebd29 |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38100
diff
changeset
|
1 ;;; antlr-mode.el --- major mode for ANTLR grammar files |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
4 ;; |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
5 ;; Author: Christoph.Wedler@sap.com |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
6 ;; Keywords: languages, ANTLR, code generator |
49554 | 7 ;; Version: (see `antlr-version' below) |
8 ;; X-URL: http://antlr-mode.sourceforge.net/ | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
9 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
11 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
15 ;; any later version. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
16 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
21 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
26 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
27 ;;; Commentary: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
28 |
49554 | 29 ;; The Emacs package ANTLR-Mode provides: syntax highlighting for ANTLR grammar |
30 ;; files, automatic indentation, menus containing rule/token definitions and | |
31 ;; supported options and various other things like running ANTLR from within | |
32 ;; Emacs. | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
33 |
49554 | 34 ;; For details, check <http://antlr-mode.sourceforge.net/> or, if you prefer |
35 ;; the manual style, follow all commands mentioned in the documentation of | |
36 ;; `antlr-mode'. ANTLR is a LL(k)-based recognition tool which generates | |
37 ;; lexers, parsers and tree transformers in Java, C++ or Sather and can be | |
38 ;; found at <http://www.antlr.org/>. | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
39 |
49554 | 40 ;; Bug fixes, bug reports, improvements, and suggestions for the newest version |
41 ;; are strongly appreciated. | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
42 |
49554 | 43 ;; To-do/Wish-list: |
44 ;; | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
45 ;; * Next Version [C-c C-w]. Produce HTML document with syntax highlighted |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
46 ;; and hyper-links (using htmlize). |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
47 ;; * Next Version [C-c C-u]. Insert/update special comments: each rule lists |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
48 ;; all rules which use the current rule. With font-lock update. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
49 ;; * Next Version. Make hiding much more customizable. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
50 ;; * Planned [C-c C-j]. Jump to generated coding. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
51 ;; * Planned. Further support for imenu, i.e., include entries for method |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
52 ;; definitions at beginning of grammar class. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
53 ;; * Planned [C-c C-p]. Pack/unpack rule/subrule & options (one/multi-line). |
49554 | 54 ;; |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
55 ;; * Probably. Show rules/dependencies for ANT like for Makefile (does ANT |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
56 ;; support vocabularies and grammar inheritance?), I have to look at |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
57 ;; jde-ant.el: http://jakarta.apache.org/ant/manual/OptionalTasks/antlr.html |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
58 ;; * Probably. Make `indent-region' faster, especially in actions. ELP |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
59 ;; profiling in a class init action shows half the time is spent in |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
60 ;; `antlr-next-rule', the other half in `c-guess-basic-syntax'. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
61 ;; * Unlikely. Sather as generated language with syntax highlighting etc/. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
62 ;; Questions/problems: is sather-mode.el the standard mode for sather, is it |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
63 ;; still supported, what is its relationship to eiffel3.el? Requirement: |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
64 ;; this mode must not depend on a Sather mode. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
65 ;; * Unlikely. Faster syntax highlighting: sectionize the buffer into Antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
66 ;; and action code and run special highlighting functions on these regions. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
67 ;; Problems: code size, this mode would depend on font-lock internals. |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
68 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
69 ;;; Installation: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
70 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
71 ;; This file requires Emacs-20.3, XEmacs-20.4 or higher and package cc-mode. |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
72 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
73 ;; If antlr-mode is not part of your distribution, put this file into your |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
74 ;; load-path and the following into your ~/.emacs: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
75 ;; (autoload 'antlr-mode "antlr-mode" nil t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
76 ;; (setq auto-mode-alist (cons '("\\.g\\'" . antlr-mode) auto-mode-alist)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
77 ;; (add-hook 'speedbar-load-hook ; would be too late in antlr-mode.el |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
78 ;; (lambda () (speedbar-add-supported-extension ".g"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
79 |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
80 ;; I strongly recommend to use font-lock with a support mode like fast-lock, |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
81 ;; lazy-lock or better jit-lock (Emacs-21.1+) / lazy-shot (XEmacs). |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
82 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
83 ;; To customize, use menu item "Antlr" -> "Customize Antlr". |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
84 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
85 ;;; Code: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
86 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
87 (provide 'antlr-mode) |
49554 | 88 (require 'easymenu) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
89 |
49554 | 90 ;; General Emacs/XEmacs-compatibility compile-time macros |
91 (eval-when-compile | |
92 (require 'cl) | |
93 (defmacro cond-emacs-xemacs (&rest args) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49554
diff
changeset
|
94 (cond-emacs-xemacs-macfn |
49554 | 95 args "`cond-emacs-xemacs' must return exactly one element")) |
96 (defun cond-emacs-xemacs-macfn (args &optional msg) | |
97 (if (atom args) args | |
98 (and (eq (car args) :@) (null msg) ; (:@ ...spliced...) | |
99 (setq args (cdr args) | |
100 msg "(:@ ....) must return exactly one element")) | |
101 (let ((ignore (if (string-match "XEmacs" emacs-version) :EMACS :XEMACS)) | |
102 (mode :BOTH) code) | |
103 (while (consp args) | |
104 (if (memq (car args) '(:EMACS :XEMACS :BOTH)) (setq mode (pop args))) | |
105 (if (atom args) | |
106 (or args (error "Used selector %s without elements" mode)) | |
107 (or (eq ignore mode) | |
108 (push (cond-emacs-xemacs-macfn (car args)) code)) | |
109 (pop args))) | |
110 (cond (msg (if (or args (cdr code)) (error msg) (car code))) | |
111 ((or (null args) (eq ignore mode)) (nreverse code)) | |
112 (t (nconc (nreverse code) args)))))) | |
113 ;; Emacs/XEmacs-compatibility `defun': remove interactive "_" for Emacs, use | |
114 ;; existing functions when they are `fboundp', provide shortcuts if they are | |
115 ;; known to be defined in a specific Emacs branch (for short .elc) | |
116 (defmacro defunx (name arglist &rest definition) | |
117 (let ((xemacsp (string-match "XEmacs" emacs-version)) reuses) | |
118 (while (memq (car definition) | |
119 '(:try :emacs-and-try :xemacs-and-try)) | |
120 (if (eq (pop definition) (if xemacsp :xemacs-and-try :emacs-and-try)) | |
121 (setq reuses (car definition) | |
122 definition nil) | |
123 (push (pop definition) reuses))) | |
124 (if (and reuses (symbolp reuses)) | |
125 `(defalias ',name ',reuses) | |
126 (let* ((docstring (if (stringp (car definition)) (pop definition))) | |
127 (spec (and (not xemacsp) | |
128 (eq (car-safe (car definition)) 'interactive) | |
129 (null (cddar definition)) | |
130 (cadar definition)))) | |
131 (if (and (stringp spec) | |
132 (not (string-equal spec "")) | |
133 (eq (aref spec 0) ?_)) | |
134 (setq definition | |
135 (cons (if (string-equal spec "_") | |
136 '(interactive) | |
137 `(interactive ,(substring spec 1))) | |
138 (cdr definition)))) | |
139 (if (null reuses) | |
140 `(defun ,name ,arglist ,docstring | |
141 ,@(cond-emacs-xemacs-macfn definition)) | |
142 ;; no dynamic docstring in this case | |
143 `(eval-and-compile ; no warnings in Emacs | |
144 (defalias ',name | |
145 (cond ,@(mapcar (lambda (func) `((fboundp ',func) ',func)) | |
146 (nreverse reuses)) | |
147 (t ,(if definition | |
148 `(lambda ,arglist ,docstring | |
149 ,@(cond-emacs-xemacs-macfn definition)) | |
150 'ignore)))))))))) | |
151 (defmacro ignore-errors-x (&rest body) | |
152 (let ((specials '((scan-sexps . 4) (scan-lists . 5))) | |
153 spec nils) | |
154 (if (and (string-match "XEmacs" emacs-version) | |
155 (null (cdr body)) (consp (car body)) | |
156 (setq spec (assq (caar body) specials)) | |
157 (>= (setq nils (- (cdr spec) (length (car body)))) 0)) | |
158 `(,@(car body) ,@(make-list nils nil) t) | |
159 `(ignore-errors ,@body))))) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
160 |
49554 | 161 ;; More compile-time-macros |
162 (eval-when-compile | |
163 (defmacro save-buffer-state-x (&rest body) ; similar to EMACS/lazy-lock.el | |
53418
af00346728dd
(save-buffer-state-x): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
52890
diff
changeset
|
164 (let ((modified (with-no-warnings (gensym "save-buffer-state-x-modified-")))) |
49554 | 165 `(let ((,modified (buffer-modified-p))) |
166 (unwind-protect | |
167 (let ((buffer-undo-list t) (inhibit-read-only t) | |
168 ,@(unless (string-match "XEmacs" emacs-version) | |
169 '((inhibit-point-motion-hooks t) deactivate-mark)) | |
170 before-change-functions after-change-functions | |
171 buffer-file-name buffer-file-truename) | |
172 ,@body) | |
173 (and (not ,modified) (buffer-modified-p) | |
174 (set-buffer-modified-p nil))))))) | |
175 (put 'save-buffer-state-x 'lisp-indent-function 0) | |
176 | |
177 ;; get rid of byte-compile warnings | |
178 (eval-when-compile ; required and optional libraries | |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
179 (require 'cc-mode) |
49554 | 180 (ignore-errors (require 'font-lock)) |
181 (ignore-errors (require 'compile)) | |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
182 ;;(ignore-errors (defun c-init-language-vars))) dangerous on Emacs! |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
183 ;;(ignore-errors (defun c-init-c-language-vars))) dangerous on Emacs! |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
184 ;;(ignore-errors (defun c-basic-common-init)) dangerous on Emacs! |
49554 | 185 (defvar outline-level) (defvar imenu-use-markers) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
186 (defvar imenu-create-index-function)) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
187 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
188 ;; We cannot use `c-forward-syntactic-ws' directly since it is a macro since |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
189 ;; cc-mode-5.30 => antlr-mode compiled with older cc-mode would fail (macro |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
190 ;; call) when used with newer cc-mode. Also, antlr-mode compiled with newer |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
191 ;; cc-mode would fail (undefined `c-forward-sws') when used with older cc-mode. |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
192 ;; Additional to the `defalias' below, we must set `antlr-c-forward-sws' to |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
193 ;; `c-forward-syntactic-ws' when `c-forward-sws' is not defined after requiring |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
194 ;; cc-mode. |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
195 (defalias 'antlr-c-forward-sws 'c-forward-sws) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
196 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
197 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
198 ;;;;########################################################################## |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
199 ;;;; Variables |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
200 ;;;;########################################################################## |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
201 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
202 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
203 (defgroup antlr nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
204 "Major mode for ANTLR grammar files." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
205 :group 'languages |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
206 :link '(emacs-commentary-link "antlr-mode.el") |
49554 | 207 :link '(url-link "http://antlr-mode.sourceforge.net/") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
208 :prefix "antlr-") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
209 |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
210 (defconst antlr-version "2.2c" |
49554 | 211 "ANTLR major mode version number. |
212 Check <http://antlr-mode.sourceforge.net/> for the newest.") | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
213 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
214 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
215 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
216 ;;; Controlling ANTLR's code generator (language option) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
217 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
218 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
219 (defvar antlr-language nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
220 "Major mode corresponding to ANTLR's \"language\" option. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
221 Set via `antlr-language-alist'. The only useful place to change this |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
222 buffer-local variable yourself is in `antlr-mode-hook' or in the \"local |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
223 variable list\" near the end of the file, see |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
224 `enable-local-variables'.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
225 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
226 (defcustom antlr-language-alist |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
227 '((java-mode "Java" nil "\"Java\"" "Java") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
228 (c++-mode "C++" "\"Cpp\"" "Cpp")) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
229 "List of ANTLR's supported languages. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
230 Each element in this list looks like |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
231 \(MAJOR-MODE MODELINE-STRING OPTION-VALUE...) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
232 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
233 MAJOR-MODE, the major mode of the code in the grammar's actions, is the |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
234 value of `antlr-language' if the first group in the string matched by |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
235 REGEXP in `antlr-language-limit-n-regexp' is one of the OPTION-VALUEs. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
236 An OPTION-VALUE of nil denotes the fallback element. MODELINE-STRING is |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
237 also displayed in the modeline next to \"Antlr\"." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
238 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
239 :type '(repeat (group :value (java-mode "") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
240 (function :tag "Major mode") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
241 (string :tag "Modeline string") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
242 (repeat :tag "ANTLR language option" :inline t |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
243 (choice (const :tag "Default" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
244 string ))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
245 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
246 (defcustom antlr-language-limit-n-regexp |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
247 '(8192 . "language[ \t]*=[ \t]*\\(\"?[A-Z][A-Za-z_]*\"?\\)") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
248 "Used to set a reasonable value for `antlr-language'. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
249 Looks like \(LIMIT \. REGEXP). Search for REGEXP from the beginning of |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
250 the buffer to LIMIT and use the first group in the matched string to set |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
251 the language according to `antlr-language-alist'." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
252 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
253 :type '(cons (choice :tag "Limit" (const :tag "No" nil) (integer :value 0)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
254 regexp)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
255 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
256 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
257 ;;;=========================================================================== |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
258 ;;; Hide/Unhide, Indent/Tabs |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
259 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
260 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
261 (defcustom antlr-action-visibility 3 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
262 "Visibility of actions when command `antlr-hide-actions' is used. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
263 If nil, the actions with their surrounding braces are hidden. If a |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
264 number, do not hide the braces, only hide the contents if its length is |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
265 greater than this number." |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
266 :group 'antlr |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
267 :type '(choice (const :tag "Completely hidden" nil) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
268 (integer :tag "Hidden if longer than" :value 3))) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
269 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
270 (defcustom antlr-indent-comment 'tab |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
271 "*Non-nil, if the indentation should touch lines in block comments. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
272 If nil, no continuation line of a block comment is changed. If t, they |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
273 are changed according to `c-indentation-line'. When not nil and not t, |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
274 they are only changed by \\[antlr-indent-command]." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
275 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
276 :type '(radio (const :tag "No" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
277 (const :tag "Always" t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
278 (sexp :tag "With TAB" :format "%t" :value tab))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
279 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
280 (defcustom antlr-tab-offset-alist |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
281 '((antlr-mode nil 4 nil) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
282 (java-mode "antlr" 4 nil)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
283 "Alist to determine whether to use ANTLR's convention for TABs. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
284 Each element looks like \(MAJOR-MODE REGEXP TAB-WIDTH INDENT-TABS-MODE). |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
285 The first element whose MAJOR-MODE is nil or equal to `major-mode' and |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
286 whose REGEXP is nil or matches variable `buffer-file-name' is used to |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
287 set `tab-width' and `indent-tabs-mode'. This is useful to support both |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
288 ANTLR's and Java's indentation styles. Used by `antlr-set-tabs'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
289 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
290 :type '(repeat (group :value (antlr-mode nil 8 nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
291 (choice (const :tag "All" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
292 (function :tag "Major mode")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
293 (choice (const :tag "All" nil) regexp) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
294 (integer :tag "Tab width") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
295 (boolean :tag "Indent-tabs-mode")))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
296 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
297 (defcustom antlr-indent-style "java" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
298 "*If non-nil, cc-mode indentation style used for `antlr-mode'. |
49554 | 299 See `c-set-style' and for details, where the most interesting part in |
300 `c-style-alist' is the value of `c-basic-offset'." | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
301 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
302 :type '(choice (const nil) regexp)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
303 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
304 (defcustom antlr-indent-item-regexp |
49554 | 305 "[]}):;|&]" ; & is local ANTLR extension (SGML's and-connector) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
306 "Regexp matching lines which should be indented by one TAB less. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
307 See `antlr-indent-line' and command \\[antlr-indent-command]." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
308 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
309 :type 'regexp) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
310 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
311 (defcustom antlr-indent-at-bol-alist |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
312 ;; eval-when-compile not usable with defcustom... |
49554 | 313 '((java-mode . "\\(package\\|import\\)\\>") |
314 (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\\)\\>")) | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
315 "Alist of regexps matching lines are indented at column 0. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
316 Each element in this list looks like (MODE . REGEXP) where MODE is a |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
317 function and REGEXP is a regular expression. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
318 |
49554 | 319 If `antlr-language' equals to a MODE, the line starting at the first |
320 non-whitespace is matched by the corresponding REGEXP, and the line is | |
321 part of an header action, indent the line at column 0 instead according | |
322 to the normal rules of `antlr-indent-line'." | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
323 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
324 :type '(repeat (cons (function :tag "Major mode") regexp))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
325 |
49554 | 326 ;; adopt indentation to cc-engine |
327 (defvar antlr-disabling-cc-syntactic-symbols | |
328 '(statement-block-intro | |
329 defun-block-intro topmost-intro statement-case-intro member-init-intro | |
330 arglist-intro brace-list-intro knr-argdecl-intro inher-intro | |
331 objc-method-intro | |
332 block-close defun-close class-close brace-list-close arglist-close | |
333 inline-close extern-lang-close namespace-close)) | |
334 | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
335 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
336 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
337 ;;; Options: customization |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
338 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
339 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
340 (defcustom antlr-options-use-submenus t |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
341 "*Non-nil, if the major mode menu should include option submenus. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
342 If nil, the menu just includes a command to insert options. Otherwise, |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
343 it includes four submenus to insert file/grammar/rule/subrule options." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
344 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
345 :type 'boolean) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
346 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
347 (defcustom antlr-tool-version 20701 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
348 "*The version number of the Antlr tool. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
349 The value is an integer of the form XYYZZ which stands for vX.YY.ZZ. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
350 This variable is used to warn about non-supported options and to supply |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
351 version correct option values when using \\[antlr-insert-option]. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
352 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
353 Don't use a number smaller than 20600 since the stored history of |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
354 Antlr's options starts with v2.06.00, see `antlr-options-alists'. You |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
355 can make this variable buffer-local." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
356 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
357 :type 'integer) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
358 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
359 (defcustom antlr-options-auto-colon t |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
360 "*Non-nil, if `:' is inserted with a rule or subrule options section. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
361 A `:' is only inserted if this value is non-nil, if a rule or subrule |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
362 option is inserted with \\[antlr-insert-option], if there was no rule or |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
363 subrule options section before, and if a `:' is not already present |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
364 after the section, ignoring whitespace, comments and the init action." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
365 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
366 :type 'boolean) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
367 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
368 (defcustom antlr-options-style nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
369 "List of symbols which determine the style of option values. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
370 If a style symbol is present, the corresponding option value is put into |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
371 quotes, i.e., represented as a string, otherwise it is represented as an |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
372 identifier. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
373 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
374 The only style symbol used in the default value of `antlr-options-alist' |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
375 is `language-as-string'. See also `antlr-read-value'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
376 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
377 :type '(repeat (symbol :tag "Style symbol"))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
378 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
379 (defcustom antlr-options-push-mark t |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
380 "*Non-nil, if inserting an option should set & push mark. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
381 If nil, never set mark when inserting an option with command |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
382 \\[antlr-insert-option]. If t, always set mark via `push-mark'. If a |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
383 number, only set mark if point was outside the options area before and |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
384 the number of lines between point and the insert position is greater |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
385 than this value. Otherwise, only set mark if point was outside the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
386 options area before." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
387 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
388 :type '(radio (const :tag "No" nil) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
389 (const :tag "Always" t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
390 (integer :tag "Lines between" :value 10) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
391 (sexp :tag "If outside options" :format "%t" :value outside))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
392 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
393 (defcustom antlr-options-assign-string " = " |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
394 "*String containing `=' to use between option name and value. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
395 This string is only used if the option to insert did not exist before |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
396 or if there was no `=' after it. In other words, the spacing around an |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
397 existing `=' won't be changed when changing an option value." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
398 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
399 :type 'string) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
400 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
401 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
402 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
403 ;;; Options: definitions |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
404 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
405 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
406 (defvar antlr-options-headings '("file" "grammar" "rule" "subrule") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
407 "Headings for the four different option kinds. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
408 The standard value is (\"file\" \"grammar\" \"rule\" \"subrule\"). See |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
409 `antlr-options-alists'") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
410 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
411 (defvar antlr-options-alists |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
412 '(;; file options ---------------------------------------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
413 (("language" antlr-language-option-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
414 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
415 "Generated language: " language-as-string |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
416 (("Java") ("Cpp") ("HTML") ("Diagnostic"))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
417 (20700 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
418 "Generated language: " language-as-string |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
419 (("Java") ("Cpp") ("HTML") ("Diagnostic") ("Sather")))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
420 ("mangleLiteralPrefix" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
421 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
422 "Prefix for literals (default LITERAL_): " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
423 ("namespace" antlr-c++-mode-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
424 (20700 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
425 "Wrap generated C++ code in namespace: " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
426 ("namespaceStd" antlr-c++-mode-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
427 (20701 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
428 "Replace ANTLR_USE_NAMESPACE(std) by: " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
429 ("namespaceAntlr" antlr-c++-mode-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
430 (20701 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
431 "Replace ANTLR_USE_NAMESPACE(antlr) by: " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
432 ("genHashLines" antlr-c++-mode-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
433 (20701 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
434 "Include #line in generated C++ code? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
435 ) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
436 ;; grammar options -------------------------------------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
437 (("k" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
438 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
439 "Lookahead depth: ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
440 ("importVocab" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
441 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
442 "Import vocabulary: ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
443 ("exportVocab" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
444 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
445 "Export vocabulary: ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
446 ("testLiterals" nil ; lexer only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
447 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
448 "Test each token against literals table? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
449 ("defaultErrorHandler" nil ; not for lexer |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
450 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
451 "Generate default exception handler for each rule? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
452 ("codeGenMakeSwitchThreshold" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
453 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
454 "Min number of alternatives for 'switch': ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
455 ("codeGenBitsetTestThreshold" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
456 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
457 "Min size of lookahead set for bitset test: ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
458 ("analyzerDebug" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
459 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
460 "Display debugging info during grammar analysis? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
461 ("codeGenDebug" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
462 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
463 "Display debugging info during code generation? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
464 ("buildAST" nil ; not for lexer |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
465 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
466 "Use automatic AST construction/transformation? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
467 ("ASTLabelType" nil ; not for lexer |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
468 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
469 "Class of user-defined AST node: " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
470 ("charVocabulary" nil ; lexer only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
471 (20600 nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
472 "Insert character vocabulary")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
473 ("interactive" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
474 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
475 "Generate interactive lexer/parser? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
476 ("caseSensitive" nil ; lexer only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
477 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
478 "Case significant when matching characters? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
479 ("caseSensitiveLiterals" nil ; lexer only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
480 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
481 "Case significant when testing literals table? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
482 ("classHeaderSuffix" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
483 (20600 nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
484 "Additional string for grammar class definition")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
485 ("filter" nil ; lexer only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
486 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
487 "Skip rule (the name, true or false): " |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
488 antlr-grammar-tokens)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
489 ("namespace" antlr-c++-mode-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
490 (20700 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
491 "Wrap generated C++ code for grammar in namespace: " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
492 ("namespaceStd" antlr-c++-mode-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
493 (20701 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
494 "Replace ANTLR_USE_NAMESPACE(std) by: " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
495 ("namespaceAntlr" antlr-c++-mode-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
496 (20701 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
497 "Replace ANTLR_USE_NAMESPACE(antlr) by: " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
498 ("genHashLines" antlr-c++-mode-extra |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
499 (20701 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
500 "Include #line in generated C++ code? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
501 ;;; ("autoTokenDef" nil ; parser only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
502 ;;; (80000 antlr-read-boolean ; default: true |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
503 ;;; "Automatically define referenced token? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
504 ;;; ("keywordsMeltTo" nil ; parser only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
505 ;;; (80000 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
506 ;;; "Change non-matching keywords to token type: ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
507 ) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
508 ;; rule options ---------------------------------------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
509 (("testLiterals" nil ; lexer only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
510 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
511 "Test this token against literals table? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
512 ("defaultErrorHandler" nil ; not for lexer |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
513 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
514 "Generate default exception handler for this rule? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
515 ("ignore" nil ; lexer only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
516 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
517 "In this rule, ignore tokens of type: " nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
518 antlr-grammar-tokens)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
519 ("paraphrase" nil ; lexer only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
520 (20600 antlr-read-value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
521 "In messages, replace name of this token by: " t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
522 ) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
523 ;; subrule options ------------------------------------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
524 (("warnWhenFollowAmbig" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
525 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
526 "Display warnings for ambiguities with FOLLOW? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
527 ("generateAmbigWarnings" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
528 (20600 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
529 "Display warnings for ambiguities? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
530 ("greedy" nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
531 (20700 antlr-read-boolean |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
532 "Make this optional/loop subrule greedy? ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
533 )) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
534 "Definitions for Antlr's options of all four different kinds. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
535 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
536 The value looks like \(FILE GRAMMAR RULE SUBRULE) where each FILE, |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
537 GRAMMAR, RULE, and SUBRULE is a list of option definitions of the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
538 corresponding kind, i.e., looks like \(OPTION-DEF...). |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
539 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
540 Each OPTION-DEF looks like \(OPTION-NAME EXTRA-FN VALUE-SPEC...) which |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
541 defines a file/grammar/rule/subrule option with name OPTION-NAME. The |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
542 OPTION-NAMEs are used for the creation of the \"Insert XXX Option\" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
543 submenus, see `antlr-options-use-submenus', and to allow to insert the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
544 option name with completion when using \\[antlr-insert-option]. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
545 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
546 If EXTRA-FN is a function, it is called at different phases of the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
547 insertion with arguments \(PHASE OPTION-NAME). PHASE can have the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
548 values `before-input' or `after-insertion', additional phases might be |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
549 defined in future versions of this mode. The phase `before-input' |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
550 occurs before the user is asked to insert a value. The phase |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
551 `after-insertion' occurs after the option value has been inserted. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
552 EXTRA-FN might be called with additional arguments in future versions of |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
553 this mode. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
554 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
555 Each specification VALUE-SPEC looks like \(VERSION READ-FN ARG...). The |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
556 last VALUE-SPEC in an OPTION-DEF whose VERSION is smaller or equal to |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
557 `antlr-tool-version' specifies how the user is asked for the value of |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
558 the option. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
559 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
560 If READ-FN is nil, the only ARG is a string which is printed at the echo |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
561 area to guide the user what to insert at point. Otherwise, READ-FN is |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
562 called with arguments \(INIT-VALUE ARG...) to get the new value of the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
563 option. INIT-VALUE is the old value of the option or nil. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
564 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
565 The standard value contains the following functions as READ-FN: |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
566 `antlr-read-value' with ARGs = \(PROMPT AS-STRING TABLE) which reads a |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
567 general value, or `antlr-read-boolean' with ARGs = \(PROMPT TABLE) which |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
568 reads a boolean value or a member of TABLE. PROMPT is the prompt when |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
569 asking for a new value. If non-nil, TABLE is a table for completion or |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
570 a function evaluating to such a table. The return value is quoted iff |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
571 AS-STRING is non-nil and is either t or a symbol which is a member of |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
572 `antlr-options-style'.") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
573 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
574 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
575 ;;;=========================================================================== |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
576 ;;; Run tool, create Makefile dependencies |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
577 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
578 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
579 (defcustom antlr-tool-command "java antlr.Tool" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
580 "*Command used in \\[antlr-run-tool] to run the Antlr tool. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
581 This variable should include all options passed to Antlr except the |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
582 option \"-glib\" which is automatically suggested if necessary." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
583 :group 'antlr |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
584 :type 'string) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
585 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
586 (defcustom antlr-ask-about-save t |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
587 "*If not nil, \\[antlr-run-tool] asks which buffers to save. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
588 Otherwise, it saves all modified buffers before running without asking." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
589 :group 'antlr |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
590 :type 'boolean) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
591 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
592 (defcustom antlr-makefile-specification |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
593 '("\n" ("GENS" "GENS%d" " \\\n\t") "$(ANTLR)") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
594 "*Variable to specify the appearance of the generated makefile rules. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
595 This variable influences the output of \\[antlr-show-makefile-rules]. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
596 It looks like \(RULE-SEP GEN-VAR-SPEC COMMAND). |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
597 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
598 RULE-SEP is the string to separate different makefile rules. COMMAND is |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
599 a string with the command which runs the Antlr tool, it should include |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
600 all options except the option \"-glib\" which is automatically added |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
601 if necessary. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
602 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
603 If GEN-VAR-SPEC is nil, each target directly consists of a list of |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
604 files. If GEN-VAR-SPEC looks like \(GEN-VAR GEN-VAR-FORMAT GEN-SEP), a |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
605 Makefile variable is created for each rule target. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
606 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
607 Then, GEN-VAR is a string with the name of the variable which contains |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
608 the file names of all makefile rules. GEN-VAR-FORMAT is a format string |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
609 producing the variable of each target with substitution COUNT/%d where |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
610 COUNT starts with 1. GEN-SEP is used to separate long variable values." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
611 :group 'antlr |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
612 :type '(list (string :tag "Rule separator") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
613 (choice |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
614 (const :tag "Direct targets" nil) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
615 (list :tag "Variables for targets" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
616 (string :tag "Variable for all targets") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
617 (string :tag "Format for each target variable") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
618 (string :tag "Variable separator"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
619 (string :tag "ANTLR command"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
620 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
621 (defvar antlr-file-formats-alist |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
622 '((java-mode ("%sTokenTypes.java") ("%s.java")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
623 (c++-mode ("%sTokenTypes.hpp") ("%s.cpp" "%s.hpp"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
624 "Language dependent formats which specify generated files. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
625 Each element in this list looks looks like |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
626 \(MAJOR-MODE (VOCAB-FILE-FORMAT...) (CLASS-FILE-FORMAT...)). |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
627 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
628 The element whose MAJOR-MODE is equal to `antlr-language' is used to |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
629 specify the generated files which are language dependent. See variable |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
630 `antlr-special-file-formats' for language independent files. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
631 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
632 VOCAB-FILE-FORMAT is a format string, it specifies with substitution |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
633 VOCAB/%s the generated file for each export vocabulary VOCAB. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
634 CLASS-FILE-FORMAT is a format string, it specifies with substitution |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
635 CLASS/%s the generated file for each grammar class CLASS.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
636 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
637 (defvar antlr-special-file-formats '("%sTokenTypes.txt" "expanded%s.g") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
638 "Language independent formats which specify generated files. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
639 The value looks like \(VOCAB-FILE-FORMAT EXPANDED-GRAMMAR-FORMAT). |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
640 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
641 VOCAB-FILE-FORMAT is a format string, it specifies with substitution |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
642 VOCAB/%s the generated or input file for each export or import |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
643 vocabulary VOCAB, respectively. EXPANDED-GRAMMAR-FORMAT is a format |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
644 string, it specifies with substitution GRAMMAR/%s the constructed |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
645 grammar file if the file GRAMMAR.g contains a grammar class which |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
646 extends a class other than \"Lexer\", \"Parser\" or \"TreeParser\". |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
647 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
648 See variable `antlr-file-formats-alist' for language dependent |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
649 formats.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
650 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
651 (defvar antlr-unknown-file-formats '("?%s?.g" "?%s?") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
652 "*Formats which specify the names of unknown files. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
653 The value looks like \(SUPER-GRAMMAR-FILE-FORMAT SUPER-EVOCAB-FORMAT). |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
654 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
655 SUPER-GRAMMAR-FORMAT is a format string, it specifies with substitution |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
656 SUPER/%s the name of a grammar file for Antlr's option \"-glib\" if no |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
657 grammar file in the current directory defines the class SUPER or if it |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
658 is defined more than once. SUPER-EVOCAB-FORMAT is a format string, it |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
659 specifies with substitution SUPER/%s the name for the export vocabulary |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
660 of above mentioned class SUPER.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
661 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
662 (defvar antlr-help-unknown-file-text |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
663 "## The following rules contain filenames of the form |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
664 ## \"?SUPERCLASS?.g\" (and \"?SUPERCLASS?TokenTypes.txt\") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
665 ## where SUPERCLASS is not found to be defined in any grammar file of |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
666 ## the current directory or is defined more than once. Please replace |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
667 ## these filenames by the grammar files (and their exportVocab).\n\n" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
668 "String indicating the existence of unknown files in the Makefile. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
669 See \\[antlr-show-makefile-rules] and `antlr-unknown-file-formats'.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
670 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
671 (defvar antlr-help-rules-intro |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
672 "The following Makefile rules define the dependencies for all (non- |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
673 expanded) grammars in directory \"%s\".\n |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
674 They are stored in the kill-ring, i.e., you can insert them with C-y |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
675 into your Makefile. You can also invoke M-x antlr-show-makefile-rules |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
676 from within a Makefile to insert them directly.\n\n\n" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
677 "Introduction to use with \\[antlr-show-makefile-rules]. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
678 It is a format string and used with substitution DIRECTORY/%s where |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
679 DIRECTORY is the name of the current directory.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
680 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
681 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
682 ;;;=========================================================================== |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
683 ;;; Menu |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
684 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
685 |
49554 | 686 (defcustom antlr-imenu-name t ; (featurep 'xemacs) ; TODO: Emacs-21 bug? |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
687 "*Non-nil, if a \"Index\" menu should be added to the menubar. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
688 If it is a string, it is used instead \"Index\". Requires package |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
689 imenu." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
690 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
691 :type '(choice (const :tag "No menu" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
692 (const :tag "Index menu" t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
693 (string :tag "Other menu name"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
694 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
695 (defvar antlr-mode-map |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
696 (let ((map (make-sparse-keymap))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
697 (define-key map "\t" 'antlr-indent-command) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
698 (define-key map "\e\C-a" 'antlr-beginning-of-rule) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
699 (define-key map "\e\C-e" 'antlr-end-of-rule) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
700 (define-key map "\C-c\C-a" 'antlr-beginning-of-body) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
701 (define-key map "\C-c\C-e" 'antlr-end-of-body) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
702 (define-key map "\C-c\C-f" 'c-forward-into-nomenclature) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
703 (define-key map "\C-c\C-b" 'c-backward-into-nomenclature) |
26965 | 704 (define-key map "\C-c\C-c" 'comment-region) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
705 (define-key map "\C-c\C-v" 'antlr-hide-actions) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
706 (define-key map "\C-c\C-r" 'antlr-run-tool) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
707 (define-key map "\C-c\C-o" 'antlr-insert-option) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
708 ;; I'm too lazy to define my own: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
709 (define-key map "\ea" 'c-beginning-of-statement) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
710 (define-key map "\ee" 'c-end-of-statement) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
711 ;; electric keys: |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
712 (define-key map ":" 'antlr-electric-character) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
713 (define-key map ";" 'antlr-electric-character) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
714 (define-key map "|" 'antlr-electric-character) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
715 (define-key map "&" 'antlr-electric-character) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
716 (define-key map "(" 'antlr-electric-character) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
717 (define-key map ")" 'antlr-electric-character) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
718 (define-key map "{" 'antlr-electric-character) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
719 (define-key map "}" 'antlr-electric-character) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
720 map) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
721 "Keymap used in `antlr-mode' buffers.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
722 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
723 (easy-menu-define antlr-mode-menu antlr-mode-map |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
724 "Major mode menu." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
725 `("Antlr" |
49554 | 726 ,@(if (cond-emacs-xemacs |
727 :EMACS (and antlr-options-use-submenus | |
728 (>= emacs-major-version 21)) | |
729 :XEMACS antlr-options-use-submenus) | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
730 `(("Insert File Option" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
731 :filter ,(lambda (x) (antlr-options-menu-filter 1 x))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
732 ("Insert Grammar Option" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
733 :filter ,(lambda (x) (antlr-options-menu-filter 2 x))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
734 ("Insert Rule Option" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
735 :filter ,(lambda (x) (antlr-options-menu-filter 3 x))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
736 ("Insert Subrule Option" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
737 :filter ,(lambda (x) (antlr-options-menu-filter 4 x))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
738 "---") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
739 '(["Insert Option" antlr-insert-option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
740 :active (not buffer-read-only)])) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
741 ("Forward/Backward" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
742 ["Backward Rule" antlr-beginning-of-rule t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
743 ["Forward Rule" antlr-end-of-rule t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
744 ["Start of Rule Body" antlr-beginning-of-body |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
745 :active (antlr-inside-rule-p)] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
746 ["End of Rule Body" antlr-end-of-body |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
747 :active (antlr-inside-rule-p)] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
748 "---" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
749 ["Backward Statement" c-beginning-of-statement t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
750 ["Forward Statement" c-end-of-statement t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
751 ["Backward Into Nomencl." c-backward-into-nomenclature t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
752 ["Forward Into Nomencl." c-forward-into-nomenclature t]) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
753 ["Indent Region" indent-region |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
754 :active (and (not buffer-read-only) (c-region-is-active-p))] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
755 ["Comment Out Region" comment-region |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
756 :active (and (not buffer-read-only) (c-region-is-active-p))] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
757 ["Uncomment Region" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
758 (comment-region (region-beginning) (region-end) '(4)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
759 :active (and (not buffer-read-only) (c-region-is-active-p))] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
760 "---" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
761 ["Hide Actions (incl. Args)" antlr-hide-actions t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
762 ["Hide Actions (excl. Args)" (antlr-hide-actions 2) t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
763 ["Unhide All Actions" (antlr-hide-actions 0) t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
764 "---" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
765 ["Run Tool on Grammar" antlr-run-tool t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
766 ["Show Makefile Rules" antlr-show-makefile-rules t] |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
767 "---" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
768 ["Customize Antlr" (customize-group 'antlr) t])) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
769 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
770 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
771 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
772 ;;; font-lock |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
773 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
774 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
775 (defcustom antlr-font-lock-maximum-decoration 'inherit |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
776 "*The maximum decoration level for fontifying actions. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
777 Value `none' means, do not fontify actions, just normal grammar code |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
778 according to `antlr-font-lock-additional-keywords'. Value `inherit' |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
779 means, use value of `font-lock-maximum-decoration'. Any other value is |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
780 interpreted as in `font-lock-maximum-decoration' with no level-0 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
781 fontification, see `antlr-font-lock-keywords-alist'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
782 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
783 While calculating the decoration level for actions, `major-mode' is |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
784 bound to `antlr-language'. For example, with value |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
785 \((java-mode \. 2) (c++-mode \. 0)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
786 Java actions are fontified with level 2 and C++ actions are not |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
787 fontified at all." |
62531
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
59238
diff
changeset
|
788 :group 'antlr |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
789 :type '(choice (const :tag "None" none) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
790 (const :tag "Inherit" inherit) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
791 (const :tag "Default" nil) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
792 (const :tag "Maximum" t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
793 (integer :tag "Level" 1) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
794 (repeat :menu-tag "Mode specific" :tag "Mode specific" |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
795 :value ((t . t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
796 (cons :tag "Instance" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
797 (radio :tag "Mode" |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
798 (const :tag "All" t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
799 (symbol :tag "Name")) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
800 (radio :tag "Decoration" |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
801 (const :tag "Default" nil) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
802 (const :tag "Maximum" t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
803 (integer :tag "Level" 1)))))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
804 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
805 (defconst antlr-no-action-keywords nil |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
806 ;; Using nil directly won't work (would use highest level, see |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
807 ;; `font-lock-choose-keywords'), but a non-symbol, i.e., (list), at `car' |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
808 ;; would break Emacs-21.0: |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
809 "Empty font-lock keywords for actions. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
810 Do not change the value of this constant.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
811 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
812 (defvar antlr-font-lock-keywords-alist |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
813 '((java-mode |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
814 antlr-no-action-keywords |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
815 java-font-lock-keywords-1 java-font-lock-keywords-2 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
816 java-font-lock-keywords-3) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
817 (c++-mode |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
818 antlr-no-action-keywords |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
819 c++-font-lock-keywords-1 c++-font-lock-keywords-2 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
820 c++-font-lock-keywords-3)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
821 "List of font-lock keywords for actions in the grammar. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
822 Each element in this list looks like |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
823 \(MAJOR-MODE KEYWORD...) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
824 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
825 If `antlr-language' is equal to MAJOR-MODE, the KEYWORDs are the |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
826 font-lock keywords according to `font-lock-defaults' used for the code |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
827 in the grammar's actions and semantic predicates, see |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
828 `antlr-font-lock-maximum-decoration'.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
829 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
830 (defvar antlr-default-face 'antlr-default) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
831 (defface antlr-default |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
832 "Face to prevent strings from language dependent highlighting. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
833 Do not change." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
834 :group 'antlr) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
835 ;; backward-compatibility alias |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
836 (put 'antlr-font-lock-default-face 'face-alias 'antlr-default) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
837 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
838 (defvar antlr-keyword-face 'antlr-keyword) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
839 (defface antlr-keyword |
49554 | 840 (cond-emacs-xemacs |
841 '((((class color) (background light)) | |
842 (:foreground "black" :EMACS :weight bold :XEMACS :bold t)))) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
843 "ANTLR keywords." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
844 :group 'antlr) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
845 ;; backward-compatibility alias |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
846 (put 'antlr-font-lock-keyword-face 'face-alias 'antlr-keyword) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
847 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
848 (defvar antlr-syntax-face 'antlr-keyword) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
849 (defface antlr-syntax |
49554 | 850 (cond-emacs-xemacs |
851 '((((class color) (background light)) | |
852 (:foreground "black" :EMACS :weight bold :XEMACS :bold t)))) | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
853 "ANTLR syntax symbols like :, |, (, ), ...." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
854 :group 'antlr) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
855 ;; backward-compatibility alias |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
856 (put 'antlr-font-lock-syntax-face 'face-alias 'antlr-syntax) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
857 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
858 (defvar antlr-ruledef-face 'antlr-ruledef) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
859 (defface antlr-ruledef |
49554 | 860 (cond-emacs-xemacs |
861 '((((class color) (background light)) | |
862 (:foreground "blue" :EMACS :weight bold :XEMACS :bold t)))) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
863 "ANTLR rule references (definition)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
864 :group 'antlr) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
865 ;; backward-compatibility alias |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
866 (put 'antlr-font-lock-ruledef-face 'face-alias 'antlr-ruledef) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
867 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
868 (defvar antlr-tokendef-face 'antlr-tokendef) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
869 (defface antlr-tokendef |
49554 | 870 (cond-emacs-xemacs |
871 '((((class color) (background light)) | |
872 (:foreground "blue" :EMACS :weight bold :XEMACS :bold t)))) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
873 "ANTLR token references (definition)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
874 :group 'antlr) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
875 ;; backward-compatibility alias |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
876 (put 'antlr-font-lock-tokendef-face 'face-alias 'antlr-tokendef) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
877 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
878 (defvar antlr-ruleref-face 'antlr-ruleref) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
879 (defface antlr-ruleref |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
880 '((((class color) (background light)) (:foreground "blue4"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
881 "ANTLR rule references (usage)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
882 :group 'antlr) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
883 ;; backward-compatibility alias |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
884 (put 'antlr-font-lock-ruleref-face 'face-alias 'antlr-ruleref) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
885 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
886 (defvar antlr-tokenref-face 'antlr-tokenref) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
887 (defface antlr-tokenref |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
888 '((((class color) (background light)) (:foreground "orange4"))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
889 "ANTLR token references (usage)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
890 :group 'antlr) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
891 ;; backward-compatibility alias |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
892 (put 'antlr-font-lock-tokenref-face 'face-alias 'antlr-tokenref) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
893 |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
894 (defvar antlr-literal-face 'antlr-literal) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
895 (defface antlr-literal |
49554 | 896 (cond-emacs-xemacs |
897 '((((class color) (background light)) | |
898 (:foreground "brown4" :EMACS :weight bold :XEMACS :bold t)))) | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
899 "ANTLR special literal tokens. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
900 It is used to highlight strings matched by the first regexp group of |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
901 `antlr-font-lock-literal-regexp'." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
902 :group 'antlr) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
903 ;; backward-compatibility alias |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
904 (put 'antlr-font-lock-literal-face 'face-alias 'antlr-literal) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
905 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
906 (defcustom antlr-font-lock-literal-regexp "\"\\(\\sw\\(\\sw\\|-\\)*\\)\"" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
907 "Regexp matching literals with special syntax highlighting, or nil. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
908 If nil, there is no special syntax highlighting for some literals. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
909 Otherwise, it should be a regular expression which must contain a regexp |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
910 group. The string matched by the first group is highlighted with |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
911 `antlr-font-lock-literal-face'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
912 :group 'antlr |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
913 :type '(choice (const :tag "None" nil) regexp)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
914 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
915 (defvar antlr-class-header-regexp |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
916 "\\(class\\)[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]+\\(extends\\)[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]*;" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
917 "Regexp matching class headers.") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
918 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
919 (defvar antlr-font-lock-additional-keywords |
49554 | 920 (cond-emacs-xemacs |
921 `((antlr-invalidate-context-cache) | |
922 ("\\$setType[ \t]*(\\([A-Za-z\300-\326\330-\337]\\sw*\\))" | |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
923 (1 antlr-tokendef-face)) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
924 ("\\$\\sw+" (0 keyword-face)) |
49554 | 925 ;; the tokens are already fontified as string/docstrings: |
926 (,(lambda (limit) | |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
927 (if antlr-literal-regexp |
49554 | 928 (antlr-re-search-forward antlr-font-lock-literal-regexp limit))) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
929 (1 antlr-literal-face t) |
49554 | 930 :XEMACS (0 nil)) ; XEmacs bug workaround |
931 (,(lambda (limit) | |
932 (antlr-re-search-forward antlr-class-header-regexp limit)) | |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
933 (1 antlr-keyword-face) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
934 (2 antlr-ruledef-face) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
935 (3 antlr-keyword-face) |
49554 | 936 (4 (if (member (match-string 4) '("Lexer" "Parser" "TreeParser")) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
937 antlr-keyword-face |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
938 type-face))) |
49554 | 939 (,(lambda (limit) |
940 (antlr-re-search-forward | |
941 "\\<\\(header\\|options\\|tokens\\|exception\\|catch\\|returns\\)\\>" | |
942 limit)) | |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
943 (1 antlr-keyword-face)) |
49554 | 944 (,(lambda (limit) |
945 (antlr-re-search-forward | |
946 "^\\(private\\|public\\|protected\\)\\>[ \t]*\\(\\(\\sw+[ \t]*\\(:\\)?\\)\\)?" | |
947 limit)) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
948 (1 font-lock-type-face) ; not XEmacs' java level-3 fruit salad |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
949 (3 (if (antlr-upcase-p (char-after (match-beginning 3))) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
950 antlr-tokendef-face |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
951 antlr-ruledef-face) nil t) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
952 (4 antlr-syntax-face nil t)) |
49554 | 953 (,(lambda (limit) |
954 (antlr-re-search-forward "^\\(\\sw+\\)[ \t]*\\(:\\)?" limit)) | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
955 (1 (if (antlr-upcase-p (char-after (match-beginning 0))) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
956 antlr-tokendef-face |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
957 antlr-ruledef-face) nil t) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
958 (2 antlr-syntax-face nil t)) |
49554 | 959 (,(lambda (limit) |
960 ;; v:ruleref and v:"literal" is allowed... | |
961 (antlr-re-search-forward "\\(\\sw+\\)[ \t]*\\([=:]\\)?" limit)) | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
962 (1 (if (match-beginning 2) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
963 (if (eq (char-after (match-beginning 2)) ?=) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
964 antlr-default-face |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
965 font-lock-variable-name-face) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
966 (if (antlr-upcase-p (char-after (match-beginning 1))) |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
967 antlr-tokenref-face |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
968 antlr-ruleref-face))) |
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
969 (2 antlr-default-face nil t)) |
49554 | 970 (,(lambda (limit) |
971 (antlr-re-search-forward "[|&:;(~]\\|)\\([*+?]\\|=>\\)?" limit)) | |
63447
7976e5fa0225
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409
Miles Bader <miles@gnu.org>
parents:
62772
diff
changeset
|
972 (0 antlr-syntax-face)))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
973 "Font-lock keywords for ANTLR's normal grammar code. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
974 See `antlr-font-lock-keywords-alist' for the keywords of actions.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
975 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
976 (defvar antlr-font-lock-defaults |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
977 '(antlr-font-lock-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
978 nil nil ((?_ . "w") (?\( . ".") (?\) . ".")) beginning-of-defun) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
979 "Font-lock defaults used for ANTLR syntax highlighting. |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
980 The SYNTAX-ALIST element is also used to initialize |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
981 `antlr-action-syntax-table'.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
982 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
983 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
984 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
985 ;;; Internal variables |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
986 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
987 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
988 (defvar antlr-mode-hook nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
989 "Hook called by `antlr-mode'.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
990 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
991 (defvar antlr-mode-syntax-table nil |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
992 "Syntax table used in `antlr-mode' buffers. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
993 If non-nil, it will be initialized in `antlr-mode'.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
994 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
995 ;; used for "in Java/C++ code" = syntactic-depth>0 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
996 (defvar antlr-action-syntax-table nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
997 "Syntax table used for ANTLR action parsing. |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
998 Initialized by `antlr-mode-syntax-table', changed by SYNTAX-ALIST in |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
999 `antlr-font-lock-defaults'. This table should be selected if you use |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1000 `buffer-syntactic-context' and `buffer-syntactic-context-depth' in order |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1001 not to confuse their context_cache.") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1002 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1003 (defvar antlr-mode-abbrev-table nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1004 "Abbreviation table used in `antlr-mode' buffers.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1005 (define-abbrev-table 'antlr-mode-abbrev-table ()) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1006 |
49554 | 1007 (defvar antlr-slow-cache-enabling-symbol 'loudly |
1008 ;; Emacs' font-lock changes buffer's tick counter, therefore this value should | |
1009 ;; be a parameter of a font-lock function, but not any other variable of | |
1010 ;; functions which call `antlr-slow-syntactic-context'. | |
1011 "If value is a bound symbol, cache will be used even with text changes. | |
1012 This is no user option. Used for `antlr-slow-syntactic-context'.") | |
1013 | |
1014 (defvar antlr-slow-cache-diff-threshold 5000 | |
1015 "Maximum distance between `point' and cache position for cache use. | |
1016 Used for `antlr-slow-syntactic-context'.") | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1017 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1018 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1019 ;;;;########################################################################## |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1020 ;;;; The Code |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1021 ;;;;########################################################################## |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1022 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1023 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1024 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1025 ;;;=========================================================================== |
49554 | 1026 ;;; Syntax functions -- Emacs vs XEmacs dependent, part 1 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1027 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1028 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1029 ;; From help.el (XEmacs-21.1), without `copy-syntax-table' |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1030 (defmacro antlr-with-syntax-table (syntab &rest body) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1031 "Evaluate BODY with the syntax table SYNTAB." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1032 `(let ((stab (syntax-table))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1033 (unwind-protect |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1034 (progn (set-syntax-table ,syntab) ,@body) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1035 (set-syntax-table stab)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1036 (put 'antlr-with-syntax-table 'lisp-indent-function 1) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1037 (put 'antlr-with-syntax-table 'edebug-form-spec '(form body)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1038 |
49554 | 1039 (defunx antlr-default-directory () |
1040 :xemacs-and-try default-directory | |
1041 "Return `default-directory'." | |
1042 default-directory) | |
1043 | |
1044 ;; Check Emacs-21.1 simple.el, `shell-command'. | |
1045 (defunx antlr-read-shell-command (prompt &optional initial-input history) | |
1046 :xemacs-and-try read-shell-command | |
1047 "Read a string from the minibuffer, using `shell-command-history'." | |
1048 (read-from-minibuffer prompt initial-input nil nil | |
1049 (or history 'shell-command-history))) | |
1050 | |
1051 (defunx antlr-with-displaying-help-buffer (thunk &optional name) | |
1052 :xemacs-and-try with-displaying-help-buffer | |
1053 "Make a help buffer and call `thunk' there." | |
1054 (with-output-to-temp-buffer "*Help*" | |
1055 (save-excursion (funcall thunk)))) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1056 |
49554 | 1057 |
1058 ;;;=========================================================================== | |
1059 ;;; Context cache | |
1060 ;;;=========================================================================== | |
1061 | |
1062 (defvar antlr-slow-context-cache nil "Internal.") | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1063 |
49554 | 1064 ;;;(defvar antlr-statistics-full-neg 0) |
1065 ;;;(defvar antlr-statistics-full-diff 0) | |
1066 ;;;(defvar antlr-statistics-full-other 0) | |
1067 ;;;(defvar antlr-statistics-cache 0) | |
1068 ;;;(defvar antlr-statistics-inval 0) | |
1069 | |
1070 (defunx antlr-invalidate-context-cache (&rest dummies) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1071 ;; checkdoc-params: (dummies) |
49554 | 1072 "Invalidate context cache for syntactical context information." |
1073 :XEMACS ; XEmacs bug workaround | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1074 (save-excursion |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1075 (set-buffer (get-buffer-create " ANTLR XEmacs bug workaround")) |
49554 | 1076 (buffer-syntactic-context-depth) |
1077 nil) | |
1078 :EMACS | |
1079 ;;; (incf antlr-statistics-inval) | |
1080 (setq antlr-slow-context-cache nil)) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1081 |
49554 | 1082 (defunx antlr-syntactic-context () |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1083 "Return some syntactic context information. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1084 Return `string' if point is within a string, `block-comment' or |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1085 `comment' is point is within a comment or the depth within all |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1086 parenthesis-syntax delimiters at point otherwise. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1087 WARNING: this may alter `match-data'." |
49554 | 1088 :XEMACS |
1089 (or (buffer-syntactic-context) (buffer-syntactic-context-depth)) | |
1090 :EMACS | |
1091 (let ((orig (point)) diff state | |
1092 ;; Arg, Emacs' (buffer-modified-tick) changes with font-lock. Use | |
1093 ;; hack that `loudly' is bound during font-locking => cache use will | |
1094 ;; increase from 7% to 99.99% during font-locking. | |
1095 (tick (or (boundp antlr-slow-cache-enabling-symbol) | |
1096 (buffer-modified-tick)))) | |
1097 (if (and (cdr antlr-slow-context-cache) | |
1098 (>= (setq diff (- orig (cadr antlr-slow-context-cache))) 0) | |
1099 (< diff antlr-slow-cache-diff-threshold) | |
1100 (eq (current-buffer) (caar antlr-slow-context-cache)) | |
1101 (eq tick (cdar antlr-slow-context-cache))) | |
1102 ;; (setq antlr-statistics-cache (1+ antlr-statistics-cache) ...) | |
1103 (setq state (parse-partial-sexp (cadr antlr-slow-context-cache) orig | |
1104 nil nil | |
1105 (cddr antlr-slow-context-cache))) | |
1106 (if (>= orig antlr-slow-cache-diff-threshold) | |
1107 (beginning-of-defun) | |
1108 (goto-char (point-min))) | |
1109 ;;; (cond ((and diff (< diff 0)) (incf antlr-statistics-full-neg)) | |
1110 ;;; ((and diff (>= diff 3000)) (incf antlr-statistics-full-diff)) | |
1111 ;;; (t (incf antlr-statistics-full-other))) | |
1112 (setq state (parse-partial-sexp (point) orig))) | |
1113 (goto-char orig) | |
1114 (if antlr-slow-context-cache | |
1115 (setcdr antlr-slow-context-cache (cons orig state)) | |
1116 (setq antlr-slow-context-cache | |
1117 (cons (cons (current-buffer) tick) | |
1118 (cons orig state)))) | |
1119 (cond ((nth 3 state) 'string) | |
1120 ((nth 4 state) 'comment) ; block-comment? -- we don't care | |
1121 (t (car state))))) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1122 |
49554 | 1123 ;;; (incf (aref antlr-statistics 2)) |
1124 ;;; (unless (and (eq (current-buffer) | |
1125 ;;; (caar antlr-slow-context-cache)) | |
1126 ;;; (eq (buffer-modified-tick) | |
1127 ;;; (cdar antlr-slow-context-cache))) | |
1128 ;;; (incf (aref antlr-statistics 1)) | |
1129 ;;; (setq antlr-slow-context-cache nil)) | |
1130 ;;; (let* ((orig (point)) | |
1131 ;;; (base (cadr antlr-slow-context-cache)) | |
1132 ;;; (curr (cddr antlr-slow-context-cache)) | |
1133 ;;; (state (cond ((eq orig (car curr)) (cdr curr)) | |
1134 ;;; ((eq orig (car base)) (cdr base)))) | |
1135 ;;; diff diff2) | |
1136 ;;; (unless state | |
1137 ;;; (incf (aref antlr-statistics 3)) | |
1138 ;;; (when curr | |
1139 ;;; (if (< (setq diff (abs (- orig (car curr)))) | |
1140 ;;; (setq diff2 (abs (- orig (car base))))) | |
1141 ;;; (setq state curr) | |
1142 ;;; (setq state base | |
1143 ;;; diff diff2)) | |
1144 ;;; (if (or (>= (1+ diff) (point)) (>= diff 3000)) | |
1145 ;;; (setq state nil))) ; start from bod/bob | |
1146 ;;; (if state | |
1147 ;;; (setq state | |
1148 ;;; (parse-partial-sexp (car state) orig nil nil (cdr state))) | |
1149 ;;; (if (>= orig 3000) (beginning-of-defun) (goto-char (point-min))) | |
1150 ;;; (incf (aref antlr-statistics 4)) | |
1151 ;;; (setq cw (list orig (point) base curr)) | |
1152 ;;; (setq state (parse-partial-sexp (point) orig))) | |
1153 ;;; (goto-char orig) | |
1154 ;;; (if antlr-slow-context-cache | |
1155 ;;; (setcdr (cdr antlr-slow-context-cache) (cons orig state)) | |
1156 ;;; (setq antlr-slow-context-cache | |
1157 ;;; (cons (cons (current-buffer) (buffer-modified-tick)) | |
1158 ;;; (cons (cons orig state) (cons orig state)))))) | |
1159 ;;; (cond ((nth 3 state) 'string) | |
1160 ;;; ((nth 4 state) 'comment) ; block-comment? -- we don't care | |
1161 ;;; (t (car state))))) | |
1162 | |
1163 ;;; (beginning-of-defun) | |
1164 ;;; (let ((state (parse-partial-sexp (point) orig))) | |
1165 ;;; (goto-char orig) | |
1166 ;;; (cond ((nth 3 state) 'string) | |
1167 ;;; ((nth 4 state) 'comment) ; block-comment? -- we don't care | |
1168 ;;; (t (car state)))))) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1169 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1170 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1171 ;;;=========================================================================== |
49554 | 1172 ;;; Miscellaneous functions |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1173 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1174 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1175 (defun antlr-upcase-p (char) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1176 "Non-nil, if CHAR is an uppercase character (if CHAR was a char)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1177 ;; in XEmacs, upcase only works for ASCII |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1178 (or (and (<= ?A char) (<= char ?Z)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1179 (and (<= ?\300 char) (<= char ?\337)))) ; ?\327 is no letter |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1180 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1181 (defun antlr-re-search-forward (regexp bound) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1182 "Search forward from point for regular expression REGEXP. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1183 Set point to the end of the occurrence found, and return point. Return |
26965 | 1184 nil if no occurrence was found. Do not search within comments, strings |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1185 and actions/semantic predicates. BOUND bounds the search; it is a |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1186 buffer position. See also the functions `match-beginning', `match-end' |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1187 and `replace-match'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1188 ;; WARNING: Should only be used with `antlr-action-syntax-table'! |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1189 (let ((continue t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1190 (while (and (re-search-forward regexp bound 'limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1191 (save-match-data |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1192 (if (eq (antlr-syntactic-context) 0) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1193 (setq continue nil) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1194 t)))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1195 (if continue nil (point)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1196 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1197 (defun antlr-search-forward (string) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1198 "Search forward from point for STRING. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1199 Set point to the end of the occurrence found, and return point. Return |
26965 | 1200 nil if no occurrence was found. Do not search within comments, strings |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1201 and actions/semantic predicates." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1202 ;; WARNING: Should only be used with `antlr-action-syntax-table'! |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1203 (let ((continue t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1204 (while (and (search-forward string nil 'limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1205 (if (eq (antlr-syntactic-context) 0) (setq continue nil) t))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1206 (if continue nil (point)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1207 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1208 (defun antlr-search-backward (string) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1209 "Search backward from point for STRING. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1210 Set point to the beginning of the occurrence found, and return point. |
26965 | 1211 Return nil if no occurrence was found. Do not search within comments, |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1212 strings and actions/semantic predicates." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1213 ;; WARNING: Should only be used with `antlr-action-syntax-table'! |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1214 (let ((continue t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1215 (while (and (search-backward string nil 'limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1216 (if (eq (antlr-syntactic-context) 0) (setq continue nil) t))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1217 (if continue nil (point)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1218 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1219 (defsubst antlr-skip-sexps (count) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1220 "Skip the next COUNT balanced expressions and the comments after it. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1221 Return position before the comments after the last expression." |
49554 | 1222 (goto-char (or (ignore-errors-x (scan-sexps (point) count)) (point-max))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1223 (prog1 (point) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1224 (antlr-c-forward-sws))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1225 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1226 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1227 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1228 ;;; font-lock |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1229 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1230 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1231 (defun antlr-font-lock-keywords () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1232 "Return font-lock keywords for current buffer. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1233 See `antlr-font-lock-additional-keywords', `antlr-language' and |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1234 `antlr-font-lock-maximum-decoration'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1235 (if (eq antlr-font-lock-maximum-decoration 'none) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1236 antlr-font-lock-additional-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1237 (append antlr-font-lock-additional-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1238 (eval (let ((major-mode antlr-language)) ; dynamic |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1239 (font-lock-choose-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1240 (cdr (assq antlr-language |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1241 antlr-font-lock-keywords-alist)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1242 (if (eq antlr-font-lock-maximum-decoration 'inherit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1243 font-lock-maximum-decoration |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1244 antlr-font-lock-maximum-decoration))))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1245 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1246 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1247 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1248 ;;; imenu support |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1249 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1250 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1251 (defun antlr-grammar-tokens () |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1252 "Return alist for tokens defined in current buffer." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1253 (save-excursion (antlr-imenu-create-index-function t))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1254 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1255 (defun antlr-imenu-create-index-function (&optional tokenrefs-only) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1256 "Return imenu index-alist for ANTLR grammar files. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1257 IF TOKENREFS-ONLY is non-nil, just return alist with tokenref names." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1258 (let ((items nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1259 (classes nil) |
49554 | 1260 (continue t)) |
1261 ;; Using `imenu-progress-message' would require imenu for compilation, but | |
1262 ;; nobody is missing these messages. The generic imenu function searches | |
1263 ;; backward, which is slower and more likely not to work during editing. | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1264 (antlr-with-syntax-table antlr-action-syntax-table |
49554 | 1265 (antlr-invalidate-context-cache) |
1266 (goto-char (point-min)) | |
1267 (antlr-skip-file-prelude t) | |
1268 (while continue | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1269 (if (looking-at "{") (antlr-skip-sexps 1)) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1270 (if (looking-at antlr-class-header-regexp) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1271 (or tokenrefs-only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1272 (push (cons (match-string 2) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1273 (if imenu-use-markers |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1274 (copy-marker (match-beginning 2)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1275 (match-beginning 2))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1276 classes)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1277 (if (looking-at "p\\(ublic\\|rotected\\|rivate\\)") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1278 (antlr-skip-sexps 1)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1279 (when (looking-at "\\sw+") |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1280 (if tokenrefs-only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1281 (if (antlr-upcase-p (char-after (point))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1282 (push (list (match-string 0)) items)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1283 (push (cons (match-string 0) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1284 (if imenu-use-markers |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1285 (copy-marker (match-beginning 0)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1286 (match-beginning 0))) |
49554 | 1287 items)))) |
1288 (if (setq continue (antlr-search-forward ";")) | |
1289 (antlr-skip-exception-part t)))) | |
1290 (if classes | |
1291 (cons (cons "Classes" (nreverse classes)) (nreverse items)) | |
1292 (nreverse items)))) | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1293 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1294 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1295 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1296 ;;; Parse grammar files (internal functions) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1297 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1298 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1299 (defun antlr-skip-exception-part (skip-comment) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1300 "Skip exception part of current rule, i.e., everything after `;'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1301 This also includes the options and tokens part of a grammar class |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1302 header. If SKIP-COMMENT is non-nil, also skip the comment after that |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1303 part." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1304 (let ((pos (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1305 (class nil)) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1306 (antlr-c-forward-sws) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1307 (while (looking-at "options\\>\\|tokens\\>") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1308 (setq class t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1309 (setq pos (antlr-skip-sexps 2))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1310 (if class |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1311 ;; Problem: an action only belongs to a class def, not a normal rule. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1312 ;; But checking the current rule type is too expensive => only expect |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1313 ;; an action if we have found an option or tokens part. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1314 (if (looking-at "{") (setq pos (antlr-skip-sexps 1))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1315 (while (looking-at "exception\\>") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1316 (setq pos (antlr-skip-sexps 1)) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1317 (when (looking-at "\\[") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1318 (setq pos (antlr-skip-sexps 1))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1319 (while (looking-at "catch\\>") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1320 (setq pos (antlr-skip-sexps 3))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1321 (or skip-comment (goto-char pos)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1322 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1323 (defun antlr-skip-file-prelude (skip-comment) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1324 "Skip the file prelude: the header and file options. |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1325 If SKIP-COMMENT is non-nil, also skip the comment after that part. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1326 Return the start position of the file prelude. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1327 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1328 Hack: if SKIP-COMMENT is `header-only' only skip header and return |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1329 position before the comment after the header." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1330 (let* ((pos (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1331 (pos0 pos)) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1332 (antlr-c-forward-sws) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1333 (if skip-comment (setq pos0 (point))) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1334 (while (looking-at "header\\>[ \t]*\\(\"\\)?") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1335 (setq pos (antlr-skip-sexps (if (match-beginning 1) 3 2)))) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1336 (if (eq skip-comment 'header-only) ; a hack... |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1337 pos |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1338 (when (looking-at "options\\>") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1339 (setq pos (antlr-skip-sexps 2))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1340 (or skip-comment (goto-char pos)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1341 pos0))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1342 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1343 (defun antlr-next-rule (arg skip-comment) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1344 "Move forward to next end of rule. Do it ARG many times. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1345 A grammar class header and the file prelude are also considered as a |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1346 rule. Negative argument ARG means move back to ARGth preceding end of |
26965 | 1347 rule. The behavior is not defined when ARG is zero. If SKIP-COMMENT |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1348 is non-nil, move to beginning of the rule." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1349 ;; WARNING: Should only be used with `antlr-action-syntax-table'! |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1350 ;; PRE: ARG<>0 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1351 (let ((pos (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1352 (beg (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1353 ;; first look whether point is in exception part |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1354 (if (antlr-search-backward ";") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1355 (progn |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1356 (setq beg (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1357 (forward-char) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1358 (antlr-skip-exception-part skip-comment)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1359 (antlr-skip-file-prelude skip-comment)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1360 (if (< arg 0) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1361 (unless (and (< (point) pos) (zerop (incf arg))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1362 ;; if we have moved backward, we already moved one defun backward |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1363 (goto-char beg) ; rewind (to ";" / point) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1364 (while (and arg (<= (incf arg) 0)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1365 (if (antlr-search-backward ";") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1366 (setq beg (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1367 (when (>= arg -1) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1368 ;; try file prelude: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1369 (setq pos (antlr-skip-file-prelude skip-comment)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1370 (if (zerop arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1371 (if (>= (point) beg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1372 (goto-char (if (>= pos beg) (point-min) pos))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1373 (goto-char (if (or (>= (point) beg) (= (point) pos)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1374 (point-min) pos)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1375 (setq arg nil))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1376 (when arg ; always found a ";" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1377 (forward-char) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1378 (antlr-skip-exception-part skip-comment))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1379 (if (<= (point) pos) ; moved backward? |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1380 (goto-char pos) ; rewind |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1381 (decf arg)) ; already moved one defun forward |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1382 (unless (zerop arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1383 (while (>= (decf arg) 0) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1384 (antlr-search-forward ";")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1385 (antlr-skip-exception-part skip-comment))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1386 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1387 (defun antlr-outside-rule-p () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1388 "Non-nil if point is outside a grammar rule. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1389 Move to the beginning of the current rule if point is inside a rule." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1390 ;; WARNING: Should only be used with `antlr-action-syntax-table'! |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1391 (let ((pos (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1392 (antlr-next-rule -1 nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1393 (let ((between (or (bobp) (< (point) pos)))) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1394 (antlr-c-forward-sws) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1395 (and between (> (point) pos) (goto-char pos))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1396 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1397 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1398 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1399 ;;; Parse grammar files (commands) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1400 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1401 ;; No (interactive "_") in Emacs... use `zmacs-region-stays'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1402 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1403 (defun antlr-inside-rule-p () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1404 "Non-nil if point is inside a grammar rule. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1405 A grammar class header and the file prelude are also considered as a |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1406 rule." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1407 (save-excursion |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1408 (antlr-with-syntax-table antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1409 (not (antlr-outside-rule-p))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1410 |
49554 | 1411 (defunx antlr-end-of-rule (&optional arg) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1412 "Move forward to next end of rule. Do it ARG [default: 1] many times. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1413 A grammar class header and the file prelude are also considered as a |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1414 rule. Negative argument ARG means move back to ARGth preceding end of |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1415 rule. If ARG is zero, run `antlr-end-of-body'." |
49554 | 1416 (interactive "_p") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1417 (if (zerop arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1418 (antlr-end-of-body) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1419 (antlr-with-syntax-table antlr-action-syntax-table |
49554 | 1420 (antlr-next-rule arg nil)))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1421 |
49554 | 1422 (defunx antlr-beginning-of-rule (&optional arg) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1423 "Move backward to preceding beginning of rule. Do it ARG many times. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1424 A grammar class header and the file prelude are also considered as a |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1425 rule. Negative argument ARG means move forward to ARGth next beginning |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1426 of rule. If ARG is zero, run `antlr-beginning-of-body'." |
49554 | 1427 (interactive "_p") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1428 (if (zerop arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1429 (antlr-beginning-of-body) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1430 (antlr-with-syntax-table antlr-action-syntax-table |
49554 | 1431 (antlr-next-rule (- arg) t)))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1432 |
49554 | 1433 (defunx antlr-end-of-body (&optional msg) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1434 "Move to position after the `;' of the current rule. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1435 A grammar class header is also considered as a rule. With optional |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1436 prefix arg MSG, move to `:'." |
49554 | 1437 (interactive "_") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1438 (antlr-with-syntax-table antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1439 (let ((orig (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1440 (if (antlr-outside-rule-p) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1441 (error "Outside an ANTLR rule")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1442 (let ((bor (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1443 (when (< (antlr-skip-file-prelude t) (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1444 ;; Yes, we are in the file prelude |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1445 (goto-char orig) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1446 (error (or msg "The file prelude is without `;'"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1447 (antlr-search-forward ";") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1448 (when msg |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1449 (when (< (point) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1450 (progn (goto-char bor) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1451 (or (antlr-search-forward ":") (point-max)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1452 (goto-char orig) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1453 (error msg)) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1454 (antlr-c-forward-sws)))))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1455 |
49554 | 1456 (defunx antlr-beginning-of-body () |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1457 "Move to the first element after the `:' of the current rule." |
49554 | 1458 (interactive "_") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1459 (antlr-end-of-body "Class headers and the file prelude are without `:'")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1460 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1461 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1462 ;;;=========================================================================== |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1463 ;;; Literal normalization, Hide Actions |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1464 ;;;=========================================================================== |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1465 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1466 (defun antlr-downcase-literals (&optional transform) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1467 "Convert all literals in buffer to lower case. |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1468 If non-nil, TRANSFORM is used on literals instead of `downcase-region'." |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1469 (interactive) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1470 (or transform (setq transform 'downcase-region)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1471 (let ((literals 0)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1472 (save-excursion |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1473 (goto-char (point-min)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1474 (antlr-with-syntax-table antlr-action-syntax-table |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1475 (antlr-invalidate-context-cache) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1476 (while (antlr-re-search-forward "\"\\(\\sw\\(\\sw\\|-\\)*\\)\"" nil) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1477 (funcall transform (match-beginning 0) (match-end 0)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1478 (incf literals)))) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1479 (message "Transformed %d literals" literals))) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1480 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1481 (defun antlr-upcase-literals () |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1482 "Convert all literals in buffer to upper case." |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1483 (interactive) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1484 (antlr-downcase-literals 'upcase-region)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1485 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1486 (defun antlr-hide-actions (arg &optional silent) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1487 "Hide or unhide all actions in buffer. |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1488 Hide all actions including arguments in brackets if ARG is 1 or if |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1489 called interactively without prefix argument. Hide all actions |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1490 excluding arguments in brackets if ARG is 2 or higher. Unhide all |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1491 actions if ARG is 0 or negative. See `antlr-action-visibility'. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1492 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1493 Display a message unless optional argument SILENT is non-nil." |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1494 (interactive "p") |
49554 | 1495 (save-buffer-state-x |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1496 (if (> arg 0) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1497 (let ((regexp (if (= arg 1) "[]}]" "}")) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1498 (diff (and antlr-action-visibility |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1499 (+ (max antlr-action-visibility 0) 2)))) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1500 (antlr-hide-actions 0 t) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1501 (save-excursion |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1502 (goto-char (point-min)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1503 (antlr-with-syntax-table antlr-action-syntax-table |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1504 (antlr-invalidate-context-cache) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1505 (while (antlr-re-search-forward regexp nil) |
49554 | 1506 (let ((beg (ignore-errors-x (scan-sexps (point) -1)))) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1507 (when beg |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1508 (if diff ; braces are visible |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1509 (if (> (point) (+ beg diff)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1510 (add-text-properties (1+ beg) (1- (point)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1511 '(invisible t intangible t))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1512 ;; if actions is on line(s) of its own, hide WS |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1513 (and (looking-at "[ \t]*$") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1514 (save-excursion |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1515 (goto-char beg) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1516 (skip-chars-backward " \t") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1517 (and (bolp) (setq beg (point)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1518 (beginning-of-line 2)) ; beginning of next line |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1519 (add-text-properties beg (point) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1520 '(invisible t intangible t)))))))) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1521 (or silent |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1522 (message "Hide all actions (%s arguments)...done" |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1523 (if (= arg 1) "including" "excluding")))) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1524 (remove-text-properties (point-min) (point-max) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1525 '(invisible nil intangible nil)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1526 (or silent |
49554 | 1527 (message "Unhide all actions (including arguments)...done"))))) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1528 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1529 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1530 ;;;=========================================================================== |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1531 ;;; Insert option: command |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1532 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1533 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1534 (defun antlr-insert-option (level option &optional location) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1535 "Insert file/grammar/rule/subrule option near point. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1536 LEVEL determines option kind to insert: 1=file, 2=grammar, 3=rule, |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1537 4=subrule. OPTION is a string with the name of the option to insert. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1538 LOCATION can be specified for not calling `antlr-option-kind' twice. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1539 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1540 Inserting an option with this command works as follows: |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1541 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1542 1. When called interactively, LEVEL is determined by the prefix |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1543 argument or automatically deduced without prefix argument. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1544 2. Signal an error if no option of that level could be inserted, e.g., |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1545 if the buffer is read-only, the option area is outside the visible |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1546 part of the buffer or a subrule/rule option should be inserted with |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1547 point outside a subrule/rule. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1548 3. When called interactively, OPTION is read from the minibuffer with |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1549 completion over the known options of the given LEVEL. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1550 4. Ask user for confirmation if the given OPTION does not seem to be a |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1551 valid option to insert into the current file. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1552 5. Find a correct position to insert the option. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1553 6. Depending on the option, insert it the following way \(inserting an |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1554 option also means inserting the option section if necessary\): |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1555 - Insert the option and let user insert the value at point. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1556 - Read a value (with completion) from the minibuffer, using a |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1557 previous value as initial contents, and insert option with value. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1558 7. Final action depending on the option. For example, set the language |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1559 according to a newly inserted language option. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1560 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1561 The name of all options with a specification for their values are stored |
49554 | 1562 in `antlr-options-alists'. The used specification also depends on the |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1563 value of `antlr-tool-version', i.e., step 4 will warn you if you use an |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1564 option that has been introduced in newer version of ANTLR, and step 5 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1565 will offer completion using version-correct values. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1566 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1567 If the option already exists inside the visible part of the buffer, this |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1568 command can be used to change the value of that option. Otherwise, find |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1569 a correct position where the option can be inserted near point. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1570 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1571 The search for a correct position is as follows: |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1572 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1573 * If search is within an area where options can be inserted, use the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1574 position of point. Inside the options section and if point is in |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1575 the middle of a option definition, skip the rest of it. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1576 * If an options section already exists, insert the options at the end. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1577 If only the beginning of the area is visible, insert at the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1578 beginning. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1579 * Otherwise, find the position where an options section can be |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1580 inserted and insert a new section before any comments. If the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1581 position before the comments is not visible, insert the new section |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1582 after the comments. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1583 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1584 This function also inserts \"options {...}\" and the \":\" if necessary, |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1585 see `antlr-options-auto-colon'. See also `antlr-options-assign-string'. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1586 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1587 This command might also set the mark like \\[set-mark-command] does, see |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1588 `antlr-options-push-mark'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1589 (interactive (antlr-insert-option-interactive current-prefix-arg)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1590 (barf-if-buffer-read-only) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1591 (or location (setq location (cdr (antlr-option-kind level)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1592 (cond ((null level) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1593 (error "Cannot deduce what kind of option to insert")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1594 ((atom location) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1595 (error "Cannot insert any %s options around here" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1596 (elt antlr-options-headings (1- level))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1597 (let ((area (car location)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1598 (place (cdr location))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1599 (cond ((null place) ; invisible |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1600 (error (if area |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1601 "Invisible %s options, use %s to make them visible" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1602 "Invisible area for %s options, use %s to make it visible") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1603 (elt antlr-options-headings (1- level)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1604 (substitute-command-keys "\\[widen]"))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1605 ((null area) ; without option part |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1606 (antlr-insert-option-do level option nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1607 (null (cdr place)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1608 (car place))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1609 ((save-excursion ; with option part, option visible |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1610 (goto-char (max (point-min) (car area))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1611 (re-search-forward (concat "\\(^\\|;\\)[ \t]*\\(\\<" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1612 (regexp-quote option) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1613 "\\>\\)[ \t\n]*\\(\\(=[ \t]?\\)[ \t]*\\(\\(\\sw\\|\\s_\\)+\\|\"\\([^\n\"\\]\\|[\\][^\n]\\)*\"\\)?\\)?") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1614 ;; 2=name, 3=4+5, 4="=", 5=value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1615 (min (point-max) (cdr area)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1616 t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1617 (antlr-insert-option-do level option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1618 (cons (or (match-beginning 5) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1619 (match-beginning 3)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1620 (match-end 5)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1621 (and (null (cdr place)) area) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1622 (or (match-beginning 5) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1623 (match-end 4) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1624 (match-end 2)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1625 (t ; with option part, option not yet |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1626 (antlr-insert-option-do level option t |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1627 (and (null (cdr place)) area) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1628 (car place)))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1629 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1630 (defun antlr-insert-option-interactive (arg) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1631 "Interactive specification for `antlr-insert-option'. |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1632 Return \(LEVEL OPTION LOCATION)." |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1633 (barf-if-buffer-read-only) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1634 (if arg (setq arg (prefix-numeric-value arg))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1635 (unless (memq arg '(nil 1 2 3 4)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1636 (error "Valid prefix args: no=auto, 1=file, 2=grammar, 3=rule, 4=subrule")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1637 (let* ((kind (antlr-option-kind arg)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1638 (level (car kind))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1639 (if (atom (cdr kind)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1640 (list level nil (cdr kind)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1641 (let* ((table (elt antlr-options-alists (1- level))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1642 (completion-ignore-case t) ;dynamic |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1643 (input (completing-read (format "Insert %s option: " |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1644 (elt antlr-options-headings |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1645 (1- level))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1646 table))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1647 (list level input (cdr kind)))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1648 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1649 (defun antlr-options-menu-filter (level menu-items) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1650 "Return items for options submenu of level LEVEL." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1651 ;; checkdoc-params: (menu-items) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1652 (let ((active (if buffer-read-only |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1653 nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1654 (consp (cdr-safe (cdr (antlr-option-kind level))))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1655 (mapcar (lambda (option) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1656 (vector option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1657 (list 'antlr-insert-option level option) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1658 :active active)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1659 (sort (mapcar 'car (elt antlr-options-alists (1- level))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1660 'string-lessp)))) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1661 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1662 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1663 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1664 ;;; Insert option: determine section-kind |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1665 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1666 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1667 (defun antlr-option-kind (requested) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1668 "Return level and location for option to insert near point. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1669 Call function `antlr-option-level' with argument REQUESTED. If the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1670 result is nil, return \(REQUESTED \. error). If the result has the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1671 non-nil value LEVEL, return \(LEVEL \. LOCATION) where LOCATION looks |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1672 like \(AREA \. PLACE), see `antlr-option-location'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1673 (save-excursion |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1674 (save-restriction |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1675 (let ((min0 (point-min)) ; before `widen'! |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1676 (max0 (point-max)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1677 (orig (point)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1678 (level (antlr-option-level requested)) ; calls `widen'! |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1679 pos) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1680 (cond ((null level) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1681 (setq level requested)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1682 ((eq level 1) ; file options |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1683 (goto-char (point-min)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1684 (setq pos (antlr-skip-file-prelude 'header-only))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1685 ((not (eq level 3)) ; grammar or subrule options |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1686 (setq pos (point)) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1687 (antlr-c-forward-sws)) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1688 ((looking-at "^\\(private[ \t\n]\\|public[ \t\n]\\|protected[ \t\n]\\)?[ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]*\\(!\\)?[ \t\n]*\\(\\[\\)?") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1689 ;; rule options, with complete rule header |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1690 (goto-char (or (match-end 4) (match-end 3))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1691 (setq pos (antlr-skip-sexps (if (match-end 5) 1 0))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1692 (when (looking-at "returns[ \t\n]*\\[") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1693 (goto-char (1- (match-end 0))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1694 (setq pos (antlr-skip-sexps 1))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1695 (cons level |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1696 (cond ((null pos) 'error) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1697 ((looking-at "options[ \t\n]*{") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1698 (goto-char (match-end 0)) |
49554 | 1699 (setq pos (ignore-errors-x (scan-lists (point) 1 1))) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1700 (antlr-option-location orig min0 max0 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1701 (point) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1702 (if pos (1- pos) (point-max)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1703 t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1704 (t |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1705 (antlr-option-location orig min0 max0 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1706 pos (point) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1707 nil)))))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1708 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1709 (defun antlr-option-level (requested) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1710 "Return level for option to insert near point. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1711 Remove any restrictions from current buffer and return level for the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1712 option to insert near point, i.e., 1, 2, 3, 4, or nil if no such option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1713 can be inserted. If REQUESTED is non-nil, it is the only possible value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1714 to return except nil. If REQUESTED is nil, return level for the nearest |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1715 option kind, i.e., the highest number possible. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1716 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1717 If the result is 2, point is at the beginning of the class after the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1718 class definition. If the result is 3 or 4, point is at the beginning of |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1719 the rule/subrule after the init action. Otherwise, the point position |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1720 is undefined." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1721 (widen) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1722 (if (eq requested 1) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1723 1 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1724 (antlr-with-syntax-table antlr-action-syntax-table |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1725 (antlr-invalidate-context-cache) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1726 (let* ((orig (point)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1727 (outsidep (antlr-outside-rule-p)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1728 bor depth) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1729 (if (eq (char-after) ?\{) (antlr-skip-sexps 1)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1730 (setq bor (point)) ; beginning of rule (after init action) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1731 (cond ((eq requested 2) ; grammar options required? |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1732 (let (boc) ; beginning of class |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1733 (goto-char (point-min)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1734 (while (and (<= (point) bor) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1735 (antlr-re-search-forward antlr-class-header-regexp |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1736 nil)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1737 (if (<= (match-beginning 0) bor) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1738 (setq boc (match-end 0)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1739 (when boc |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1740 (goto-char boc) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1741 2))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1742 ((save-excursion ; in region of file options? |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1743 (goto-char (point-min)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1744 (antlr-skip-file-prelude t) ; ws/comment after: OK |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1745 (< orig (point))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1746 (and (null requested) 1)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1747 (outsidep ; outside rule not OK |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1748 nil) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1749 ((looking-at antlr-class-header-regexp) ; rule = class def? |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1750 (goto-char (match-end 0)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1751 (and (null requested) 2)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1752 ((eq requested 3) ; rule options required? |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1753 (goto-char bor) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1754 3) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1755 ((setq depth (antlr-syntactic-grammar-depth orig bor)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1756 (if (> depth 0) ; move out of actions |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1757 (goto-char (scan-lists (point) -1 depth))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1758 (set-syntax-table antlr-mode-syntax-table) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1759 (antlr-invalidate-context-cache) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1760 (if (eq (antlr-syntactic-context) 0) ; not in subrule? |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1761 (unless (eq requested 4) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1762 (goto-char bor) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1763 3) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1764 (goto-char (1+ (scan-lists (point) -1 1))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1765 4))))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1766 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1767 (defun antlr-option-location (orig min-vis max-vis min-area max-area withp) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1768 "Return location for the options area. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1769 ORIG is the original position of `point', MIN-VIS is `point-min' and |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1770 MAX-VIS is `point-max'. If WITHP is non-nil, there exists an option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1771 specification and it starts after the brace at MIN-AREA and stops at |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1772 MAX-AREA. If WITHP is nil, there is no area and the region where it |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1773 could be inserted starts at MIN-AREA and stops at MAX-AREA. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1774 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1775 The result has the form (AREA . PLACE). AREA is (MIN-AREA . MAX-AREA) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1776 if WITHP is non-nil, and nil otherwise. PLACE is nil if the area is |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1777 invisible, (ORIG) if ORIG is inside the area, (MIN-AREA . beginning) for |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1778 a visible start position and (MAX-AREA . end) for a visible end position |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1779 where the beginning is preferred if WITHP is nil and the end if WITHP is |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1780 non-nil." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1781 (cons (and withp (cons min-area max-area)) |
49554 | 1782 (cond ((and (<= min-area orig) (<= orig max-area) |
1783 (save-excursion | |
1784 (goto-char orig) | |
1785 (not (memq (antlr-syntactic-context) | |
1786 '(comment block-comment))))) | |
1787 ;; point in options area and not in comment | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1788 (list orig)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1789 ((and (null withp) (<= min-vis min-area) (<= min-area max-vis)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1790 ;; use start of options area (only if not `withp') |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1791 (cons min-area 'beginning)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1792 ((and (<= min-vis max-area) (<= max-area max-vis)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1793 ;; use end of options area |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1794 (cons max-area 'end)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1795 ((and withp (<= min-vis min-area) (<= min-area max-vis)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1796 ;; use start of options area (only if `withp') |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1797 (cons min-area 'beginning))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1798 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1799 (defun antlr-syntactic-grammar-depth (pos beg) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1800 "Return syntactic context depth at POS. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1801 Move to POS and from there on to the beginning of the string or comment |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1802 if POS is inside such a construct. Then, return the syntactic context |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1803 depth at point if the point position is smaller than BEG. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1804 WARNING: this may alter `match-data'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1805 (goto-char pos) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1806 (let ((context (or (antlr-syntactic-context) 0))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1807 (while (and context (not (integerp context))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1808 (cond ((eq context 'string) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1809 (setq context |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1810 (and (search-backward "\"" nil t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1811 (>= (point) beg) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1812 (or (antlr-syntactic-context) 0)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1813 ((memq context '(comment block-comment)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1814 (setq context |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1815 (and (re-search-backward "/[/*]" nil t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1816 (>= (point) beg) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1817 (or (antlr-syntactic-context) 0)))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1818 context)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1819 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1820 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1821 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1822 ;;; Insert options: do the insertion |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1823 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1824 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1825 (defun antlr-insert-option-do (level option old area pos) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1826 "Insert option into buffer at position POS. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1827 Insert option of level LEVEL and name OPTION. If OLD is non-nil, an |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1828 options area is already exists. If OLD looks like \(BEG \. END), the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1829 option already exists. Then, BEG is the start position of the option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1830 value, the position of the `=' or nil, and END is the end position of |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1831 the option value or nil. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1832 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1833 If the original point position was outside an options area, AREA is nil. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1834 Otherwise, and if an option specification already exists, AREA is a cons |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1835 cell where the two values determine the area inside the braces." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1836 (let* ((spec (cdr (assoc option (elt antlr-options-alists (1- level))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1837 (value (antlr-option-spec level option (cdr spec) (consp old)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1838 (if (fboundp (car spec)) (funcall (car spec) 'before-input option)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1839 ;; set mark (unless point was inside options area before) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1840 (if (cond (area (eq antlr-options-push-mark t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1841 ((numberp antlr-options-push-mark) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1842 (> (count-lines (min (point) pos) (max (point) pos)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1843 antlr-options-push-mark)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1844 (antlr-options-push-mark)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1845 (push-mark)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1846 ;; read option value ----------------------------------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1847 (goto-char pos) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1848 (if (null value) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1849 ;; no option specification found |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1850 (if (y-or-n-p (format "Insert unknown %s option %s? " |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1851 (elt antlr-options-headings (1- level)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1852 option)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1853 (message "Insert value for %s option %s" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1854 (elt antlr-options-headings (1- level)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1855 option) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1856 (error "Didn't insert unknown %s option %s" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1857 (elt antlr-options-headings (1- level)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1858 option)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1859 ;; option specification found |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1860 (setq value (cdr value)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1861 (if (car value) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1862 (let ((initial (and (consp old) (cdr old) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1863 (buffer-substring (car old) (cdr old))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1864 (setq value (apply (car value) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1865 (and initial |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1866 (if (eq (aref initial 0) ?\") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1867 (read initial) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1868 initial)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1869 (cdr value)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1870 (message (cadr value)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1871 (setq value nil))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1872 ;; insert value ---------------------------------------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1873 (if (consp old) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1874 (antlr-insert-option-existing old value) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1875 (if (consp area) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1876 ;; Move outside string/comment if point is inside option spec |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1877 (antlr-syntactic-grammar-depth (point) (car area))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1878 (antlr-insert-option-space area old) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1879 (or old (antlr-insert-option-area level)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1880 (insert option " = ;") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1881 (backward-char) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1882 (if value (insert value))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1883 ;; final ----------------------------------------------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1884 (if (fboundp (car spec)) (funcall (car spec) 'after-insertion option)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1885 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1886 (defun antlr-option-spec (level option specs existsp) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1887 "Return version correct option value specification. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1888 Return specification for option OPTION of kind level LEVEL. SPECS |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1889 should correspond to the VALUE-SPEC... in `antlr-option-alists'. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1890 EXISTSP determines whether the option already exists." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1891 (let (value) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1892 (while (and specs (>= antlr-tool-version (caar specs))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1893 (setq value (pop specs))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1894 (cond (value) ; found correct spec |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1895 ((null specs) nil) ; didn't find any specs |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1896 (existsp (car specs)) ; wrong version, but already present |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1897 ((y-or-n-p (format "Insert v%s %s option %s in v%s? " |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1898 (antlr-version-string (caar specs)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1899 (elt antlr-options-headings (1- level)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1900 option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1901 (antlr-version-string antlr-tool-version))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1902 (car specs)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1903 (t |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1904 (error "Didn't insert v%s %s option %s in v%s" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1905 (antlr-version-string (caar specs)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1906 (elt antlr-options-headings (1- level)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1907 option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1908 (antlr-version-string antlr-tool-version)))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1909 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1910 (defun antlr-version-string (version) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1911 "Format the Antlr version number VERSION, see `antlr-tool-version'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1912 (let ((version100 (/ version 100))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1913 (format "%d.%d.%d" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1914 (/ version100 100) (mod version100 100) (mod version 100)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1915 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1916 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1917 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1918 ;;; Insert options: the details (used by `antlr-insert-option-do') |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1919 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1920 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1921 (defun antlr-insert-option-existing (old value) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1922 "Insert option value VALUE at point for existing option. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1923 For OLD, see `antlr-insert-option-do'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1924 ;; no = => insert = |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1925 (unless (car old) (insert antlr-options-assign-string)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1926 ;; with user input => insert if necessary |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1927 (when value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1928 (if (cdr old) ; with value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1929 (if (string-equal value (buffer-substring (car old) (cdr old))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1930 (goto-char (cdr old)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1931 (delete-region (car old) (cdr old)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1932 (insert value)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1933 (insert value))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1934 (unless (looking-at "\\([^\n=;{}/'\"]\\|'\\([^\n'\\]\\|\\\\.\\)*'\\|\"\\([^\n\"\\]\\|\\\\.\\)*\"\\)*;") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1935 ;; stuff (no =, {, } or /) at point is not followed by ";" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1936 (insert ";") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1937 (backward-char))) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1938 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1939 (defun antlr-insert-option-space (area old) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1940 "Find appropriate place to insert option, insert newlines/spaces. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1941 For AREA and OLD, see `antlr-insert-option-do'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1942 (let ((orig (point)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1943 (open t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1944 (skip-chars-backward " \t") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1945 (unless (bolp) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1946 (let ((before (char-after (1- (point))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1947 (goto-char orig) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1948 (and old ; with existing options area |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1949 (consp area) ; if point inside existing area |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1950 (not (eq before ?\;)) ; if not at beginning of option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1951 ; => skip to end of option |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1952 (if (and (search-forward ";" (cdr area) t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1953 (let ((context (antlr-syntactic-context))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1954 (or (null context) (numberp context)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1955 (setq orig (point)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1956 (goto-char orig))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1957 (skip-chars-forward " \t") |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1958 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1959 (if (looking-at "$\\|//") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1960 ;; just comment after point => skip (+ lines w/ same col comment) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1961 (let ((same (if (> (match-end 0) (match-beginning 0)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1962 (current-column)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1963 (beginning-of-line 2) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1964 (or (bolp) (insert "\n")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1965 (when (and same (null area)) ; or (consp area)? |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1966 (while (and (looking-at "[ \t]*\\(//\\)") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1967 (goto-char (match-beginning 1)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1968 (= (current-column) same)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1969 (beginning-of-line 2) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1970 (or (bolp) (insert "\n"))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1971 (goto-char orig) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1972 (if (null old) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1973 (progn (insert "\n") (antlr-indent-line)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1974 (unless (eq (char-after (1- (point))) ?\ ) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1975 (insert " ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1976 (unless (eq (char-after (point)) ?\ ) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1977 (insert " ") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1978 (backward-char)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1979 (setq open nil))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1980 (when open |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1981 (beginning-of-line 1) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1982 (insert "\n") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1983 (backward-char) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1984 (antlr-indent-line)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1985 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1986 (defun antlr-insert-option-area (level) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1987 "Insert new options area for options of level LEVEL. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1988 Used by `antlr-insert-option-do'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1989 (insert "options {\n\n}") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1990 (when (and antlr-options-auto-colon |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1991 (memq level '(3 4)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1992 (save-excursion |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1993 (antlr-c-forward-sws) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1994 (if (eq (char-after (point)) ?\{) (antlr-skip-sexps 1)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1995 (not (eq (char-after (point)) ?\:)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1996 (insert "\n:") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1997 (antlr-indent-line) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1998 (end-of-line 0)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
1999 (backward-char 1) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2000 (antlr-indent-line) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2001 (beginning-of-line 0) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2002 (antlr-indent-line)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2003 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2004 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2005 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2006 ;;; Insert options: in `antlr-options-alists' |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2007 ;;;=========================================================================== |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2008 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2009 (defun antlr-read-value (initial-contents prompt |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2010 &optional as-string table table-x) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2011 "Read a string from the minibuffer, possibly with completion. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2012 If INITIAL-CONTENTS is non-nil, insert it in the minibuffer initially. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2013 PROMPT is a string to prompt with, normally it ends in a colon and a |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2014 space. If AS-STRING is t or is a member \(comparison done with `eq') of |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2015 `antlr-options-style', return printed representation of the user input, |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2016 otherwise return the user input directly. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2017 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2018 If TABLE or TABLE-X is non-nil, read with completion. The completion |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2019 table is the resulting alist of TABLE-X concatenated with TABLE where |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2020 TABLE can also be a function evaluation to an alist. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2021 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2022 Used inside `antlr-options-alists'." |
49554 | 2023 (let* ((completion-ignore-case t) ; dynamic |
2024 (table0 (and (or table table-x) | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2025 (append table-x |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2026 (if (functionp table) (funcall table) table)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2027 (input (if table0 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2028 (completing-read prompt table0 nil nil initial-contents) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2029 (read-from-minibuffer prompt initial-contents)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2030 (if (and as-string |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2031 (or (eq as-string t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2032 (cdr (assq as-string antlr-options-style)))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2033 (format "%S" input) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2034 input))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2035 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2036 (defun antlr-read-boolean (initial-contents prompt &optional table) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2037 "Read a boolean value from the minibuffer, with completion. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2038 If INITIAL-CONTENTS is non-nil, insert it in the minibuffer initially. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2039 PROMPT is a string to prompt with, normally it ends in a question mark |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2040 and a space. \"(true or false) \" is appended if TABLE is nil. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2041 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2042 Read with completion over \"true\", \"false\" and the keys in TABLE, see |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2043 also `antlr-read-value'. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2044 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2045 Used inside `antlr-options-alists'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2046 (antlr-read-value initial-contents |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2047 (if table prompt (concat prompt "(true or false) ")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2048 nil |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2049 table '(("false") ("true")))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2050 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2051 (defun antlr-language-option-extra (phase &rest dummies) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2052 ;; checkdoc-params: (dummies) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2053 "Change language according to the new value of the \"language\" option. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2054 Call `antlr-mode' if the new language would be different from the value |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2055 of `antlr-language', keeping the value of variable `font-lock-mode'. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2056 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2057 Called in PHASE `after-insertion', see `antlr-options-alists'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2058 (when (eq phase 'after-insertion) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2059 (let ((new-language (antlr-language-option t))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2060 (or (null new-language) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2061 (eq new-language antlr-language) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2062 (let ((font-lock (and (boundp 'font-lock-mode) font-lock-mode))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2063 (if font-lock (font-lock-mode 0)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2064 (antlr-mode) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2065 (and font-lock (null font-lock-mode) (font-lock-mode 1))))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2066 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2067 (defun antlr-c++-mode-extra (phase option &rest dummies) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2068 ;; checkdoc-params: (option dummies) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2069 "Warn if C++ option is used with the wrong language. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2070 Ask user \(\"y or n\"), if a C++ only option is going to be inserted but |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2071 `antlr-language' has not the value `c++-mode'. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2072 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2073 Called in PHASE `before-input', see `antlr-options-alists'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2074 (and (eq phase 'before-input) |
49554 | 2075 (not (eq antlr-language 'c++-mode)) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2076 (not (y-or-n-p (format "Insert C++ %s option? " option))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2077 (error "Didn't insert C++ %s option with language %s" |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2078 option (cadr (assq antlr-language antlr-language-alist))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2079 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2080 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2081 ;;;=========================================================================== |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2082 ;;; Compute dependencies |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2083 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2084 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2085 (defun antlr-file-dependencies () |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2086 "Return dependencies for grammar in current buffer. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2087 The result looks like \(FILE \(CLASSES \. SUPERS) VOCABS \. LANGUAGE) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2088 where CLASSES = ((CLASS . CLASS-EVOCAB) ...), |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2089 SUPERS = ((SUPER . USE-EVOCAB-P) ...), and |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2090 VOCABS = ((EVOCAB ...) . (IVOCAB ...)) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2091 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2092 FILE is the current buffer's file-name without directory part and |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2093 LANGUAGE is the value of `antlr-language' in the current buffer. Each |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2094 EVOCAB is an export vocabulary and each IVOCAB is an import vocabulary. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2095 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2096 Each CLASS is a grammar class with its export vocabulary CLASS-EVOCAB. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2097 Each SUPER is a super-grammar class where USE-EVOCAB-P indicates whether |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2098 its export vocabulary is used as an import vocabulary." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2099 (unless buffer-file-name |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2100 (error "Grammar buffer does not visit a file")) |
49554 | 2101 (let (classes export-vocabs import-vocabs superclasses default-vocab) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2102 (antlr-with-syntax-table antlr-action-syntax-table |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2103 (goto-char (point-min)) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2104 (while (antlr-re-search-forward antlr-class-header-regexp nil) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2105 ;; parse class definition -------------------------------------------- |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2106 (let* ((class (match-string 2)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2107 (sclass (match-string 4)) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2108 ;; export vocab defaults to class name (first grammar in file) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2109 ;; or to the export vocab of the first grammar in file: |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2110 (evocab (or default-vocab class)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2111 (ivocab nil)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2112 (goto-char (match-end 0)) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2113 (antlr-c-forward-sws) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2114 (while (looking-at "options\\>\\|\\(tokens\\)\\>") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2115 (if (match-beginning 1) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2116 (antlr-skip-sexps 2) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2117 (goto-char (match-end 0)) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2118 (antlr-c-forward-sws) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2119 ;; parse grammar option sections ------------------------------- |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2120 (when (eq (char-after (point)) ?\{) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2121 (let* ((beg (1+ (point))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2122 (end (1- (antlr-skip-sexps 1))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2123 (cont (point))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2124 (goto-char beg) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2125 (if (re-search-forward "\\<exportVocab[ \t]*=[ \t]*\\([A-Za-z\300-\326\330-\337]\\sw*\\)" end t) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2126 (setq evocab (match-string 1))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2127 (goto-char beg) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2128 (if (re-search-forward "\\<importVocab[ \t]*=[ \t]*\\([A-Za-z\300-\326\330-\337]\\sw*\\)" end t) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2129 (setq ivocab (match-string 1))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2130 (goto-char cont))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2131 (unless (member sclass '("Parser" "Lexer" "TreeParser")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2132 (let ((super (assoc sclass superclasses))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2133 (if super |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2134 (or ivocab (setcdr super t)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2135 (push (cons sclass (null ivocab)) superclasses)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2136 ;; remember class with export vocabulary: |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2137 (push (cons class evocab) classes) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2138 ;; default export vocab is export vocab of first grammar in file: |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2139 (or default-vocab (setq default-vocab evocab)) |
49554 | 2140 (or (member evocab export-vocabs) (push evocab export-vocabs)) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2141 (or (null ivocab) |
49554 | 2142 (member ivocab import-vocabs) (push ivocab import-vocabs))))) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2143 (if classes |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2144 (list* (file-name-nondirectory buffer-file-name) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2145 (cons (nreverse classes) (nreverse superclasses)) |
49554 | 2146 (cons (nreverse export-vocabs) (nreverse import-vocabs)) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2147 antlr-language)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2148 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2149 (defun antlr-directory-dependencies (dirname) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2150 "Return dependencies for all grammar files in directory DIRNAME. |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2151 The result looks like \((CLASS-SPEC ...) \. \(FILE-DEP ...)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2152 where CLASS-SPEC = (CLASS (FILE \. EVOCAB) ...). |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2153 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2154 FILE-DEP are the dependencies for each grammar file in DIRNAME, see |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2155 `antlr-file-dependencies'. For each grammar class CLASS, FILE is a |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2156 grammar file in which CLASS is defined and EVOCAB is the name of the |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2157 export vocabulary specified in that file." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2158 (let ((grammar (directory-files dirname t "\\.g\\'"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2159 (when grammar |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2160 (let ((temp-buffer (get-buffer-create |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2161 (generate-new-buffer-name " *temp*"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2162 (antlr-imenu-name nil) ; dynamic-let: no imenu |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2163 (expanded-regexp (concat (format (regexp-quote |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2164 (cadr antlr-special-file-formats)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2165 ".+") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2166 "\\'")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2167 classes dependencies) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2168 (unwind-protect |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2169 (save-excursion |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2170 (set-buffer temp-buffer) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2171 (widen) ; just in case... |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2172 (dolist (file grammar) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2173 (when (and (file-regular-p file) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2174 (null (string-match expanded-regexp file))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2175 (insert-file-contents file t nil nil t) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2176 (normal-mode t) ; necessary for major-mode, syntax |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2177 ; table and `antlr-language' |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2178 (when (eq major-mode 'antlr-mode) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2179 (let* ((file-deps (antlr-file-dependencies)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2180 (file (car file-deps))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2181 (when file-deps |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2182 (dolist (class-def (caadr file-deps)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2183 (let ((file-evocab (cons file (cdr class-def))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2184 (class-spec (assoc (car class-def) classes))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2185 (if class-spec |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2186 (nconc (cdr class-spec) (list file-evocab)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2187 (push (list (car class-def) file-evocab) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2188 classes)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2189 (push file-deps dependencies))))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2190 (kill-buffer temp-buffer)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2191 (cons (nreverse classes) (nreverse dependencies)))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2192 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2193 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2194 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2195 ;;; Compilation: run ANTLR tool |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2196 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2197 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2198 (defun antlr-superclasses-glibs (supers classes) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2199 "Compute the grammar lib option for the super grammars SUPERS. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2200 Look in CLASSES for the right grammar lib files for SUPERS. SUPERS is |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2201 part SUPER in the result of `antlr-file-dependencies'. CLASSES is the |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2202 part \(CLASS-SPEC ...) in the result of `antlr-directory-dependencies'. |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2203 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2204 The result looks like \(OPTION WITH-UNKNOWN GLIB ...). OPTION is the |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2205 complete \"-glib\" option. WITH-UNKNOWN has value t iff there is none |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2206 or more than one grammar file for at least one super grammar. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2207 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2208 Each GLIB looks like \(GRAMMAR-FILE \. EVOCAB). GRAMMAR-FILE is a file |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2209 in which a super-grammar is defined. EVOCAB is the value of the export |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2210 vocabulary of the super-grammar or nil if it is not needed." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2211 ;; If the superclass is defined in the same file, that file will be included |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2212 ;; with -glib again. This will lead to a redefinition. But defining a |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2213 ;; analyzer of the same class twice in a file will lead to an error anyway... |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2214 (let (glibs unknown) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2215 (while supers |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2216 (let* ((super (pop supers)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2217 (sup-files (cdr (assoc (car super) classes))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2218 (file (and sup-files (null (cdr sup-files)) (car sup-files)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2219 (or file (setq unknown t)) ; not exactly one file |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2220 (push (cons (or (car file) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2221 (format (car antlr-unknown-file-formats) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2222 (car super))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2223 (and (cdr super) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2224 (or (cdr file) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2225 (format (cadr antlr-unknown-file-formats) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2226 (car super))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2227 glibs))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2228 (cons (if glibs (concat " -glib " (mapconcat 'car glibs ";")) "") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2229 (cons unknown glibs)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2230 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2231 (defun antlr-run-tool (command file &optional saved) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2232 "Run Antlr took COMMAND on grammar FILE. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2233 When called interactively, COMMAND is read from the minibuffer and |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2234 defaults to `antlr-tool-command' with a computed \"-glib\" option if |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2235 necessary. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2236 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2237 Save all buffers first unless optional value SAVED is non-nil. When |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2238 called interactively, the buffers are always saved, see also variable |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2239 `antlr-ask-about-save'." |
49554 | 2240 (interactive (antlr-run-tool-interactive)) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2241 (or saved (save-some-buffers (not antlr-ask-about-save))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2242 (let ((default-directory (file-name-directory file))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2243 (require 'compile) ; only `compile' autoload |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2244 (compile-internal (concat command " " (file-name-nondirectory file)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2245 "No more errors" "Antlr-Run"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2246 |
49554 | 2247 (defun antlr-run-tool-interactive () |
2248 ;; code in `interactive' is not compiled | |
2249 "Interactive specification for `antlr-run-tool'. | |
2250 Use prefix argument ARG to return \(COMMAND FILE SAVED)." | |
2251 (let* ((supers (cdadr (save-excursion | |
2252 (save-restriction | |
2253 (widen) | |
2254 (antlr-file-dependencies))))) | |
2255 (glibs "")) | |
2256 (when supers | |
2257 (save-some-buffers (not antlr-ask-about-save) nil) | |
2258 (setq glibs (car (antlr-superclasses-glibs | |
2259 supers | |
2260 (car (antlr-directory-dependencies | |
2261 (antlr-default-directory))))))) | |
2262 (list (antlr-read-shell-command "Run Antlr on current file with: " | |
2263 (concat antlr-tool-command glibs " ")) | |
2264 buffer-file-name | |
2265 supers))) | |
2266 | |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2267 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2268 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2269 ;;; Makefile creation |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2270 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2271 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2272 (defun antlr-makefile-insert-variable (number pre post) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2273 "Insert Makefile variable numbered NUMBER according to specification. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2274 Also insert strings PRE and POST before and after the variable." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2275 (let ((spec (cadr antlr-makefile-specification))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2276 (when spec |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2277 (insert pre |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2278 (if number (format (cadr spec) number) (car spec)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2279 post)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2280 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2281 (defun antlr-insert-makefile-rules (&optional in-makefile) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2282 "Insert Makefile rules in the current buffer at point. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2283 IN-MAKEFILE is non-nil, if the current buffer is the Makefile. See |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2284 command `antlr-show-makefile-rules' for detail." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2285 (let* ((dirname (antlr-default-directory)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2286 (deps0 (antlr-directory-dependencies dirname)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2287 (classes (car deps0)) ; CLASS -> (FILE . EVOCAB) ... |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2288 (deps (cdr deps0)) ; FILE -> (c . s) (ev . iv) . LANGUAGE |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2289 (with-error nil) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2290 (gen-sep (or (caddr (cadr antlr-makefile-specification)) " ")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2291 (n (and (cdr deps) (cadr antlr-makefile-specification) 0))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2292 (or in-makefile (set-buffer standard-output)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2293 (dolist (dep deps) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2294 (let ((supers (cdadr dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2295 (lang (cdr (assoc (cdddr dep) antlr-file-formats-alist)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2296 (if n (incf n)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2297 (antlr-makefile-insert-variable n "" " =") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2298 (if supers |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2299 (insert " " |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2300 (format (cadr antlr-special-file-formats) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2301 (file-name-sans-extension (car dep))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2302 (dolist (class-def (caadr dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2303 (let ((sep gen-sep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2304 (dolist (class-file (cadr lang)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2305 (insert sep (format class-file (car class-def))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2306 (setq sep " ")))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2307 (dolist (evocab (caaddr dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2308 (let ((sep gen-sep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2309 (dolist (vocab-file (cons (car antlr-special-file-formats) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2310 (car lang))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2311 (insert sep (format vocab-file evocab)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2312 (setq sep " ")))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2313 (antlr-makefile-insert-variable n "\n$(" ")") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2314 (insert ": " (car dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2315 (dolist (ivocab (cdaddr dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2316 (insert " " (format (car antlr-special-file-formats) ivocab))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2317 (let ((glibs (antlr-superclasses-glibs supers classes))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2318 (if (cadr glibs) (setq with-error t)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2319 (dolist (super (cddr glibs)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2320 (insert " " (car super)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2321 (if (cdr super) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2322 (insert " " (format (car antlr-special-file-formats) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2323 (cdr super))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2324 (insert "\n\t" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2325 (caddr antlr-makefile-specification) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2326 (car glibs) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2327 " $<\n" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2328 (car antlr-makefile-specification))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2329 (if n |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2330 (let ((i 0)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2331 (antlr-makefile-insert-variable nil "" " =") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2332 (while (<= (incf i) n) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2333 (antlr-makefile-insert-variable i " $(" ")")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2334 (insert "\n" (car antlr-makefile-specification)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2335 (if (string-equal (car antlr-makefile-specification) "\n") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2336 (backward-delete-char 1)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2337 (when with-error |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2338 (goto-char (point-min)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2339 (insert antlr-help-unknown-file-text)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2340 (unless in-makefile |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2341 (copy-region-as-kill (point-min) (point-max)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2342 (goto-char (point-min)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2343 (insert (format antlr-help-rules-intro dirname))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2344 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2345 ;;;###autoload |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2346 (defun antlr-show-makefile-rules () |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2347 "Show Makefile rules for all grammar files in the current directory. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2348 If the `major-mode' of the current buffer has the value `makefile-mode', |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2349 the rules are directory inserted at point. Otherwise, a *Help* buffer |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2350 is shown with the rules which are also put into the `kill-ring' for |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2351 \\[yank]. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2352 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2353 This command considers import/export vocabularies and grammar |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2354 inheritance and provides a value for the \"-glib\" option if necessary. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2355 Customize variable `antlr-makefile-specification' for the appearance of |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2356 the rules. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2357 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2358 If the file for a super-grammar cannot be determined, special file names |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2359 are used according to variable `antlr-unknown-file-formats' and a |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2360 commentary with value `antlr-help-unknown-file-text' is added. The |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2361 *Help* buffer always starts with the text in `antlr-help-rules-intro'." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2362 (interactive) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2363 (if (null (eq major-mode 'makefile-mode)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2364 (antlr-with-displaying-help-buffer 'antlr-insert-makefile-rules) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2365 (push-mark) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2366 (antlr-insert-makefile-rules t))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2367 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2368 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2369 ;;;=========================================================================== |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2370 ;;; Indentation |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2371 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2372 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2373 (defun antlr-indent-line () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2374 "Indent the current line as ANTLR grammar code. |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2375 The indentation of grammar lines are calculated by `c-basic-offset', |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2376 multiplied by: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2377 - the level of the paren/brace/bracket depth, |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2378 - plus 0/2/1, depending on the position inside the rule: header, body, |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2379 exception part, |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2380 - minus 1 if `antlr-indent-item-regexp' matches the beginning of the |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2381 line starting from the first non-whitespace. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2382 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2383 Lines inside block comments are indented by `c-indent-line' according to |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2384 `antlr-indent-comment'. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2385 |
49554 | 2386 Lines in actions except top-level actions in a header part or an option |
2387 area are indented by `c-indent-line'. | |
2388 | |
2389 Lines in header actions are indented at column 0 if `antlr-language' | |
2390 equals to a key in `antlr-indent-at-bol-alist' and the line starting at | |
2391 the first non-whitespace is matched by the corresponding value. | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2392 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2393 For the initialization of `c-basic-offset', see `antlr-indent-style' and, |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2394 to a lesser extent, `antlr-tab-offset-alist'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2395 (save-restriction |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2396 (let ((orig (point)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2397 (min0 (point-min)) |
49554 | 2398 bol boi indent syntax cc-syntax) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2399 (widen) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2400 (beginning-of-line) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2401 (setq bol (point)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2402 (if (< bol min0) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2403 (error "Beginning of current line not visible")) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2404 (skip-chars-forward " \t") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2405 (setq boi (point)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2406 ;; check syntax at beginning of indentation ---------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2407 (antlr-with-syntax-table antlr-action-syntax-table |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
2408 (antlr-invalidate-context-cache) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2409 (setq syntax (antlr-syntactic-context)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2410 (cond ((symbolp syntax) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2411 (setq indent nil)) ; block-comments, strings, (comments) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2412 ((progn |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2413 (antlr-next-rule -1 t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2414 (if (antlr-search-forward ":") (< boi (1- (point))) t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2415 (setq indent 0)) ; in rule header |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2416 ((if (antlr-search-forward ";") (< boi (point)) t) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2417 (setq indent 2)) ; in rule body |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2418 (t |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2419 (forward-char) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2420 (antlr-skip-exception-part nil) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2421 (setq indent (if (> (point) boi) 1 0))))) ; in exception part? |
49554 | 2422 ;; check whether to use indentation engine of cc-mode ------------------ |
2423 (antlr-invalidate-context-cache) | |
2424 (goto-char boi) | |
2425 (when (and indent (> syntax 0)) | |
2426 (cond ((> syntax 1) ; block in action => use cc-mode | |
2427 (setq indent nil)) | |
2428 ((and (= indent 0) | |
2429 (assq antlr-language antlr-indent-at-bol-alist) | |
2430 (looking-at (cdr (assq antlr-language | |
2431 antlr-indent-at-bol-alist)))) | |
2432 (setq syntax 'bol)) | |
2433 ((setq cc-syntax (c-guess-basic-syntax)) | |
2434 (let ((cc cc-syntax) symbol) | |
2435 (while (setq symbol (pop cc)) | |
2436 (when (cdr symbol) | |
2437 (or (memq (car symbol) | |
2438 antlr-disabling-cc-syntactic-symbols) | |
2439 (setq indent nil)) | |
2440 (setq cc nil))))))) | |
2441 ;;; ((= indent 1) ; exception part => use cc-mode | |
2442 ;;; (setq indent nil)) | |
2443 ;;; ((save-restriction ; not in option part => cc-mode | |
2444 ;;; (goto-char (scan-lists (point) -1 1)) | |
2445 ;;; (skip-chars-backward " \t\n") | |
2446 ;;; (narrow-to-region (point-min) (point)) | |
2447 ;;; (not (re-search-backward "\\<options\\'" nil t))) | |
2448 ;;; (setq indent nil))))) | |
2449 ;; compute the corresponding indentation and indent -------------------- | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2450 (if (null indent) |
49554 | 2451 ;; Use the indentation engine of cc-mode |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2452 (progn |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2453 (goto-char orig) |
49554 | 2454 (if (or (numberp syntax) |
2455 (if (eq syntax 'string) nil (eq antlr-indent-comment t))) | |
2456 (c-indent-line cc-syntax))) | |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2457 ;; do it ourselves |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2458 (goto-char boi) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2459 (unless (symbolp syntax) ; direct indentation |
49554 | 2460 ;;(antlr-invalidate-context-cache) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2461 (incf indent (antlr-syntactic-context)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2462 (and (> indent 0) (looking-at antlr-indent-item-regexp) (decf indent)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2463 (setq indent (* indent c-basic-offset))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2464 ;; the usual major-mode indent stuff --------------------------------- |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2465 (setq orig (- (point-max) orig)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2466 (unless (= (current-column) indent) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2467 (delete-region bol boi) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2468 (beginning-of-line) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2469 (indent-to indent)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2470 ;; If initial point was within line's indentation, |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2471 ;; position after the indentation. Else stay at same point in text. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2472 (if (> (- (point-max) orig) (point)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2473 (goto-char (- (point-max) orig))))))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2474 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2475 (defun antlr-indent-command (&optional arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2476 "Indent the current line or insert tabs/spaces. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2477 With optional prefix argument ARG or if the previous command was this |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2478 command, insert ARG tabs or spaces according to `indent-tabs-mode'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2479 Otherwise, indent the current line with `antlr-indent-line'." |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2480 (interactive "*P") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2481 (if (or arg (eq last-command 'antlr-indent-command)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2482 (insert-tab arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2483 (let ((antlr-indent-comment (and antlr-indent-comment t))) ; dynamic |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2484 (antlr-indent-line)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2485 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2486 (defun antlr-electric-character (&optional arg) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2487 "Insert the character you type and indent the current line. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2488 Insert the character like `self-insert-command' and indent the current |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2489 line as `antlr-indent-command' does. Do not indent the line if |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2490 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2491 * this command is called with a prefix argument ARG, |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2492 * there are characters except whitespaces between point and the |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2493 beginning of the line, or |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2494 * point is not inside a normal grammar code, { and } are also OK in |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2495 actions. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2496 |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2497 This command is useful for a character which has some special meaning in |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2498 ANTLR's syntax and influences the auto indentation, see |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2499 `antlr-indent-item-regexp'." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2500 (interactive "*P") |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2501 (if (or arg |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2502 (save-excursion (skip-chars-backward " \t") (not (bolp))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2503 (antlr-with-syntax-table antlr-action-syntax-table |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2504 (antlr-invalidate-context-cache) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2505 (let ((context (antlr-syntactic-context))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2506 (not (and (numberp context) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2507 (or (zerop context) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2508 (memq last-command-char '(?\{ ?\})))))))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2509 (self-insert-command (prefix-numeric-value arg)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2510 (self-insert-command (prefix-numeric-value arg)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2511 (antlr-indent-line))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2512 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2513 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2514 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2515 ;;; Mode entry |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2516 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2517 |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2518 (defun antlr-c-init-language-vars () |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2519 "Like `c-init-language-vars-for' when using cc-mode before v5.29." |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2520 (let ((settings ; (cdr '(setq...)) will be optimized |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2521 (if (eq antlr-language 'c++-mode) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2522 (cdr '(setq ;' from `c++-mode' v5.20, v5.28 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2523 c-keywords (c-identifier-re c-C++-keywords) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2524 c-conditional-key c-C++-conditional-key |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2525 c-comment-start-regexp c-C++-comment-start-regexp |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2526 c-class-key c-C++-class-key |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2527 c-extra-toplevel-key c-C++-extra-toplevel-key |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2528 c-access-key c-C++-access-key |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2529 c-recognize-knr-p nil |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2530 c-bitfield-key c-C-bitfield-key ; v5.28 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2531 )) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2532 (cdr '(setq ; from `java-mode' v5.20, v5.28 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2533 c-keywords (c-identifier-re c-Java-keywords) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2534 c-conditional-key c-Java-conditional-key |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2535 c-comment-start-regexp c-Java-comment-start-regexp |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2536 c-class-key c-Java-class-key |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2537 c-method-key nil |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2538 c-baseclass-key nil |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2539 c-recognize-knr-p nil |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2540 c-access-key c-Java-access-key ; v5.20 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2541 c-inexpr-class-key c-Java-inexpr-class-key ; v5.28 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2542 ))))) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2543 (while settings |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2544 (when (boundp (car settings)) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2545 (ignore-errors |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2546 (set (car settings) (eval (cadr settings))))) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2547 (setq settings (cddr settings))))) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2548 |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2549 (defun antlr-language-option (search) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2550 "Find language in `antlr-language-alist' for language option. |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2551 If SEARCH is non-nil, find element for language option. Otherwise, find |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2552 the default language." |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2553 (let ((value (and search |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2554 (save-excursion |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2555 (goto-char (point-min)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2556 (re-search-forward (cdr antlr-language-limit-n-regexp) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2557 (car antlr-language-limit-n-regexp) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2558 t)) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2559 (match-string 1))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2560 (seq antlr-language-alist) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2561 r) |
49554 | 2562 ;; Like (find VALUE antlr-language-alist :key 'cddr :test 'member) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2563 (while seq |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2564 (setq r (pop seq)) |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2565 (if (member value (cddr r)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2566 (setq seq nil) ; stop |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2567 (setq r nil))) ; no result yet |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2568 (car r))) |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2569 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2570 ;;;###autoload |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2571 (defun antlr-mode () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2572 "Major mode for editing ANTLR grammar files. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2573 \\{antlr-mode-map}" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2574 (interactive) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2575 (kill-all-local-variables) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2576 (c-initialize-cc-mode) ; cc-mode is required |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2577 (unless (fboundp 'c-forward-sws) ; see above |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2578 (fset 'antlr-c-forward-sws 'c-forward-syntactic-ws)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2579 ;; ANTLR specific ---------------------------------------------------------- |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2580 (setq major-mode 'antlr-mode |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2581 mode-name "Antlr") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2582 (setq local-abbrev-table antlr-mode-abbrev-table) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2583 (unless antlr-mode-syntax-table |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2584 (setq antlr-mode-syntax-table (make-syntax-table)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2585 (c-populate-syntax-table antlr-mode-syntax-table)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2586 (set-syntax-table antlr-mode-syntax-table) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2587 (unless antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2588 (let ((slist (nth 3 antlr-font-lock-defaults))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2589 (setq antlr-action-syntax-table |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2590 (copy-syntax-table antlr-mode-syntax-table)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2591 (while slist |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2592 (modify-syntax-entry (caar slist) (cdar slist) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2593 antlr-action-syntax-table) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2594 (setq slist (cdr slist))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2595 (use-local-map antlr-mode-map) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2596 (make-local-variable 'antlr-language) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2597 (unless antlr-language |
42249
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2598 (setq antlr-language |
50adfc6e47b2
More sophisticated indentation of cpp directive.
Richard M. Stallman <rms@gnu.org>
parents:
41802
diff
changeset
|
2599 (or (antlr-language-option t) (antlr-language-option nil)))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2600 (if (stringp (cadr (assq antlr-language antlr-language-alist))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2601 (setq mode-name |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
2602 (concat "Antlr." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2603 (cadr (assq antlr-language antlr-language-alist))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2604 ;; indentation, for the C engine ------------------------------------------- |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2605 (setq c-buffer-is-cc-mode antlr-language) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2606 (cond ((fboundp 'c-init-language-vars-for) ; cc-mode 5.30.5+ |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2607 (c-init-language-vars-for antlr-language)) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2608 ((fboundp 'c-init-c-language-vars) ; cc-mode 5.30 to 5.30.4 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2609 (c-init-c-language-vars) ; not perfect, but OK |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2610 (setq c-recognize-knr-p nil)) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2611 ((fboundp 'c-init-language-vars) ; cc-mode 5.29 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2612 (let ((init-fn 'c-init-language-vars)) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2613 (funcall init-fn))) ; is a function in v5.29 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2614 (t ; cc-mode upto 5.28 |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2615 (antlr-c-init-language-vars))) ; do it myself |
59238
a7774e900abe
(antlr-mode): Use mode-require-final-newline.
Richard M. Stallman <rms@gnu.org>
parents:
53418
diff
changeset
|
2616 (c-basic-common-init antlr-language (or antlr-indent-style "gnu")) |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2617 (make-local-variable 'outline-regexp) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2618 (make-local-variable 'outline-level) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2619 (make-local-variable 'require-final-newline) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2620 (make-local-variable 'indent-line-function) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2621 (make-local-variable 'indent-region-function) |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2622 (setq outline-regexp "[^#\n\^M]" |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2623 outline-level 'c-outline-level) ; TODO: define own |
59238
a7774e900abe
(antlr-mode): Use mode-require-final-newline.
Richard M. Stallman <rms@gnu.org>
parents:
53418
diff
changeset
|
2624 (setq require-final-newline mode-require-final-newline) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2625 (setq indent-line-function 'antlr-indent-line |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2626 indent-region-function nil) ; too lazy |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2627 (setq comment-start "// " |
52890
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2628 comment-end "" |
51328ad3b6be
Make major mode work with cc-mode-5.30+.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
2629 comment-start-skip "/\\*+ *\\|// *") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2630 ;; various ----------------------------------------------------------------- |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2631 (make-local-variable 'font-lock-defaults) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2632 (setq font-lock-defaults antlr-font-lock-defaults) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2633 (easy-menu-add antlr-mode-menu) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2634 (make-local-variable 'imenu-create-index-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2635 (setq imenu-create-index-function 'antlr-imenu-create-index-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2636 (make-local-variable 'imenu-generic-expression) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2637 (setq imenu-generic-expression t) ; fool stupid test |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2638 (and antlr-imenu-name ; there should be a global variable... |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2639 (fboundp 'imenu-add-to-menubar) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2640 (imenu-add-to-menubar |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2641 (if (stringp antlr-imenu-name) antlr-imenu-name "Index"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2642 (antlr-set-tabs) |
62772
f2892faa87d4
* progmodes/ada-mode.el (ada-mode):
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
2643 (run-mode-hooks 'antlr-mode-hook)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2644 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2645 ;; A smarter version of `group-buffers-menu-by-mode-then-alphabetically' (in |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2646 ;; XEmacs) could use the following property. The header of the submenu would |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
2647 ;; be "Antlr" instead of "Antlr.C++" or (not and!) "Antlr.Java". |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
2648 (put 'antlr-mode 'mode-name "Antlr") |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
2649 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2650 ;;;###autoload |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2651 (defun antlr-set-tabs () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2652 "Use ANTLR's convention for TABs according to `antlr-tab-offset-alist'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2653 Used in `antlr-mode'. Also a useful function in `java-mode-hook'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2654 (if buffer-file-name |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2655 (let ((alist antlr-tab-offset-alist) elem) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2656 (while alist |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2657 (setq elem (pop alist)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2658 (and (or (null (car elem)) (eq (car elem) major-mode)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2659 (or (null (cadr elem)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2660 (string-match (cadr elem) buffer-file-name)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2661 (setq tab-width (caddr elem) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2662 indent-tabs-mode (cadddr elem) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2663 alist nil)))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2664 |
49554 | 2665 ;;; Local IspellPersDict: .ispell_antlr |
52401 | 2666 |
2667 ;;; arch-tag: 5de2be79-3d13-4560-8fbc-f7d0234dcb5c | |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38100
diff
changeset
|
2668 ;;; antlr-mode.el ends here |