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