Mercurial > emacs
annotate lisp/progmodes/antlr-mode.el @ 40072:22a7c39a8c32
(syms_of_eval): Doc fixes.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 19 Oct 2001 23:33:55 +0000 |
parents | 113b18d8a765 |
children | c4946eb1e1e8 |
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 |
38100
c18732fcfbab
(antlr-mode): Check that `c-Java-access-key' is
Gerd Moellmann <gerd@gnu.org>
parents:
34011
diff
changeset
|
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 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
7 ;; Version: 1.4 |
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 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
29 ;; Major mode for editing ANTLR grammar files, i.e., files ending with `.g'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
30 ;; ANTLR is ANother Tool for Language Recognition (an excellent alternative to |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
31 ;; lex/yacc), see <http://www.ANTLR.org> and <news:comp.compilers.tools.pccts>. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
32 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
33 ;; This package provides the following features: |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
34 ;; * Syntax coloring (via font-lock) for grammar symbols and the code in |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
35 ;; actions. The latter depends on the language settings. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
36 ;; * Indentation for the current line (TAB) and selected region (C-M-\). |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
37 ;; * Support for imenu/speedbar: menu "Index" (Parser, Lexer, TreeParser). |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
38 ;; * Commands to move to previous/next rule, beginning/end of rule body etc. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
39 ;; * Commands to hide/unhide actions, upcase/downcase literals. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
40 ;; * Run ANTLR from within Emacs, create Makefile dependencies. |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
41 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
42 ;; LANGUAGE SETTINGS. This mode needs to know which language is used in |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
43 ;; actions and semantic predicated of the grammar. This information is used |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
44 ;; for syntax coloring and the creation of the Makefile dependencies. It is |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
45 ;; stored in variable `antlr-language' and automatically set according to |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
46 ;; ANTLR's file option "language", see `antlr-language-alist'. The supported |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
47 ;; languages are "Java" (java-mode) and "Cpp" (c++-mode). |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
48 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
49 ;; INDENTATION. This package supports ANTLR's (intended) indentation style |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
50 ;; 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
|
51 ;; `antlr-indent-line'. The indentation engine of cc-mode is only used inside |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
52 ;; block comments (it is not easy to use it for actions, esp if they come early |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
53 ;; in the rule body). By default, this package defines a tab width of 4 to be |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
54 ;; 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
|
55 ;; `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
|
56 ;; `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
|
57 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
58 ;; SYNTAX COLORING comes in three phases. First, comments and strings are |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
59 ;; highlighted. Second, the grammar code is highlighted according to |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
60 ;; `antlr-font-lock-additional-keywords' (rule refs: dark blue, token refs: |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
61 ;; dark orange, definition: bold blue). Third, actions, semantic predicates |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
62 ;; and arguments are highlighted according to the usual font-lock keywords of |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
63 ;; `antlr-language', see also `antlr-font-lock-maximum-decoration'. We define |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
64 ;; special font-lock faces for the grammar code to allow you to distinguish |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
65 ;; ANTLR keywords from Java/C++ keywords. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
66 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
67 ;; 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
|
68 ;; dependencies for all grammar files in the current directory. It considers |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
69 ;; import/export vocabularies and grammar inheritance and provides a value for |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
70 ;; the -glib option if necessary (which you have to edit if the super-grammar |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
71 ;; is not in the same directory). |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
72 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
73 ;; TODO. Support to insert/change file/grammar/rule/subrule options. imenu |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
74 ;; support for method definitions in actions is not really planned (you can |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
75 ;; send be a patch, though). This mode would become too dependent on cc-mode |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
76 ;; or I would have to do a lot of language-dependent things myself... |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
77 |
26965 | 78 ;; Bug fixes, bug reports, improvements, and suggestions are strongly |
79 ;; appreciated. Please check the newest version first: | |
80 ;; http://www.fmi.uni-passau.de/~wedler/antlr-mode/changes.html | |
81 | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
82 ;;; Installation: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
83 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
84 ;; 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
|
85 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
86 ;; 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
|
87 ;; load-path and the following into your ~/.emacs: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
88 ;; (autoload 'antlr-mode "antlr-mode" nil t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
89 ;; (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
|
90 ;; (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
|
91 ;; (lambda () (speedbar-add-supported-extension ".g"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
92 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
93 ;; 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
|
94 ;; (autoload 'antlr-set-tabs "antlr-mode") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
95 ;; (add-hook 'java-mode-hook 'antlr-set-tabs) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
96 |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
97 ;; 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
|
98 ;; 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
|
99 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
100 ;; To customize, use `M-x customize-group RET antlr RET' or the custom browser |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
101 ;; (Emacs->Programming->Languages->Antlr). |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
102 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
103 ;;; Code: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
104 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
105 (provide 'antlr-mode) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
106 (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
|
107 (require 'cc-mode) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
108 (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
|
109 (defvar imenu-create-index-function)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
110 (eval-when-compile ; Emacs: cl, easymenu |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
111 (require 'cl) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
112 (require 'easymenu)) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
113 (eval-when-compile ; XEmacs: Emacs vars |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
114 (defvar inhibit-point-motion-hooks) (defvar deactivate-mark)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
115 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
116 (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
|
117 (if (featurep 'xemacs) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
118 (defalias 'antlr-scan-sexps 'scan-sexps) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
119 (defalias 'antlr-scan-sexps 'antlr-scan-sexps-internal)) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
120 (if (fboundp 'default-directory) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
121 (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
|
122 (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
|
123 (if (fboundp 'read-shell-command) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
124 (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
|
125 (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
|
126 (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
|
127 (or history 'shell-command-history)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
128 (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
|
129 (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
|
130 (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
|
131 (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
|
132 (save-excursion (funcall thunk))))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
133 (if (and (fboundp 'buffer-syntactic-context) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
134 (fboundp 'buffer-syntactic-context-depth)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
135 (progn |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
136 (defalias 'antlr-invalidate-context-cache 'antlr-xemacs-bug-workaround) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
137 (defalias 'antlr-syntactic-context 'antlr-fast-syntactic-context)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
138 (defalias 'antlr-invalidate-context-cache 'ignore) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
139 (defalias 'antlr-syntactic-context 'antlr-slow-syntactic-context))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
140 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
141 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
142 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
143 ;;;;########################################################################## |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
144 ;;;; Variables |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
145 ;;;;########################################################################## |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
146 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
147 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
148 (defgroup antlr nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
149 "Major mode for ANTLR grammar files." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
150 :group 'languages |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
151 :link '(emacs-commentary-link "antlr-mode.el") |
26965 | 152 :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
|
153 :prefix "antlr-") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
154 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
155 (defconst antlr-version "1.4" |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
156 "ANTLR major mode version number.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
157 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
158 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
159 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
160 ;;; Controlling ANTLR's code generator (language option) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
161 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
162 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
163 (defvar antlr-language nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
164 "Major mode corresponding to ANTLR's \"language\" option. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
165 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
|
166 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
|
167 variable list\" near the end of the file, see |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
168 `enable-local-variables'.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
169 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
170 (defcustom antlr-language-alist |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
171 '((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
|
172 (c++-mode "C++" "\"Cpp\"" "Cpp")) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
173 "List of ANTLR's supported languages. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
174 Each element in this list looks like |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
175 (MAJOR-MODE MODELINE-STRING OPTION-VALUE...) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
176 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
177 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
|
178 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
|
179 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
|
180 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
|
181 also displayed in the modeline next to \"Antlr\"." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
182 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
183 :type '(repeat (group :value (java-mode "") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
184 (function :tag "Major mode") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
185 (string :tag "Modeline string") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
186 (repeat :tag "ANTLR language option" :inline t |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
187 (choice (const :tag "Default" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
188 string ))))) |
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 (defcustom antlr-language-limit-n-regexp |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
191 '(3000 . "language[ \t]*=[ \t]*\\(\"?[A-Z][A-Za-z_]*\"?\\)") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
192 "Used to set a reasonable value for `antlr-language'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
193 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
|
194 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
|
195 the language according to `antlr-language-alist'." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
196 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
197 :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
|
198 regexp)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
199 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
200 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
201 ;;;=========================================================================== |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
202 ;;; Hide/Unhide, Indent/Tabs |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
203 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
204 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
205 (defcustom antlr-action-visibility 3 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
206 "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
|
207 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
|
208 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
|
209 greater than this number." |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
210 :group 'antlr |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
211 :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
|
212 (integer :tag "Hidden if longer than" :value 3))) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
213 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
214 (defcustom antlr-indent-comment 'tab |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
215 "*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
|
216 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
|
217 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
|
218 they are only changed by \\[antlr-indent-command]." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
219 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
220 :type '(radio (const :tag "No" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
221 (const :tag "Always" t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
222 (sexp :tag "With TAB" :format "%t" :value tab))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
223 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
224 (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
|
225 '((antlr-mode nil 4 nil) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
226 (java-mode "antlr" 4 nil)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
227 "Alist to determine whether to use ANTLR's convention for TABs. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
228 Each element looks like (MAJOR-MODE REGEXP TAB-WIDTH INDENT-TABS-MODE). |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
229 The first element whose MAJOR-MODE is nil or equal to `major-mode' and |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
230 whose REGEXP is nil or matches `buffer-file-name' is used to set |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
231 `tab-width' and `indent-tabs-mode'. This is useful to support both |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
232 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
|
233 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
234 :type '(repeat (group :value (antlr-mode nil 8 nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
235 (choice (const :tag "All" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
236 (function :tag "Major mode")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
237 (choice (const :tag "All" nil) regexp) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
238 (integer :tag "Tab width") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
239 (boolean :tag "Indent-tabs-mode")))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
240 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
241 (defvar antlr-indent-item-regexp |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
242 "[]}):;|&]\\|default[ \t]*:\\|case[ \t]+\\('\\\\?.'\\|[0-9]+\\|[A-Za-z_][A-Za-z_0-9]*\\)[ \t]*:" ; & is local ANTLR extension |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
243 "Regexp matching lines which should be indented by one TAB less. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
244 See command \\[antlr-indent-command].") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
245 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
246 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
247 ;;;=========================================================================== |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
248 ;;; Run tool, create Makefile dependencies |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
249 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
250 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
251 (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
|
252 "*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
|
253 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
|
254 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
|
255 :group 'antlr |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
256 :type 'string) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
257 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
258 (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
|
259 "*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
|
260 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
|
261 :group 'antlr |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
262 :type 'boolean) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
263 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
264 (defcustom antlr-makefile-specification |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
265 '("\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
|
266 "*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
|
267 This variable influences the output of \\[antlr-show-makefile-rules]. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
268 It looks like (RULE-SEP GEN-VAR-SPEC COMMAND). |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
269 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
270 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
|
271 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
|
272 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
|
273 if necessary. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
274 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
275 If GEN-VAR-SPEC is nil, each target directly consists of a list of |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
276 files. If GEN-VAR-SPEC looks like (GEN-VAR GEN-VAR-FORMAT GEN-SEP), a |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
277 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
|
278 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 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
|
283 :group 'antlr |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
284 :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
|
285 (choice |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
286 (const :tag "Direct targets" nil) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
287 (list :tag "Variables for targets" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
288 (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
|
289 (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
|
290 (string :tag "Variable separator"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
291 (string :tag "ANTLR command"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
292 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
293 (defvar antlr-file-formats-alist |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
294 '((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
|
295 (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
|
296 "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
|
297 Each element in this list looks looks like |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
298 (MAJOR-MODE (VOCAB-FILE-FORMAT...) (CLASS-FILE-FORMAT...)). |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
299 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
300 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
|
301 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
|
302 `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
|
303 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
304 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
|
305 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
|
306 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
|
307 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
|
308 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
309 (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
|
310 "Language independent formats which specify generated files. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
311 The value looks like (VOCAB-FILE-FORMAT EXPANDED-GRAMMAR-FORMAT). |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
312 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
320 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
|
321 formats.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
322 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
323 (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
|
324 "*Formats which specify the names of unknown files. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
325 The value looks like (SUPER-GRAMMAR-FILE-FORMAT SUPER-EVOCAB-FORMAT). |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
326 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
327 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
|
328 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
|
329 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
|
330 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
|
331 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
|
332 of above mentioned class SUPER.") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
333 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
334 (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
|
335 "## 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
|
336 ## \"?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
|
337 ## 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
|
338 ## 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
|
339 ## 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
|
340 "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
|
341 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
|
342 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
343 (defvar antlr-help-rules-intro |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
344 "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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 "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
|
350 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
|
351 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
|
352 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
353 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
354 ;;;=========================================================================== |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
355 ;;; Menu |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
356 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
357 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
358 (defcustom antlr-imenu-name t |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
359 "*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
|
360 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
|
361 imenu." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
362 :group 'antlr |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
363 :type '(choice (const :tag "No menu" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
364 (const :tag "Index menu" t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
365 (string :tag "Other menu name"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
366 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
367 (defvar antlr-mode-map |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
368 (let ((map (make-sparse-keymap))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
369 (define-key map "\t" 'antlr-indent-command) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
370 (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
|
371 (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
|
372 (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
|
373 (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
|
374 (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
|
375 (define-key map "\C-c\C-b" 'c-backward-into-nomenclature) |
26965 | 376 (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
|
377 (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
|
378 (define-key map "\C-c\C-r" 'antlr-run-tool) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
379 ;; I'm too lazy to define my own: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
380 (define-key map "\ea" 'c-beginning-of-statement) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
381 (define-key map "\ee" 'c-end-of-statement) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
382 map) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
383 "Keymap used in `antlr-mode' buffers.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
384 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
385 (easy-menu-define antlr-mode-menu |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
386 antlr-mode-map |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
387 "Major mode menu." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
388 '("Antlr" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
389 ["Indent Line" antlr-indent-command |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
390 :active (not buffer-read-only)] |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
391 ["Indent for Comment" indent-for-comment |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
392 :active (not buffer-read-only)] |
26965 | 393 ["Comment Out Region" comment-region |
394 :active (and (not buffer-read-only) | |
395 (c-region-is-active-p))] | |
396 ["Uncomment Region" | |
397 (comment-region (region-beginning) (region-end) '(4)) | |
398 :active (and (not buffer-read-only) | |
399 (c-region-is-active-p))] | |
400 "---" | |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
401 ["Backward Rule" antlr-beginning-of-rule t] |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
402 ["Forward Rule" antlr-end-of-rule t] |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
403 ["Start of Rule Body" antlr-beginning-of-body |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
404 :active (antlr-inside-rule-p)] |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
405 ["End of Rule Body" antlr-end-of-body |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
406 :active (antlr-inside-rule-p)] |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
407 "---" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
408 ["Backward Statement" c-beginning-of-statement t] |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
409 ["Forward Statement" c-end-of-statement t] |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
410 ["Backward Into Nomencl." c-backward-into-nomenclature t] |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
411 ["Forward Into Nomencl." c-forward-into-nomenclature t] |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
412 "---" |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
413 ["Hide Actions (incl. Args)" antlr-hide-actions t] |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
414 ["Hide Actions (excl. Args)" (antlr-hide-actions 2) t] |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
415 ["Unhide All Actions" (antlr-hide-actions 0) t] |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
416 "---" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
417 ["Run Tool on Grammar" antlr-run-tool t] |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
418 ["Show Makefile Rules" antlr-show-makefile-rules t])) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
419 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
420 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
421 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
422 ;;; font-lock |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
423 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
424 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
425 (defcustom antlr-font-lock-maximum-decoration 'inherit |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
426 "*The maximum decoration level for fontifying actions. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
427 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
|
428 according to `antlr-font-lock-additional-keywords'. Value `inherit' |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
429 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
|
430 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
|
431 fontification, see `antlr-font-lock-keywords-alist'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
432 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
433 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
|
434 bound to `antlr-language'. For example, with value |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
435 ((java-mode . 2) (c++-mode . 0)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
436 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
|
437 fontified at all." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
438 :type '(choice (const :tag "none" none) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
439 (const :tag "inherit" inherit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
440 (const :tag "default" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
441 (const :tag "maximum" t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
442 (integer :tag "level" 1) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
443 (repeat :menu-tag "mode specific" :tag "mode specific" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
444 :value ((t . t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
445 (cons :tag "Instance" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
446 (radio :tag "Mode" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
447 (const :tag "all" t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
448 (symbol :tag "name")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
449 (radio :tag "Decoration" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
450 (const :tag "default" nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
451 (const :tag "maximum" t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
452 (integer :tag "level" 1)))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
453 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
454 (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
|
455 ;; 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
|
456 ;; `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
|
457 ;; would break Emacs-21.0: |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
458 "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
|
459 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
|
460 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
461 (defvar antlr-font-lock-keywords-alist |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
462 '((java-mode |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
463 antlr-no-action-keywords |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
464 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
|
465 java-font-lock-keywords-3) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
466 (c++-mode |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
467 antlr-no-action-keywords |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
468 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
|
469 c++-font-lock-keywords-3)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
470 "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
|
471 Each element in this list looks like |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
472 (MAJOR-MODE KEYWORD...) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
473 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
474 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
|
475 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
|
476 in the grammar's actions and semantic predicates, see |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
477 `antlr-font-lock-maximum-decoration'.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
478 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
479 (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
|
480 (defface antlr-font-lock-keyword-face |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
481 '((((class color) (background light)) (:foreground "black" :bold t))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
482 "ANTLR keywords." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
483 :group 'antlr) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
484 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
485 (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
|
486 (defface antlr-font-lock-ruledef-face |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
487 '((((class color) (background light)) (:foreground "blue" :bold t))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
488 "ANTLR rule references (definition)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
489 :group 'antlr) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
490 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
491 (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
|
492 (defface antlr-font-lock-tokendef-face |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
493 '((((class color) (background light)) (:foreground "blue" :bold t))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
494 "ANTLR token references (definition)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
495 :group 'antlr) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
496 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
497 (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
|
498 (defface antlr-font-lock-ruleref-face |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
499 '((((class color) (background light)) (:foreground "blue4"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
500 "ANTLR rule references (usage)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
501 :group 'antlr) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
502 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
503 (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
|
504 (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
|
505 '((((class color) (background light)) (:foreground "orange4"))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
506 "ANTLR token references (usage)." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
507 :group 'antlr) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
508 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
509 (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
|
510 (defface antlr-font-lock-literal-face |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
511 '((((class color) (background light)) (:foreground "brown4" :bold t))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
512 "ANTLR literal tokens consisting merely of letter-like characters." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
513 :group 'antlr) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
514 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
515 (defvar antlr-font-lock-additional-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
516 `((antlr-invalidate-context-cache) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
517 ("\\$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
|
518 (1 antlr-font-lock-tokendef-face)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
519 ("\\$\\sw+" (0 font-lock-keyword-face)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
520 ;; the tokens are already fontified as string/docstrings: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
521 (,(lambda (limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
522 (antlr-re-search-forward "\"\\(\\sw\\(\\sw\\|-\\)*\\)\"" limit)) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
523 (1 antlr-font-lock-literal-face t) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
524 ,@(and (string-match "XEmacs" emacs-version) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
525 '((0 nil)))) ; XEmacs bug workaround |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
526 (,(lambda (limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
527 (antlr-re-search-forward |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
528 "^\\(class\\)[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]+\\(extends\\)[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]*;" limit)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
529 (1 antlr-font-lock-keyword-face) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
530 (2 antlr-font-lock-ruledef-face) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
531 (3 antlr-font-lock-keyword-face) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
532 (4 (if (member (match-string 4) '("Lexer" "Parser" "TreeParser")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
533 'antlr-font-lock-keyword-face |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
534 'font-lock-type-face))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
535 (,(lambda (limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
536 (antlr-re-search-forward |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
537 "\\<\\(header\\|options\\|tokens\\|exception\\|catch\\|returns\\)\\>" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
538 limit)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
539 (1 antlr-font-lock-keyword-face)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
540 (,(lambda (limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
541 (antlr-re-search-forward |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
542 "^\\(private\\|public\\|protected\\)\\>\\([ \t]+\\(\\sw+\\)\\)?" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
543 limit)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
544 (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
|
545 (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
|
546 'antlr-font-lock-tokendef-face |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
547 'antlr-font-lock-ruledef-face) nil t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
548 (,(lambda (limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
549 (antlr-re-search-forward "^\\sw+" limit)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
550 (0 (if (antlr-upcase-p (char-after (match-beginning 0))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
551 'antlr-font-lock-tokendef-face |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
552 'antlr-font-lock-ruledef-face) nil t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
553 (,(lambda (limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
554 ;; not only before a rule ref, also before a literal |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
555 (antlr-re-search-forward "\\<\\(\\sw+\\)[ \t]*:" limit)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
556 (1 font-lock-variable-name-face)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
557 (,(lambda (limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
558 (antlr-re-search-forward "\\<\\(\\sw+[ \t]*=[ \t]*\\)?\\(\\sw+[ \t]*:[ \t]*\\)?\\(\\sw+\\)" limit)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
559 ;;(1 antlr-font-lock-default-face nil t) ; fool java-font-lock-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
560 (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
|
561 'antlr-font-lock-tokenref-face |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
562 'antlr-font-lock-ruleref-face)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
563 "Font-lock keywords for ANTLR's normal grammar code. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
564 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
|
565 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
566 (defvar antlr-font-lock-defaults |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
567 '(antlr-font-lock-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
568 nil nil ((?_ . "w") (?\( . ".") (?\) . ".")) beginning-of-defun) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
569 "Font-lock defaults used for ANTLR syntax coloring. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
570 The SYNTAX-ALIST element is also used to initialize |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
571 `antlr-action-syntax-table'.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
572 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
573 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
574 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
575 ;;; Internal variables |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
576 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
577 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
578 (defvar antlr-mode-hook nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
579 "Hook called by `antlr-mode'.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
580 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
581 (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
|
582 "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
|
583 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
|
584 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
585 ;; used for "in Java/C++ code" = syntactic-depth>0 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
586 (defvar antlr-action-syntax-table nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
587 "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
|
588 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
|
589 `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
|
590 `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
|
591 not to confuse their context_cache.") |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
592 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
593 (defvar antlr-mode-abbrev-table nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
594 "Abbreviation table used in `antlr-mode' buffers.") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
595 (define-abbrev-table 'antlr-mode-abbrev-table ()) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
596 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
597 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
598 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
599 ;;;;########################################################################## |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
600 ;;;; The Code |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
601 ;;;;########################################################################## |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
602 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
603 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
604 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
605 ;;; Syntax functions -- Emacs vs XEmacs dependent |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
606 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
607 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
608 ;; 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
|
609 (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
|
610 "Evaluate BODY with the syntax table SYNTAB." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
611 `(let ((stab (syntax-table))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
612 (unwind-protect |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
613 (progn (set-syntax-table ,syntab) ,@body) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
614 (set-syntax-table stab)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
615 (put 'antlr-with-syntax-table 'lisp-indent-function 1) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
616 (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
|
617 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
618 (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
|
619 ;; checkdoc-params: (from count dummy) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
620 "Like `scan-sexps' but with additional arguments. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
621 When optional arg NO-ERROR is non-nil, `scan-sexps' will return nil |
26965 | 622 instead of signaling an error." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
623 (if no-error |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
624 (condition-case nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
625 (scan-sexps from count) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
626 (t nil)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
627 (scan-sexps from count))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
628 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
629 (defun antlr-xemacs-bug-workaround (&rest dummies) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
630 ;; checkdoc-params: (dummies) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
631 "Invalidate context_cache for syntactical context information." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
632 ;; XEmacs bug workaround |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
633 (save-excursion |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
634 (set-buffer (get-buffer-create " ANTLR XEmacs bug workaround")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
635 (buffer-syntactic-context-depth)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
636 nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
637 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
638 (defun antlr-fast-syntactic-context () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
639 "Return some syntactic context information. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
640 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
|
641 `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
|
642 parenthesis-syntax delimiters at point otherwise. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
643 WARNING: this may alter `match-data'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
644 (or (buffer-syntactic-context) (buffer-syntactic-context-depth))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
645 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
646 (defun antlr-slow-syntactic-context () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
647 "Return some syntactic context information. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
648 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
|
649 `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
|
650 parenthesis-syntax delimiters at point otherwise. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
651 WARNING: this may alter `match-data'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
652 (let ((orig (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
653 (beginning-of-defun) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
654 (let ((state (parse-partial-sexp (point) orig))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
655 (goto-char orig) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
656 (cond ((nth 3 state) 'string) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
657 ((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
|
658 (t (car state)))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
659 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
660 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
661 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
662 ;;; Misc functions |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
663 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
664 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
665 (defun antlr-upcase-p (char) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
666 "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
|
667 ;; in XEmacs, upcase only works for ASCII |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
668 (or (and (<= ?A char) (<= char ?Z)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
669 (and (<= ?\300 char) (<= char ?\337)))) ; ?\327 is no letter |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
670 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
671 (defun antlr-re-search-forward (regexp bound) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
672 "Search forward from point for regular expression REGEXP. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
673 Set point to the end of the occurrence found, and return point. Return |
26965 | 674 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
|
675 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
|
676 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
|
677 and `replace-match'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
678 ;; 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
|
679 (let ((continue t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
680 (while (and (re-search-forward regexp bound 'limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
681 (save-match-data |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
682 (if (eq (antlr-syntactic-context) 0) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
683 (setq continue nil) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
684 t)))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
685 (if continue nil (point)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
686 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
687 (defun antlr-search-forward (string) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
688 "Search forward from point for STRING. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
689 Set point to the end of the occurrence found, and return point. Return |
26965 | 690 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
|
691 and actions/semantic predicates." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
692 ;; 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
|
693 (let ((continue t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
694 (while (and (search-forward string nil 'limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
695 (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
|
696 (if continue nil (point)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
697 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
698 (defun antlr-search-backward (string) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
699 "Search backward from point for STRING. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
700 Set point to the beginning of the occurrence found, and return point. |
26965 | 701 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
|
702 strings and actions/semantic predicates." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
703 ;; 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
|
704 (let ((continue t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
705 (while (and (search-backward string nil 'limit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
706 (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
|
707 (if continue nil (point)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
708 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
709 (defsubst antlr-skip-sexps (count) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
710 "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
|
711 Return position before the comments after the last expression." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
712 (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
|
713 (prog1 (point) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
714 (c-forward-syntactic-ws))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
715 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
716 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
717 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
718 ;;; font-lock |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
719 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
720 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
721 (defun antlr-font-lock-keywords () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
722 "Return font-lock keywords for current buffer. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
723 See `antlr-font-lock-additional-keywords', `antlr-language' and |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
724 `antlr-font-lock-maximum-decoration'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
725 (if (eq antlr-font-lock-maximum-decoration 'none) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
726 antlr-font-lock-additional-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
727 (append antlr-font-lock-additional-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
728 (eval (let ((major-mode antlr-language)) ; dynamic |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
729 (font-lock-choose-keywords |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
730 (cdr (assq antlr-language |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
731 antlr-font-lock-keywords-alist)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
732 (if (eq antlr-font-lock-maximum-decoration 'inherit) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
733 font-lock-maximum-decoration |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
734 antlr-font-lock-maximum-decoration))))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
735 |
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 ;;; imenu support |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
739 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
740 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
741 (defun antlr-imenu-create-index-function () |
26965 | 742 "Return imenu index-alist for ANTLR grammar files." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
743 (let ((items nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
744 (classes nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
745 (semi (point-max))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
746 ;; Using `imenu-progress-message' would require imenu for compilation -- |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
747 ;; nobody is missing these messages... |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
748 (antlr-with-syntax-table antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
749 ;; 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
|
750 ;; 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
|
751 ;; 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
|
752 (while semi |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
753 (goto-char semi) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
754 (if (setq semi (antlr-search-backward ";")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
755 (progn (forward-char) (antlr-skip-exception-part t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
756 (antlr-skip-file-prelude t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
757 (if (looking-at "{") (antlr-skip-sexps 1)) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
758 (if (looking-at "class[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]+extends[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]*;") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
759 (push (cons (match-string 1) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
760 (if imenu-use-markers |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
761 (copy-marker (match-beginning 1)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
762 (match-beginning 1))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
763 classes) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
764 (if (looking-at "p\\(ublic\\|rotected\\|rivate\\)") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
765 (antlr-skip-sexps 1)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
766 (when (looking-at "\\sw+") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
767 (push (cons (match-string 0) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
768 (if imenu-use-markers |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
769 (copy-marker (match-beginning 0)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
770 (match-beginning 0))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
771 items))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
772 (if classes (cons (cons "Classes" classes) items) items))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
773 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
774 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
775 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
776 ;;; Parse grammar files (internal functions) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
777 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
778 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
779 (defun antlr-skip-exception-part (skip-comment) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
780 "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
|
781 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
|
782 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
|
783 part." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
784 (let ((pos (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
785 (class nil)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
786 (c-forward-syntactic-ws) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
787 (while (looking-at "options\\>\\|tokens\\>") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
788 (setq class t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
789 (setq pos (antlr-skip-sexps 2))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
790 (if class |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
791 ;; 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
|
792 ;; 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
|
793 ;; 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
|
794 (if (looking-at "{") (setq pos (antlr-skip-sexps 1))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
795 (while (looking-at "exception\\>") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
796 (setq pos (antlr-skip-sexps 1)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
797 (if (looking-at "\\[") (setq pos (antlr-skip-sexps 1))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
798 (while (looking-at "catch\\>") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
799 (setq pos (antlr-skip-sexps 3))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
800 (or skip-comment (goto-char pos)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
801 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
802 (defun antlr-skip-file-prelude (skip-comment) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
803 "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
|
804 If SKIP-COMMENT is non-nil, also skip the comment after that part. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
805 Return the start position of the file prelude." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
806 (let* ((pos (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
807 (pos0 pos)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
808 (c-forward-syntactic-ws) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
809 (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
|
810 (while (looking-at "header\\>[ \t]*\\(\"\\)?") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
811 (setq pos (antlr-skip-sexps (if (match-beginning 1) 3 2)))) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
812 (if (looking-at "options\\>") (setq pos (antlr-skip-sexps 2))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
813 (or skip-comment (goto-char pos)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
814 pos0)) |
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 (defun antlr-next-rule (arg skip-comment) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
817 "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
|
818 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
|
819 rule. Negative argument ARG means move back to ARGth preceding end of |
26965 | 820 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
|
821 is non-nil, move to beginning of the rule." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
822 ;; 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
|
823 ;; PRE: ARG<>0 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
824 (let ((pos (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
825 (beg (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
826 ;; first look whether point is in exception part |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
827 (if (antlr-search-backward ";") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
828 (progn |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
829 (setq beg (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
830 (forward-char) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
831 (antlr-skip-exception-part skip-comment)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
832 (antlr-skip-file-prelude skip-comment)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
833 (if (< arg 0) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
834 (unless (and (< (point) pos) (zerop (incf arg))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
835 ;; 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
|
836 (goto-char beg) ; rewind (to ";" / point) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
837 (while (and arg (<= (incf arg) 0)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
838 (if (antlr-search-backward ";") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
839 (setq beg (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
840 (when (>= arg -1) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
841 ;; try file prelude: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
842 (setq pos (antlr-skip-file-prelude skip-comment)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
843 (if (zerop arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
844 (if (>= (point) beg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
845 (goto-char (if (>= pos beg) (point-min) pos))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
846 (goto-char (if (or (>= (point) beg) (= (point) pos)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
847 (point-min) pos)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
848 (setq arg nil))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
849 (when arg ; always found a ";" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
850 (forward-char) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
851 (antlr-skip-exception-part skip-comment))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
852 (if (<= (point) pos) ; moved backward? |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
853 (goto-char pos) ; rewind |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
854 (decf arg)) ; already moved one defun forward |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
855 (unless (zerop arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
856 (while (>= (decf arg) 0) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
857 (antlr-search-forward ";")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
858 (antlr-skip-exception-part skip-comment))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
859 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
860 (defun antlr-outside-rule-p () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
861 "Non-nil if point is outside a grammar rule. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
862 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
|
863 ;; 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
|
864 (let ((pos (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
865 (antlr-next-rule -1 nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
866 (let ((between (or (bobp) (< (point) pos)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
867 (c-forward-syntactic-ws) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
868 (and between (> (point) pos) (goto-char pos))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
869 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
870 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
871 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
872 ;;; Parse grammar files (commands) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
873 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
874 ;; No (interactive "_") in Emacs... use `zmacs-region-stays'. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
875 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
876 (defun antlr-inside-rule-p () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
877 "Non-nil if point is inside a grammar rule. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
878 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
|
879 rule." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
880 (save-excursion |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
881 (antlr-with-syntax-table antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
882 (not (antlr-outside-rule-p))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
883 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
884 (defun antlr-end-of-rule (&optional arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
885 "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
|
886 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
|
887 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
|
888 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
|
889 (interactive "p") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
890 (if (zerop arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
891 (antlr-end-of-body) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
892 (antlr-with-syntax-table antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
893 (antlr-next-rule arg nil)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
894 (setq zmacs-region-stays t))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
895 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
896 (defun antlr-beginning-of-rule (&optional arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
897 "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
|
898 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
|
899 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
|
900 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
|
901 (interactive "p") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
902 (if (zerop arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
903 (antlr-beginning-of-body) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
904 (antlr-with-syntax-table antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
905 (antlr-next-rule (- arg) t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
906 (setq zmacs-region-stays t))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
907 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
908 (defun antlr-end-of-body (&optional msg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
909 "Move to position after the `;' of the current rule. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
910 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
|
911 prefix arg MSG, move to `:'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
912 (interactive) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
913 (antlr-with-syntax-table antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
914 (let ((orig (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
915 (if (antlr-outside-rule-p) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
916 (error "Outside an ANTLR rule")) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
917 (let ((bor (point))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
918 (when (< (antlr-skip-file-prelude t) (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
919 ;; Yes, we are in the file prelude |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
920 (goto-char orig) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
921 (error (or msg "The file prelude is without `;'"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
922 (antlr-search-forward ";") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
923 (when msg |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
924 (when (< (point) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
925 (progn (goto-char bor) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
926 (or (antlr-search-forward ":") (point-max)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
927 (goto-char orig) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
928 (error msg)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
929 (c-forward-syntactic-ws))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
930 (setq zmacs-region-stays t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
931 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
932 (defun antlr-beginning-of-body () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
933 "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
|
934 (interactive) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
935 (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
|
936 |
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 ;;;=========================================================================== |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
939 ;;; Literal normalization, Hide Actions |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
940 ;;;=========================================================================== |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
941 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
942 (defun antlr-downcase-literals (&optional transform) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
943 "Convert all literals in buffer to lower case. |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
944 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
|
945 (interactive) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
946 (or transform (setq transform 'downcase-region)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
947 (let ((literals 0)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
948 (save-excursion |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
949 (goto-char (point-min)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
950 (antlr-with-syntax-table antlr-action-syntax-table |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
951 (antlr-invalidate-context-cache) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
952 (while (antlr-re-search-forward "\"\\(\\sw\\(\\sw\\|-\\)*\\)\"" nil) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
953 (funcall transform (match-beginning 0) (match-end 0)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
954 (incf literals)))) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
955 (message "Transformed %d literals" literals))) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
956 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
957 (defun antlr-upcase-literals () |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
958 "Convert all literals in buffer to upper case." |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
959 (interactive) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
960 (antlr-downcase-literals 'upcase-region)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
961 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
962 (defun antlr-hide-actions (arg &optional silent) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
963 "Hide or unhide all actions in buffer. |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
964 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
|
965 called interactively without prefix argument. Hide all actions |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
966 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
|
967 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
|
968 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
969 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
|
970 (interactive "p") |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
971 ;; from Emacs/lazy-lock: `save-buffer-state' |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
972 (let ((modified (buffer-modified-p)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
973 (buffer-undo-list t) (inhibit-read-only t) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
974 (inhibit-point-motion-hooks t) deactivate-mark ; Emacs only |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
975 before-change-functions after-change-functions |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
976 buffer-file-name buffer-file-truename) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
977 (if (> arg 0) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
978 (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
|
979 (diff (and antlr-action-visibility |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
980 (+ (max antlr-action-visibility 0) 2)))) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
981 (antlr-hide-actions 0 t) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
982 (save-excursion |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
983 (goto-char (point-min)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
984 (antlr-with-syntax-table antlr-action-syntax-table |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
985 (antlr-invalidate-context-cache) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
986 (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
|
987 (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
|
988 (when beg |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
989 (if diff ; braces are visible |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
990 (if (> (point) (+ beg diff)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
991 (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
|
992 '(invisible t intangible t))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
993 ;; 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
|
994 (and (looking-at "[ \t]*$") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
995 (save-excursion |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
996 (goto-char beg) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
997 (skip-chars-backward " \t") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
998 (and (bolp) (setq beg (point)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
999 (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
|
1000 (add-text-properties beg (point) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1001 '(invisible t intangible t)))))))) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1002 (or silent |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1003 (message "Hide all actions (%s arguments)...done" |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1004 (if (= arg 1) "including" "excluding")))) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1005 (remove-text-properties (point-min) (point-max) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1006 '(invisible nil intangible nil)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1007 (or silent |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1008 (message "Unhide all actions (including arguments)...done"))) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1009 (and (not modified) (buffer-modified-p) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1010 (set-buffer-modified-p nil)))) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1011 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1012 |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1013 ;;;=========================================================================== |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1014 ;;; Compute dependencies |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1015 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1016 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1017 (defun antlr-file-dependencies () |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1018 "Return dependencies for grammar in current buffer. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1019 The result looks like (FILE (CLASSES . SUPERS) VOCABS . LANGUAGE) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1020 where CLASSES = ((CLASS . CLASS-EVOCAB) ...), |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1021 SUPERS = ((SUPER . USE-EVOCAB-P) ...), and |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1022 VOCABS = ((EVOCAB ...) . (IVOCAB ...)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1023 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1024 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
|
1025 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
|
1026 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
|
1027 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1028 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
|
1029 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
|
1030 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
|
1031 (unless buffer-file-name |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1032 (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
|
1033 (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
|
1034 (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
|
1035 (goto-char (point-min)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1036 (while (antlr-re-search-forward "class[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]+extends[ \t]+\\([A-Za-z\300-\326\330-\337]\\sw*\\)[ \t]*;" nil) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1037 ;; parse class definition -------------------------------------------- |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1038 (let* ((class (match-string 1)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1039 (sclass (match-string 2)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1040 ;; 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
|
1041 ;; 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
|
1042 (evocab (or default-vocab class)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1043 (ivocab nil)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1044 (goto-char (match-end 0)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1045 (c-forward-syntactic-ws) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1046 (while (looking-at "options\\>\\|\\(tokens\\)\\>") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1047 (if (match-beginning 1) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1048 (antlr-skip-sexps 2) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1049 (goto-char (match-end 0)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1050 (c-forward-syntactic-ws) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1051 ;; parse grammar option section -------------------------------- |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1052 (when (eq (char-after (point)) ?\{) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1053 (let* ((beg (1+ (point))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1054 (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
|
1055 (cont (point))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1056 (goto-char beg) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1057 (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
|
1058 (setq evocab (match-string 1))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1059 (goto-char beg) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1060 (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
|
1061 (setq ivocab (match-string 1))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1062 (goto-char cont))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1063 (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
|
1064 (let ((super (assoc sclass superclasses))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1065 (if super |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1066 (or ivocab (setcdr super t)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1067 (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
|
1068 ;; remember class with export vocabulary: |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1069 (push (cons class evocab) classes) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1070 ;; 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
|
1071 (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
|
1072 (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
|
1073 (or (null ivocab) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1074 (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
|
1075 (if classes |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1076 (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
|
1077 (cons (nreverse classes) (nreverse superclasses)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1078 (cons (nreverse exportVocabs) (nreverse importVocabs)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1079 antlr-language)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1080 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1081 (defun antlr-directory-dependencies (dirname) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1082 "Return dependencies for all grammar files in directory DIRNAME. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1083 The result looks like ((CLASS-SPEC ...) . (FILE-DEP ...)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1084 where CLASS-SPEC = (CLASS (FILE . EVOCAB) ...). |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1085 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1086 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
|
1087 `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
|
1088 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
|
1089 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
|
1090 (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
|
1091 (when grammar |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1092 (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
|
1093 (generate-new-buffer-name " *temp*"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1094 (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
|
1095 (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
|
1096 (cadr antlr-special-file-formats)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1097 ".+") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1098 "\\'")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1099 classes dependencies) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1100 (unwind-protect |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1101 (save-excursion |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1102 (set-buffer temp-buffer) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1103 (widen) ; just in case... |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1104 (dolist (file grammar) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1105 (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
|
1106 (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
|
1107 (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
|
1108 (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
|
1109 ; table and `antlr-language' |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1110 (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
|
1111 (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
|
1112 (file (car file-deps))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1113 (when file-deps |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1114 (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
|
1115 (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
|
1116 (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
|
1117 (if class-spec |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1118 (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
|
1119 (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
|
1120 classes)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1121 (push file-deps dependencies))))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1122 (kill-buffer temp-buffer)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1123 (cons (nreverse classes) (nreverse dependencies)))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1124 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1125 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1126 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1127 ;;; Compilation: run ANTLR tool |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1128 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1129 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1130 (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
|
1131 "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
|
1132 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
|
1133 part SUPER in the result of `antlr-file-dependencies'. CLASSES is the |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1134 part (CLASS-SPEC ...) in the result of `antlr-directory-dependencies'. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1135 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1136 The result looks like (OPTION WITH-UNKNOWN GLIB ...). OPTION is the |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1137 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
|
1138 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
|
1139 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1140 Each GLIB looks like (GRAMMAR-FILE . EVOCAB). GRAMMAR-FILE is a file in |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1141 which a super-grammar is defined. EVOCAB is the value of the export |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1142 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
|
1143 ;; 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
|
1144 ;; 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
|
1145 ;; 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
|
1146 (let (glibs unknown) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1147 (while supers |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1148 (let* ((super (pop supers)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1149 (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
|
1150 (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
|
1151 (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
|
1152 (push (cons (or (car file) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1153 (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
|
1154 (car super))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1155 (and (cdr super) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1156 (or (cdr file) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1157 (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
|
1158 (car super))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1159 glibs))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1160 (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
|
1161 (cons unknown glibs)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1162 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1163 (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
|
1164 "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
|
1165 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
|
1166 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
|
1167 necessary. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1168 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1169 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
|
1170 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
|
1171 `antlr-ask-about-save'." |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1172 (interactive |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1173 ;; 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
|
1174 (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
|
1175 (save-restriction |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1176 (widen) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1177 (antlr-file-dependencies)))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1178 (glibs "")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1179 (when supers |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1180 (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
|
1181 (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
|
1182 supers |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1183 (car (antlr-directory-dependencies |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1184 (antlr-default-directory))))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1185 (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
|
1186 (concat antlr-tool-command glibs " ")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1187 buffer-file-name |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1188 supers))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1189 (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
|
1190 (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
|
1191 (require 'compile) ; only `compile' autoload |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1192 (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
|
1193 "No more errors" "Antlr-Run"))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1194 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1195 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1196 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1197 ;;; Makefile creation |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1198 ;;;=========================================================================== |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1199 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1200 (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
|
1201 "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
|
1202 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
|
1203 (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
|
1204 (when spec |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1205 (insert pre |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1206 (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
|
1207 post)))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1208 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1209 (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
|
1210 "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
|
1211 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
|
1212 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
|
1213 (let* ((dirname (antlr-default-directory)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1214 (deps0 (antlr-directory-dependencies dirname)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1215 (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
|
1216 (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
|
1217 (with-error nil) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1218 (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
|
1219 (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
|
1220 (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
|
1221 (dolist (dep deps) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1222 (let ((supers (cdadr dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1223 (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
|
1224 (if n (incf n)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1225 (antlr-makefile-insert-variable n "" " =") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1226 (if supers |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1227 (insert " " |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1228 (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
|
1229 (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
|
1230 (dolist (class-def (caadr dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1231 (let ((sep gen-sep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1232 (dolist (class-file (cadr lang)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1233 (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
|
1234 (setq sep " ")))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1235 (dolist (evocab (caaddr dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1236 (let ((sep gen-sep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1237 (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
|
1238 (car lang))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1239 (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
|
1240 (setq sep " ")))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1241 (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
|
1242 (insert ": " (car dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1243 (dolist (ivocab (cdaddr dep)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1244 (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
|
1245 (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
|
1246 (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
|
1247 (dolist (super (cddr glibs)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1248 (insert " " (car super)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1249 (if (cdr super) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1250 (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
|
1251 (cdr super))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1252 (insert "\n\t" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1253 (caddr antlr-makefile-specification) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1254 (car glibs) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1255 " $<\n" |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1256 (car antlr-makefile-specification))))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1257 (if n |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1258 (let ((i 0)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1259 (antlr-makefile-insert-variable nil "" " =") |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1260 (while (<= (incf i) n) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1261 (antlr-makefile-insert-variable i " $(" ")")) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1262 (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
|
1263 (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
|
1264 (backward-delete-char 1)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1265 (when with-error |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1266 (goto-char (point-min)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1267 (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
|
1268 (unless in-makefile |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1269 (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
|
1270 (goto-char (point-min)) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1271 (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
|
1272 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1273 ;;;###autoload |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1274 (defun antlr-show-makefile-rules () |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1275 "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
|
1276 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
|
1277 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
|
1278 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
|
1279 \\[yank]. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1280 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1281 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
|
1282 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
|
1283 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
|
1284 the rules. |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1285 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1286 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
|
1287 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
|
1288 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
|
1289 *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
|
1290 (interactive) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1291 (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
|
1292 (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
|
1293 (push-mark) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1294 (antlr-insert-makefile-rules t))) |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1295 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1296 |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1297 ;;;=========================================================================== |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1298 ;;; Indentation |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1299 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1300 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1301 (defun antlr-indent-line () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1302 "Indent the current line as ANTLR grammar code. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1303 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
|
1304 multiplied by: |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1305 - the level of the paren/brace/bracket depth, |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1306 - 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
|
1307 exception part, |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1308 - minus 1 if `antlr-indent-item-regexp' matches the beginning of the |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1309 line starting from the first non-blank. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1310 |
26965 | 1311 Lines inside block comments are not changed or indented by |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1312 `c-indent-line', see `antlr-indent-comment'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1313 (let ((orig (point)) bol boi indent syntax) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1314 (beginning-of-line) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1315 (setq bol (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1316 (skip-chars-forward " \t") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1317 (setq boi (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1318 ;; check syntax at beginning of indentation ------------------------------ |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1319 (antlr-with-syntax-table antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1320 (antlr-invalidate-context-cache) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1321 (cond ((symbolp (setq syntax (antlr-syntactic-context))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1322 (setq indent nil)) ; block-comments, strings, (comments) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1323 ((eq (char-after) ?#) ; cpp directive |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1324 (setq syntax 'cpp) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1325 (setq indent 0)) ; indentation at 0 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1326 ((progn |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1327 (antlr-next-rule -1 t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1328 (if (antlr-search-forward ":") (< boi (1- (point))) t)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1329 (setq indent 0)) ; in rule header |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1330 ((if (antlr-search-forward ";") (< boi (point)) t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1331 (setq indent 2)) ; in rule body |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1332 (t |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1333 (forward-char) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1334 (antlr-skip-exception-part nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1335 (setq indent (if (> (point) boi) 1 0))))) ; in exception part? |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1336 ;; compute the corresponding indentation and indent ---------------------- |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1337 (if (null indent) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1338 (progn |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1339 (goto-char orig) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1340 (and (eq antlr-indent-comment t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1341 (not (eq syntax 'string)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1342 (c-indent-line))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1343 ;; do it ourselves |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1344 (goto-char boi) |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1345 (unless (symbolp syntax) ; direct indentation |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1346 (antlr-invalidate-context-cache) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1347 (incf indent (antlr-syntactic-context)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1348 (and (> indent 0) (looking-at antlr-indent-item-regexp) (decf indent)) |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1349 (setq indent (* indent c-basic-offset))) |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1350 ;; the usual major-mode indent stuff ----------------------------------- |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1351 (setq orig (- (point-max) orig)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1352 (unless (= (current-column) indent) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1353 (delete-region bol boi) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1354 (beginning-of-line) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1355 (indent-to indent)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1356 ;; If initial point was within line's indentation, |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1357 ;; position after the indentation. Else stay at same point in text. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1358 (if (> (- (point-max) orig) (point)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1359 (goto-char (- (point-max) orig)))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1360 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1361 (defun antlr-indent-command (&optional arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1362 "Indent the current line or insert tabs/spaces. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1363 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
|
1364 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
|
1365 Otherwise, indent the current line with `antlr-indent-line'." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1366 (interactive "P") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1367 (if (or arg (eq last-command 'antlr-indent-command)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1368 (insert-tab arg) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1369 (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
|
1370 (antlr-indent-line)))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1371 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1372 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1373 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1374 ;;; Mode entry |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1375 ;;;=========================================================================== |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1376 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1377 (defun antlr-c-common-init () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1378 "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
|
1379 ;; X/Emacs 20 only |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1380 (make-local-variable 'paragraph-start) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1381 (make-local-variable 'paragraph-separate) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1382 (make-local-variable 'paragraph-ignore-fill-prefix) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1383 (make-local-variable 'require-final-newline) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1384 (make-local-variable 'parse-sexp-ignore-comments) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1385 (make-local-variable 'indent-line-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1386 (make-local-variable 'indent-region-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1387 (make-local-variable 'comment-start) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1388 (make-local-variable 'comment-end) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1389 (make-local-variable 'comment-column) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1390 (make-local-variable 'comment-start-skip) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1391 (make-local-variable 'comment-multi-line) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1392 (make-local-variable 'outline-regexp) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1393 (make-local-variable 'outline-level) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1394 (make-local-variable 'adaptive-fill-regexp) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1395 (make-local-variable 'adaptive-fill-mode) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1396 (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
|
1397 (and (boundp 'comment-line-break-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1398 (make-local-variable 'comment-line-break-function)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1399 ;; Emacs 19.30 and beyond only, AFAIK |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1400 (if (boundp 'fill-paragraph-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1401 (progn |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1402 (make-local-variable 'fill-paragraph-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1403 (setq fill-paragraph-function 'c-fill-paragraph))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1404 ;; now set their values |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1405 (setq paragraph-start (concat page-delimiter "\\|$") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1406 paragraph-separate paragraph-start |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1407 paragraph-ignore-fill-prefix t |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1408 require-final-newline t |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1409 parse-sexp-ignore-comments t |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1410 indent-line-function 'c-indent-line |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1411 indent-region-function 'c-indent-region |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1412 outline-regexp "[^#\n\^M]" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1413 outline-level 'c-outline-level |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1414 comment-column 32 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1415 comment-start-skip "/\\*+ *\\|// *" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1416 comment-multi-line nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1417 comment-line-break-function 'c-comment-line-break-function |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1418 adaptive-fill-regexp nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1419 adaptive-fill-mode nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1420 ;; 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
|
1421 ;; buffer local value has its own alist structure. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1422 (setq c-offsets-alist (copy-alist c-offsets-alist)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1423 ;; 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
|
1424 ;; ignore any byte compiler warnings you might get here |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1425 (make-local-variable 'comment-indent-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1426 (setq comment-indent-function 'c-comment-indent)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1427 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1428 (defun antlr-language-for-option (option-value) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1429 "Find element in `antlr-language-alist' for OPTION-VALUE." |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1430 ;; Like (find OPTION-VALUE antlr-language-alist :key 'cddr :test 'member) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1431 (let ((seq antlr-language-alist) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1432 r) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1433 (while seq |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1434 (setq r (pop seq)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1435 (if (member option-value (cddr r)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1436 (setq seq nil) ; stop |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1437 (setq r nil))) ; no result yet |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1438 r)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1439 |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1440 ;;;###autoload |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1441 (defun antlr-mode () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1442 "Major mode for editing ANTLR grammar files. |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1443 \\{antlr-mode-map}" |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1444 (interactive) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1445 (c-initialize-cc-mode) ; for java syntax table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1446 (kill-all-local-variables) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1447 ;; ANTLR specific ---------------------------------------------------------- |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1448 (setq major-mode 'antlr-mode |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1449 mode-name "Antlr") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1450 (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
|
1451 (unless antlr-mode-syntax-table |
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1452 (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
|
1453 (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
|
1454 (set-syntax-table antlr-mode-syntax-table) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1455 (unless antlr-action-syntax-table |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1456 (let ((slist (nth 3 antlr-font-lock-defaults))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1457 (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
|
1458 (copy-syntax-table antlr-mode-syntax-table)) |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1459 (while slist |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1460 (modify-syntax-entry (caar slist) (cdar slist) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1461 antlr-action-syntax-table) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1462 (setq slist (cdr slist))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1463 (use-local-map antlr-mode-map) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1464 (make-local-variable 'antlr-language) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1465 (unless antlr-language |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1466 (save-excursion |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1467 (goto-char (point-min)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1468 (setq antlr-language |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1469 (car (or (and (re-search-forward (cdr antlr-language-limit-n-regexp) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1470 (car antlr-language-limit-n-regexp) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1471 t) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1472 (antlr-language-for-option (match-string 1))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1473 (antlr-language-for-option nil)))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1474 (if (stringp (cadr (assq antlr-language antlr-language-alist))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1475 (setq mode-name |
29289
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1476 (concat "Antlr." |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1477 (cadr (assq antlr-language antlr-language-alist))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1478 ;; indentation, for the C engine ------------------------------------------- |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1479 (antlr-c-common-init) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1480 (setq indent-line-function 'antlr-indent-line |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1481 indent-region-function nil) ; too lazy |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1482 (setq comment-start "// " |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1483 comment-end "") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1484 (c-set-style "java") |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1485 (if (eq antlr-language 'c++-mode) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1486 (setq c-conditional-key c-C++-conditional-key |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1487 c-comment-start-regexp c-C++-comment-start-regexp |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1488 c-class-key c-C++-class-key |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1489 c-extra-toplevel-key c-C++-extra-toplevel-key |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1490 c-access-key c-C++-access-key |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1491 c-recognize-knr-p nil) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1492 (setq c-conditional-key c-Java-conditional-key |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1493 c-comment-start-regexp c-Java-comment-start-regexp |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1494 c-class-key c-Java-class-key |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1495 c-method-key nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1496 c-baseclass-key nil |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1497 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
|
1498 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
|
1499 (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
|
1500 (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
|
1501 ;; various ----------------------------------------------------------------- |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1502 (make-local-variable 'font-lock-defaults) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1503 (setq font-lock-defaults antlr-font-lock-defaults) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1504 (easy-menu-add antlr-mode-menu) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1505 (make-local-variable 'imenu-create-index-function) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1506 (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
|
1507 (make-local-variable 'imenu-generic-expression) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1508 (setq imenu-generic-expression t) ; fool stupid test |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1509 (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
|
1510 (fboundp 'imenu-add-to-menubar) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1511 (imenu-add-to-menubar |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1512 (if (stringp antlr-imenu-name) antlr-imenu-name "Index"))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1513 (antlr-set-tabs) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1514 (run-hooks 'antlr-mode-hook)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1515 |
34011
075cc818f566
New commands to run ANTLR from within Emacs and
Gerd Moellmann <gerd@gnu.org>
parents:
29289
diff
changeset
|
1516 ;; 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
|
1517 ;; 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
|
1518 ;; 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
|
1519 (put 'antlr-mode 'mode-name "Antlr") |
9ad79f5782af
New commands: hide/unhide actions,
Gerd Moellmann <gerd@gnu.org>
parents:
26965
diff
changeset
|
1520 |
26542
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1521 ;;;###autoload |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1522 (defun antlr-set-tabs () |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1523 "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
|
1524 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
|
1525 (if buffer-file-name |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1526 (let ((alist antlr-tab-offset-alist) elem) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1527 (while alist |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1528 (setq elem (pop alist)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1529 (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
|
1530 (or (null (cadr elem)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1531 (string-match (cadr elem) buffer-file-name)) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1532 (setq tab-width (caddr elem) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1533 indent-tabs-mode (cadddr elem) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1534 alist nil)))))) |
0d41332e3819
Major mode for ANTLR grammar files.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1535 |
26965 | 1536 ; 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
|
1537 ; LocalWords: Java's Nomencl ruledef tokendef ruleref tokenref setType ader ev |
26965 | 1538 ; 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
|
1539 ; 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
|
1540 ; 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
|
1541 ; 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
|
1542 ; LocalWords: sclass evocab ivocab importVocab deps glibs supers sep dep lang |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38100
diff
changeset
|
1543 |
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38100
diff
changeset
|
1544 ;;; antlr-mode.el ends here |