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