Mercurial > emacs
annotate lisp/cedet/semantic/lex-spp.el @ 105891:07c792840800
* xmenu.c (Fx_popup_menu): Extract event timestamp. Pass it to
xmenu_show.
(xmenu_show): New arg. Pass it to create_and_show_popup_menu.
(create_and_show_popup_menu): New arg. Pass it to gtk_menu_popup.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 07 Nov 2009 23:49:08 +0000 |
parents | 83dde921cc1b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
104416
c13af98da4d6
Fix renamed filenames in file headers.
Chong Yidong <cyd@stupidchicken.com>
parents:
104414
diff
changeset
|
1 ;;; lex-spp.el --- Semantic Lexical Pre-processor |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
105340 | 3 ;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; This file is part of GNU Emacs. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; GNU Emacs is free software: you can redistribute it and/or modify |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; it under the terms of the GNU General Public License as published by |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; the Free Software Foundation, either version 3 of the License, or |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; (at your option) any later version. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; GNU Emacs is distributed in the hope that it will be useful, |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; GNU General Public License for more details. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; You should have received a copy of the GNU General Public License |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;;; Commentary: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;; The Semantic Preprocessor works with semantic-lex to provide a phase |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; during lexical analysis to do the work of a pre-processor. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; A pre-processor identifies lexical syntax mixed in with another language |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 ;; and replaces some keyword tokens with streams of alternate tokens. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 ;; If you use SPP in your language, be sure to specify this in your |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; semantic language setup function: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;; (add-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook nil t) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; Special Lexical Tokens: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 ;; There are several special lexical tokens that are used by the |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 ;; Semantic PreProcessor lexer. They are: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 ;; Declarations: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 ;; spp-macro-def - A definition of a lexical macro. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 ;; spp-macro-undef - A removal of a definition of a lexical macro. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 ;; spp-system-include - A system level include file |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 ;; spp-include - An include file |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 ;; spp-concat - A lexical token representing textual concatenation |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 ;; of symbol parts. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 ;; Operational tokens: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 ;; spp-arg-list - Represents an argument list to a macro. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 ;; spp-symbol-merge - A request for multiple symbols to be textually merged. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 ;;; TODO: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 ;; Use `semantic-push-parser-warning' for situations where there are likely |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 ;; macros that are undefined unexpectedly, or other problem. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 ;; TODO: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 ;; Try to handle the case of: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 ;; #define NN namespace nn { |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 ;; #define NN_END } |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 ;; NN |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 ;; int mydecl() {} |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 ;; NN_END |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104434
diff
changeset
|
70 (require 'semantic) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 (require 'semantic/lex) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 ;;; Code: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 (defvar semantic-lex-spp-macro-symbol-obarray nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 "Table of macro keywords used by the Semantic Preprocessor. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 These symbols will be used in addition to those in |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 `semantic-lex-spp-dynamic-macro-symbol-obarray'.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 (make-variable-buffer-local 'semantic-lex-spp-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 (defvar semantic-lex-spp-project-macro-symbol-obarray nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 "Table of macro keywords for this project. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 These symbols will be used in addition to those in |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 `semantic-lex-spp-dynamic-macro-symbol-obarray'.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 (make-variable-buffer-local 'semantic-lex-spp-project-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 (defvar semantic-lex-spp-dynamic-macro-symbol-obarray nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 "Table of macro keywords used during lexical analysis. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 Macros are lexical symbols which are replaced by other lexical |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 tokens during lexical analysis. During analysis symbols can be |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 added and removed from this symbol table.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 (make-variable-buffer-local 'semantic-lex-spp-dynamic-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 (defvar semantic-lex-spp-dynamic-macro-symbol-obarray-stack nil |
105340 | 94 "A stack of obarrays for temporarily scoped macro values.") |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 (make-variable-buffer-local 'semantic-lex-spp-dynamic-macro-symbol-obarray-stack) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 (defvar semantic-lex-spp-expanded-macro-stack nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 "The stack of lexical SPP macros we have expanded.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 ;; The above is not buffer local. Some macro expansions need to be |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 ;; dumped into a secondary buffer for re-lexing. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 ;;; NON-RECURSIVE MACRO STACK |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 ;; C Pre-processor does not allow recursive macros. Here are some utils |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 ;; for managing the symbol stack of where we've been. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 (defmacro semantic-lex-with-macro-used (name &rest body) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 "With the macro NAME currently being expanded, execute BODY. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 Pushes NAME into the macro stack. The above stack is checked |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 by `semantic-lex-spp-symbol' to not return true for any symbol |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 currently being expanded." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 `(unwind-protect |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 (progn |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 (push ,name semantic-lex-spp-expanded-macro-stack) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 ,@body) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 (pop semantic-lex-spp-expanded-macro-stack))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 (put 'semantic-lex-with-macro-used 'lisp-indent-function 1) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 (add-hook |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 'edebug-setup-hook |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 #'(lambda () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (def-edebug-spec semantic-lex-with-macro-used |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (symbolp def-body) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 ;;; MACRO TABLE UTILS |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 ;; The dynamic macro table is a buffer local variable that is modified |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 ;; during the analysis. OBARRAYs are used, so the language must |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 ;; have symbols that are compatible with Emacs Lisp symbols. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 (defsubst semantic-lex-spp-symbol (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 "Return spp symbol with NAME or nil if not found. |
105340 | 136 The search priority is: |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 1. DYNAMIC symbols |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 2. PROJECT specified symbols. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 3. SYSTEM specified symbols." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 (and |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 ;; Only strings... |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 (stringp name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 ;; Make sure we don't recurse. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 (not (member name semantic-lex-spp-expanded-macro-stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 ;; Do the check of the various tables. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (or |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 ;; DYNAMIC |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (and (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 (intern-soft name semantic-lex-spp-dynamic-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 ;; PROJECT |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 (and (arrayp semantic-lex-spp-project-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 (intern-soft name semantic-lex-spp-project-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 ;; SYSTEM |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 (and (arrayp semantic-lex-spp-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 (intern-soft name semantic-lex-spp-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 ;; ... |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 ))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 (defsubst semantic-lex-spp-symbol-p (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 "Return non-nil if a keyword with NAME exists in any keyword table." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 (if (semantic-lex-spp-symbol name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 t)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 (defsubst semantic-lex-spp-dynamic-map () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 "Return the dynamic macro map for the current buffer." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 (or semantic-lex-spp-dynamic-macro-symbol-obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (setq semantic-lex-spp-dynamic-macro-symbol-obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 (make-vector 13 0)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 (defsubst semantic-lex-spp-dynamic-map-stack () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 "Return the dynamic macro map for the current buffer." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 (or semantic-lex-spp-dynamic-macro-symbol-obarray-stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 (setq semantic-lex-spp-dynamic-macro-symbol-obarray-stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 (make-vector 13 0)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 (defun semantic-lex-spp-symbol-set (name value &optional obarray-in) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 "Set value of spp symbol with NAME to VALUE and return VALUE. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 If optional OBARRAY-IN is non-nil, then use that obarray instead of |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 the dynamic map." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 (if (and (stringp value) (string= value "")) (setq value nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 (set (intern name (or obarray-in |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 (semantic-lex-spp-dynamic-map))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 value)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 (defsubst semantic-lex-spp-symbol-remove (name &optional obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 "Remove the spp symbol with NAME. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 If optional OBARRAY is non-nil, then use that obarray instead of |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 the dynamic map." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 (unintern name (or obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 (semantic-lex-spp-dynamic-map)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 (defun semantic-lex-spp-symbol-push (name value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 "Push macro NAME with VALUE into the map. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 Reverse with `semantic-lex-spp-symbol-pop'." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (let* ((map (semantic-lex-spp-dynamic-map)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 (stack (semantic-lex-spp-dynamic-map-stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 (mapsym (intern name map)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (stacksym (intern name stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 (mapvalue (when (boundp mapsym) (symbol-value mapsym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 (when (boundp mapsym) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 ;; Make sure there is a stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 (if (not (boundp stacksym)) (set stacksym nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 ;; If there is a value to push, then push it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 (set stacksym (cons mapvalue (symbol-value stacksym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 ;; Set our new value here. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 (set mapsym value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 (defun semantic-lex-spp-symbol-pop (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 "Pop macro NAME from the stackmap into the orig map. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 Reverse with `semantic-lex-spp-symbol-pop'." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 (let* ((map (semantic-lex-spp-dynamic-map)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (stack (semantic-lex-spp-dynamic-map-stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 (mapsym (intern name map)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 (stacksym (intern name stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 (oldvalue nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 (if (or (not (boundp stacksym) ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 (= (length (symbol-value stacksym)) 0)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 ;; Nothing to pop, remove it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 (unintern name map) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 ;; If there is a value to pop, then add it to the map. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 (set mapsym (car (symbol-value stacksym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 (set stacksym (cdr (symbol-value stacksym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 ))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 (defsubst semantic-lex-spp-symbol-stream (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 "Return replacement stream of macro with NAME." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 (let ((spp (semantic-lex-spp-symbol name))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 (if spp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 (symbol-value spp)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 (defun semantic-lex-make-spp-table (specs) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 "Convert spp macro list SPECS into an obarray and return it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 SPECS must be a list of (NAME . REPLACEMENT) elements, where: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 NAME is the name of the spp macro symbol to define. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 REPLACEMENT a string that would be substituted in for NAME." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 ;; Create the symbol hash table |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 (let ((semantic-lex-spp-macro-symbol-obarray (make-vector 13 0)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 spec) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 ;; fill it with stuff |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 (while specs |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 (setq spec (car specs) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 specs (cdr specs)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 (semantic-lex-spp-symbol-set |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 (car spec) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 (cdr spec) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 semantic-lex-spp-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 semantic-lex-spp-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 (defun semantic-lex-spp-save-table () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 "Return a list of spp macros and values. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 The return list is meant to be saved in a semanticdb table." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 (let (macros) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 (when (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 (mapatoms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 #'(lambda (symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 (setq macros (cons (cons (symbol-name symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 (symbol-value symbol)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 semantic-lex-spp-dynamic-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 macros)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 (defun semantic-lex-spp-macros () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 "Return a list of spp macros as Lisp symbols. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 The value of each symbol is the replacement stream." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 (let (macros) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 (when (arrayp semantic-lex-spp-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (mapatoms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 #'(lambda (symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 (setq macros (cons symbol macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 semantic-lex-spp-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 (when (arrayp semantic-lex-spp-project-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 (mapatoms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 #'(lambda (symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 (setq macros (cons symbol macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 semantic-lex-spp-project-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 (when (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 (mapatoms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 #'(lambda (symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 (setq macros (cons symbol macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 semantic-lex-spp-dynamic-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 macros)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 (defun semantic-lex-spp-set-dynamic-table (new-entries) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 "Set the dynamic symbol table to NEW-ENTRIES. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 For use with semanticdb restoration of state." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 (dolist (e new-entries) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 ;; Default obarray for below is the dynamic map. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 (semantic-lex-spp-symbol-set (car e) (cdr e)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 (defun semantic-lex-spp-reset-hook (start end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 "Reset anything needed by SPP for parsing. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 In this case, reset the dynamic macro symbol table if |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 START is (point-min). |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 END is not used." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 (when (= start (point-min)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 (setq semantic-lex-spp-dynamic-macro-symbol-obarray nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 semantic-lex-spp-dynamic-macro-symbol-obarray-stack nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 ;; This shouldn't not be nil, but reset just in case. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 semantic-lex-spp-expanded-macro-stack nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 ;;; MACRO EXPANSION: Simple cases |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 ;; If a user fills in the table with simple strings, we can |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 ;; support that by converting them into tokens with the |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 ;; various analyzers that are available. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 (defun semantic-lex-spp-extract-regex-and-compare (analyzer value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 "Extract a regexp from an ANALYZER and use to match VALUE. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 Return non-nil if it matches" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 (let* ((condition (car analyzer)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 (regex (cond ((eq (car condition) 'looking-at) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 (nth 1 condition)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 (t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 nil)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 (when regex |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 (string-match regex value)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (defun semantic-lex-spp-simple-macro-to-macro-stream (val beg end argvalues) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 "Convert lexical macro contents VAL into a macro expansion stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 These are for simple macro expansions that a user may have typed in directly. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 As such, we need to analyze the input text, to figure out what kind of real |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 lexical token we should be inserting in its place. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 Argument VAL is the value of some macro to be converted into a stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 BEG and END are the token bounds of the macro to be expanded |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 that will somehow gain a much longer token stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 ARGVALUES are values for any arg list, or nil." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 (cond |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 ;; We perform a replacement. Technically, this should |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 ;; be a full lexical step over the "val" string, but take |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 ;; a guess that its just a keyword or existing symbol. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 ;; Probably a really bad idea. See how it goes. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 semantic-lex-symbol-or-keyword val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 (semantic-lex-token (or (semantic-lex-keyword-p val) 'symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 beg end |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 val))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 ;; Ok, the rest of these are various types of syntax. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 ;; Conveniences for users that type in their symbol table. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 semantic-lex-punctuation val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (semantic-lex-token 'punctuation beg end val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 semantic-lex-number val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 (semantic-lex-token 'number beg end val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 semantic-lex-paren-or-list val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 (semantic-lex-token 'semantic-list beg end val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 semantic-lex-string val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (semantic-lex-token 'string beg end val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 (t nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 ;;; MACRO EXPANSION : Lexical token replacement |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 ;; When substituting in a macro from a token stream of formatted |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 ;; semantic lex tokens, things can be much more complicated. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 ;; Some macros have arguments that get set into the dynamic macro |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 ;; table during replacement. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 ;; In general, the macro tokens are substituted into the regular |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 ;; token stream, but placed under the characters of the original |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 ;; macro symbol. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 ;; Argument lists are saved as a lexical token at the beginning |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 ;; of a replacement value. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 |
104434
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
381 (defun semantic-lex-spp-one-token-to-txt (tok &optional blocktok) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 "Convert the token TOK into a string. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 If TOK is made of multiple tokens, convert those to text. This |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 conversion is needed if a macro has a merge symbol in it that |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 combines the text of two previously distinct symbols. For |
105340 | 386 example, in c: |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 |
104434
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
388 #define (a,b) a ## b; |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
389 |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
390 If optional string BLOCKTOK matches the expanded value, then do not |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
391 continue processing recursively." |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 (let ((txt (semantic-lex-token-text tok)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 (sym nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 ) |
104434
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
395 (cond |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
396 ;; Recursion prevention |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
397 ((and (stringp blocktok) (string= txt blocktok)) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
398 blocktok) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
399 ;; A complex symbol |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
400 ((and (eq (car tok) 'symbol) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
401 (setq sym (semantic-lex-spp-symbol txt)) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
402 (not (semantic-lex-spp-macro-with-args (symbol-value sym))) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
403 ) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
404 ;; Now that we have a symbol, |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
405 (let ((val (symbol-value sym))) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
406 (cond |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
407 ;; This is another lexical token. |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
408 ((and (consp val) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
409 (symbolp (car val))) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
410 (semantic-lex-spp-one-token-to-txt val txt)) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
411 ;; This is a list of tokens. |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
412 ((and (consp val) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
413 (consp (car val)) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
414 (symbolp (car (car val)))) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
415 (mapconcat (lambda (subtok) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
416 (semantic-lex-spp-one-token-to-txt subtok)) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
417 val |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
418 "")) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
419 ;; If val is nil, that's probably wrong. |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
420 ;; Found a system header case where this was true. |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
421 ((null val) "") |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
422 ;; Debug wierd stuff. |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
423 (t (debug))) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
424 )) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
425 ((stringp txt) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
426 txt) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
427 (t nil)) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 (defun semantic-lex-spp-macro-with-args (val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 "If the macro value VAL has an argument list, return the arglist." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 (when (and val (consp val) (consp (car val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 (eq 'spp-arg-list (car (car val)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 (car (cdr (car val))))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 (defun semantic-lex-spp-token-macro-to-macro-stream (val beg end argvalues) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 "Convert lexical macro contents VAL into a macro expansion stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 Argument VAL is the value of some macro to be converted into a stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
439 BEG and END are the token bounds of the macro to be expanded |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
440 that will somehow gain a much longer token stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 ARGVALUES are values for any arg list, or nil. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
442 See comments in code for information about how token streams are processed |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 and what valid VAL values are." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
444 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
445 ;; A typical VAL value might be either a stream of tokens. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
446 ;; Tokens saved into a macro stream always includes the text from the |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
447 ;; buffer, since the locations specified probably don't represent |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
448 ;; that text anymore, or even the same buffer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
449 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
450 ;; CASE 1: Simple token stream |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
452 ;; #define SUPER mysuper:: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 ;; ==> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 ;;((symbol "mysuper" 480 . 487) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 ;; (punctuation ":" 487 . 488) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 ;; (punctuation ":" 488 . 489)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
457 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
458 ;; CASE 2: Token stream with argument list |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
459 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
460 ;; #define INT_FCN(name) int name (int in) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 ;; ==> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 ;; ((spp-arg-list ("name") 558 . 564) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 ;; (INT "int" 565 . 568) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
464 ;; (symbol "name" 569 . 573) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
465 ;; (semantic-list "(int in)" 574 . 582)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
466 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
467 ;; In the second case, a macro with an argument list as the a rgs as the |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 ;; first entry. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 ;; CASE 3: Symbol text merge |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 ;; #define TMP(a) foo_ ## a |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 ;; ==> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 ;; ((spp-arg-list ("a") 20 . 23) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 ;; (spp-symbol-merge ((symbol "foo_" 24 . 28) (symbol "a" 32 . 33)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 ;; 24 . 33)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 ;; Usually in conjunction with a macro with an argument, merging symbol |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
479 ;; parts is a way of fabricating new symbols from pieces inside the macro. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
480 ;; These macros use `spp-symbol-merge' tokens whose TEXT part is another |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
481 ;; token stream. This sub-stream ought to consist of only 2 SYMBOL pieces, |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 ;; though I suppose keywords might be ok. The end result of this example |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
483 ;; merge symbol would be (symbol "foo_A" 24 . 33) where A is the symbol |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 ;; passed in from the arg list "a". |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 ;; CASE 4: Nested token streams |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 ;; #define FOO(f) f |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
489 ;; #define BLA bla FOO(foo) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
490 ;; ==> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
491 ;; ((INT "int" 82 . 85) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 ;; (symbol "FOO" 86 . 89) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 ;; (semantic-list "(foo)" 89 . 94)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 ;; Nested token FOO shows up in the table of macros, and gets replace |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 ;; inline. This is the same as case 2. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
497 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
498 (let ((arglist (semantic-lex-spp-macro-with-args val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 (argalist nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 (val-tmp nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 (v nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
503 ;; CASE 2: Dealing with the arg list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
504 (when arglist |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
505 ;; Skip the arg list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 (setq val (cdr val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 ;; Push args into the replacement list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 (let ((AV argvalues)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 (dolist (A arglist) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 (let* ((argval (car AV))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 (semantic-lex-spp-symbol-push A argval) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
514 (setq argalist (cons (cons A argval) argalist)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
515 (setq AV (cdr AV))))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
516 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
517 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 ;; Set val-tmp after stripping arguments. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 (setq val-tmp val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
521 ;; CASE 1: Push everything else onto the list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 ;; Once the arg list is stripped off, CASE 2 is the same |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 ;; as CASE 1. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 (while val-tmp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 (setq v (car val-tmp)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
526 (setq val-tmp (cdr val-tmp)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 (let* (;; The text of the current lexical token. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 (txt (car (cdr v))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 ;; Try to convert txt into a macro declaration. If it is |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 ;; not a macro, use nil. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
532 (txt-macro-or-nil (semantic-lex-spp-symbol txt)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
533 ;; If our current token is a macro, then pull off the argument |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 ;; list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 (macro-and-args |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 (when txt-macro-or-nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
537 (semantic-lex-spp-macro-with-args (symbol-value txt-macro-or-nil))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
538 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
539 ;; We need to peek at the next token when testing for |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 ;; used macros with arg lists. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
541 (next-tok-class (semantic-lex-token-class (car val-tmp))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
542 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
543 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
544 (cond |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 ;; CASE 3: Merge symbols together. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
546 ((eq (semantic-lex-token-class v) 'spp-symbol-merge) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 ;; We need to merge the tokens in the 'text segement together, |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 ;; and produce a single symbol from it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 (let ((newsym |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 (mapconcat (lambda (tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
551 (semantic-lex-spp-one-token-to-txt tok)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 txt |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 ""))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 (semantic-lex-token 'symbol beg end newsym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
556 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
557 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
558 ;; CASE 2: Argument replacement. If a discovered symbol is in |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
559 ;; the active list of arguments, then we need to substitute |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 ;; in the new value. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
561 ((and (eq (semantic-lex-token-class v) 'symbol) txt-macro-or-nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 (or (and macro-and-args (eq next-tok-class 'semantic-list)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 (not macro-and-args)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 (let ((AV nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 (when macro-and-args |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 (setq AV |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 (semantic-lex-spp-stream-for-arglist (car val-tmp))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
569 ;; We used up these args. Pull from the stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 (setq val-tmp (cdr val-tmp)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
571 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
573 (semantic-lex-with-macro-used txt |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 ;; Don't recurse directly into this same fcn, because it is |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
575 ;; convenient to have plain string replacements too. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 (semantic-lex-spp-macro-to-macro-stream |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
577 (symbol-value txt-macro-or-nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
578 beg end AV)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
579 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
580 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
581 ;; This is a HACK for the C parser. The 'macros text |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
582 ;; property is some storage so that the parser can do |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
583 ;; some C specific text manipulations. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
584 ((eq (semantic-lex-token-class v) 'semantic-list) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
585 ;; Push our arg list onto the semantic list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
586 (when argalist |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
587 (setq txt (concat txt)) ; Copy the text. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
588 (put-text-property 0 1 'macros argalist txt)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
589 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
590 (semantic-lex-token (semantic-lex-token-class v) beg end txt)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
592 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
593 ;; CASE 1: Just another token in the stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
594 (t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
595 ;; Nothing new. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
596 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
597 (semantic-lex-token (semantic-lex-token-class v) beg end txt)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
599 ))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
600 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
601 ;; CASE 2: The arg list we pushed onto the symbol table |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 ;; must now be removed. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 (dolist (A arglist) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 (semantic-lex-spp-symbol-pop A)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
605 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 ;;; Macro Merging |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 ;; Used when token streams from different macros include eachother. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 ;; Merged macro streams perform in place replacements. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
611 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 (defun semantic-lex-spp-merge-streams (raw-stream) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 "Merge elements from the RAW-STREAM together. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
614 Handle spp-concat symbol concatenation. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
615 Handle Nested macro replacements. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 Return the cooked stream." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 (let ((cooked-stream nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
618 ;; Merge the stream |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 (while raw-stream |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
620 (cond ((eq (semantic-lex-token-class (car raw-stream)) 'spp-concat) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 ;; handle hashhash, by skipping it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 (setq raw-stream (cdr raw-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 ;; Now merge the symbols. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 (let ((prev-tok (car cooked-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
625 (next-tok (car raw-stream))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 (setq cooked-stream (cdr cooked-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
627 (push (semantic-lex-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 'spp-symbol-merge |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 (semantic-lex-token-start prev-tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 (semantic-lex-token-end next-tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 (list prev-tok next-tok)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 cooked-stream) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 (t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 (push (car raw-stream) cooked-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 (setq raw-stream (cdr raw-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
638 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
639 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 (nreverse cooked-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
641 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 ;;; MACRO EXPANSION |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 ;; There are two types of expansion. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
647 ;; 1. Expansion using a value made up of lexical tokens. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
648 ;; 2. User input replacement from a plain string. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 (defun semantic-lex-spp-macro-to-macro-stream (val beg end argvalues) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
651 "Convert lexical macro contents VAL into a macro expansion stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
652 Argument VAL is the value of some macro to be converted into a stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
653 BEG and END are the token bounds of the macro to be expanded |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
654 that will somehow gain a much longer token stream. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
655 ARGVALUES are values for any arg list, or nil." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
656 (cond |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
657 ;; If val is nil, then just skip it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 ((null val) t) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
659 ;; If it is a token, then return that token rebuilt. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
660 ((and (consp val) (car val) (symbolp (car val))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
662 (semantic-lex-token (car val) beg end (semantic-lex-token-text val)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
663 ;; Test for a token list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
664 ((and (consp val) (consp (car val)) (car (car val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 (symbolp (car (car val)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
666 (semantic-lex-spp-token-macro-to-macro-stream val beg end argvalues)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
667 ;; Test for miscellaneous strings. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 ((stringp val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
669 (semantic-lex-spp-simple-macro-to-macro-stream val beg end argvalues)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
670 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
671 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
672 ;;; -------------------------------------------------------- |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
673 ;;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 ;;; ANALYZERS: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
675 ;;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
676 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 ;;; Symbol Is Macro |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
679 ;; An analyser that will push tokens from a macro in place |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 ;; of the macro symbol. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
681 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
682 (defun semantic-lex-spp-anlyzer-do-replace (sym val beg end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
683 "Do the lexical replacement for SYM with VAL. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
684 Argument BEG and END specify the bounds of SYM in the buffer." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
685 (if (not val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 (setq semantic-lex-end-point end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 (let ((arg-in nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 (arg-parsed nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 (arg-split nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
690 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
691 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 ;; Check for arguments. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 (setq arg-in (semantic-lex-spp-macro-with-args val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (when arg-in |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 (save-excursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 (goto-char end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 (setq arg-parsed |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 (semantic-lex-spp-one-token-and-move-for-macro |
105692
15b4b661ceb1
* cedet/semantic/bovine/c.el (semantic-c-debug-mode-init)
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
700 ;; NOTE: This used to be (point-at-eol), but |
15b4b661ceb1
* cedet/semantic/bovine/c.el (semantic-c-debug-mode-init)
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
701 ;; that was too close for multi-line arguments |
15b4b661ceb1
* cedet/semantic/bovine/c.el (semantic-c-debug-mode-init)
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
702 ;; to a macro. Point max may be too far if there |
15b4b661ceb1
* cedet/semantic/bovine/c.el (semantic-c-debug-mode-init)
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
703 ;; is a typo in the buffer. |
15b4b661ceb1
* cedet/semantic/bovine/c.el (semantic-c-debug-mode-init)
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
704 ;; |
15b4b661ceb1
* cedet/semantic/bovine/c.el (semantic-c-debug-mode-init)
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
705 ;; Look here for performance issues while a user is typing |
15b4b661ceb1
* cedet/semantic/bovine/c.el (semantic-c-debug-mode-init)
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
706 ;; incomplete code. |
15b4b661ceb1
* cedet/semantic/bovine/c.el (semantic-c-debug-mode-init)
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
707 (point-max))) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
708 (setq end (semantic-lex-token-end arg-parsed)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
710 (when (and (listp arg-parsed) (eq (car arg-parsed) 'semantic-list)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
711 (setq arg-split |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
712 ;; Use lex to split up the contents of the argument list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 (semantic-lex-spp-stream-for-arglist arg-parsed) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
715 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
717 ;; if we have something to sub in, then do it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
718 (semantic-lex-spp-macro-to-macro-stream val beg end arg-split) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 (setq semantic-lex-end-point end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 (defvar semantic-lex-spp-replacements-enabled t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 "Non-nil means do replacements when finding keywords. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
725 Disable this only to prevent recursive expansion issues.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
726 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 (defun semantic-lex-spp-analyzer-push-tokens-for-symbol (str beg end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
728 "Push lexical tokens for the symbol or keyword STR. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 STR occurs in the current buffer between BEG and END." |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104434
diff
changeset
|
730 (let (sym val count) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
731 (cond |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
733 ;; It is a macro. Prepare for a replacement. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
734 ((and semantic-lex-spp-replacements-enabled |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 (semantic-lex-spp-symbol-p str)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 (setq sym (semantic-lex-spp-symbol str) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
737 val (symbol-value sym) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 count 0) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 (let ((semantic-lex-spp-expanded-macro-stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 semantic-lex-spp-expanded-macro-stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
743 (semantic-lex-with-macro-used str |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
744 ;; Do direct replacements of single value macros of macros. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
745 ;; This solves issues with a macro containing one symbol that |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
746 ;; is another macro, and get arg lists passed around. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
747 (while (and val (consp val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
748 (semantic-lex-token-p (car val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
749 (eq (length val) 1) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
750 (eq (semantic-lex-token-class (car val)) 'symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
751 (semantic-lex-spp-symbol-p (semantic-lex-token-text (car val))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
752 (< count 10) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
753 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 (setq str (semantic-lex-token-text (car val))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 (setq sym (semantic-lex-spp-symbol str) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 val (symbol-value sym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 ;; Prevent recursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 (setq count (1+ count)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 ;; This prevents a different kind of recursion. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
760 (push str semantic-lex-spp-expanded-macro-stack) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
761 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
762 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
763 (semantic-lex-spp-anlyzer-do-replace sym val beg end)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
765 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
766 ;; Anything else. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
767 (t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
768 ;; A regular keyword. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 (semantic-lex-token (or (semantic-lex-keyword-p str) 'symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 beg end)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 (define-lex-regex-analyzer semantic-lex-spp-replace-or-symbol-or-keyword |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 "Like 'semantic-lex-symbol-or-keyword' plus preprocessor macro replacement." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
776 "\\(\\sw\\|\\s_\\)+" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
777 (let ((str (match-string 0)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
778 (beg (match-beginning 0)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
779 (end (match-end 0))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
780 (semantic-lex-spp-analyzer-push-tokens-for-symbol str beg end))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
781 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
782 ;;; ANALYZERS FOR NEW MACROS |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
783 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
784 ;; These utilities and analyzer declaration function are for |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 ;; creating an analyzer which produces new macros in the macro table. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
787 ;; There are two analyzers. One for new macros, and one for removing |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
788 ;; a macro. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
789 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 (defun semantic-lex-spp-first-token-arg-list (token) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 "If TOKEN is a semantic-list, turn it into a an SPP ARG LIST." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 (when (and (consp token) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 (symbolp (car token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 (eq 'semantic-list (car token))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
795 ;; Convert TOKEN in place. |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104434
diff
changeset
|
796 (let ((argsplit (split-string (semantic-lex-token-text token) |
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104434
diff
changeset
|
797 "[(), ]" t))) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
798 (setcar token 'spp-arg-list) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (setcar (nthcdr 1 token) argsplit)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
800 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
801 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
802 (defun semantic-lex-spp-one-token-and-move-for-macro (max) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
803 "Lex up one token, and move to end of that token. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
804 Don't go past MAX." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
805 (let ((ans (semantic-lex (point) max 0 0))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
806 (if (not ans) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
807 (progn (goto-char max) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
808 nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
809 (when (> (semantic-lex-token-end (car ans)) max) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
810 (let ((bounds (semantic-lex-token-bounds (car ans)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
811 (setcdr bounds max))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 (goto-char (semantic-lex-token-end (car ans))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
813 (car ans)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
815 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
816 (defun semantic-lex-spp-stream-for-arglist (token) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
817 "Lex up the contents of the arglist TOKEN. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
818 Parsing starts inside the parens, and ends at the end of TOKEN." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
819 (let ((end (semantic-lex-token-end token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
820 (fresh-toks nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 (toks nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 (save-excursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
823 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
824 (if (stringp (nth 1 token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
825 ;; If the 2nd part of the token is a string, then we have |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
826 ;; a token specifically extracted from a buffer. Possibly |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
827 ;; a different buffer. This means we need to do something |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
828 ;; nice to parse its contents. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 (let ((txt (semantic-lex-token-text token))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
830 (semantic-lex-spp-lex-text-string |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 (substring txt 1 (1- (length txt))))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
832 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
833 ;; This part is like the original |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 (goto-char (semantic-lex-token-start token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 ;; A cheat for going into the semantic list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 (forward-char 1) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
837 (setq fresh-toks (semantic-lex-spp-stream-for-macro (1- end))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
838 (dolist (tok fresh-toks) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
839 (when (memq (semantic-lex-token-class tok) '(symbol semantic-list)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
840 (setq toks (cons tok toks)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
841 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
842 (nreverse toks))))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
843 |
104489
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
844 (defvar semantic-lex-spp-hack-depth 0 |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
845 "Current depth of recursive calls to `semantic-lex-spp-lex-text-string'.") |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
846 |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
847 (defun semantic-lex-spp-lex-text-string (text) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 "Lex the text string TEXT using the current buffer's state. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
849 Use this to parse text extracted from a macro as if it came from |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 the current buffer. Since the lexer is designed to only work in |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
851 a buffer, we need to create a new buffer, and populate it with rules |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
852 and variable state from the current buffer." |
104489
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
853 (let* ((semantic-lex-spp-hack-depth (1+ semantic-lex-spp-hack-depth)) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
854 (buf (get-buffer-create (format " *SPP parse hack %d*" |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
855 semantic-lex-spp-hack-depth))) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
856 (mode major-mode) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
857 (fresh-toks nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
858 (toks nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
859 (origbuff (current-buffer)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
860 (important-vars '(semantic-lex-spp-macro-symbol-obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
861 semantic-lex-spp-project-macro-symbol-obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
862 semantic-lex-spp-dynamic-macro-symbol-obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
863 semantic-lex-spp-dynamic-macro-symbol-obarray-stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
864 semantic-lex-spp-expanded-macro-stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
865 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
866 ) |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105692
diff
changeset
|
867 (with-current-buffer buf |
104434
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
868 (erase-buffer) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
869 ;; Below is a painful hack to make sure everything is setup correctly. |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
870 (when (not (eq major-mode mode)) |
104492
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
871 (save-match-data |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
872 |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
873 ;; Protect against user-hooks that throw errors. |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
874 (condition-case nil |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
875 (funcall mode) |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
876 (error nil)) |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104493
diff
changeset
|
877 |
104492
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
878 ;; Hack in mode-local |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
879 (activate-mode-local-bindings) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
880 ;; CHEATER! The following 3 lines are from |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
881 ;; `semantic-new-buffer-fcn', but we don't want to turn |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
882 ;; on all the other annoying modes for this little task. |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
883 (setq semantic-new-buffer-fcn-was-run t) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
884 (semantic-lex-init) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
885 (semantic-clear-toplevel-cache) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
886 (remove-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
887 t) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
888 )) |
104434
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
889 |
104492
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
890 ;; Second Cheat: copy key variables regarding macro state from the |
104434
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
891 ;; the originating buffer we are parsing. We need to do this every time |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
892 ;; since the state changes. |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
893 (dolist (V important-vars) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
894 (set V (semantic-buffer-local-value V origbuff))) |
104434
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
895 (insert text) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
896 (goto-char (point-min)) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
897 |
104434
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
898 (setq fresh-toks (semantic-lex-spp-stream-for-macro (point-max)))) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
899 |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
900 (dolist (tok fresh-toks) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
901 (when (memq (semantic-lex-token-class tok) '(symbol semantic-list)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
902 (setq toks (cons tok toks)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
903 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
904 (nreverse toks))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
905 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
906 ;;;; FIRST DRAFT |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
907 ;; This is the fist version of semantic-lex-spp-stream-for-arglist |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
908 ;; that worked pretty well. It doesn't work if the TOKEN was derived |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
909 ;; from some other buffer, in which case it can get the wrong answer |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
910 ;; or throw an error if the token location in the originating buffer is |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
911 ;; larger than the current buffer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 ;;(defun semantic-lex-spp-stream-for-arglist-orig (token) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
913 ;; "Lex up the contents of the arglist TOKEN. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
914 ;; Parsing starts inside the parens, and ends at the end of TOKEN." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
915 ;; (save-excursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
916 ;; (let ((end (semantic-lex-token-end token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
917 ;; (fresh-toks nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
918 ;; (toks nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
919 ;; (goto-char (semantic-lex-token-start token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
920 ;; ;; A cheat for going into the semantic list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
921 ;; (forward-char 1) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
922 ;; (setq fresh-toks (semantic-lex-spp-stream-for-macro (1- end))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
923 ;; (dolist (tok fresh-toks) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 ;; (when (memq (semantic-lex-token-class tok) '(symbol semantic-list)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
925 ;; (setq toks (cons tok toks)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
926 ;; (nreverse toks)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
927 ;; )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
928 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
929 ;;;; USING SPLIT |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 ;; This doesn't work, because some arguments passed into a macro |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
931 ;; might contain non-simple symbol words, which this doesn't handle. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
932 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
933 ;; Thus, you need a full lex to occur. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
934 ;; (defun semantic-lex-spp-stream-for-arglist-split (token) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
935 ;; "Lex up the contents of the arglist TOKEN. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
936 ;; Parsing starts inside the parens, and ends at the end of TOKEN." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
937 ;; (let* ((txt (semantic-lex-token-text token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
938 ;; (split (split-string (substring txt 1 (1- (length txt))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
939 ;; "(), " t)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
940 ;; ;; Hack for lexing. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
941 ;; (semantic-lex-spp-analyzer-push-tokens-for-symbol nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
942 ;; (dolist (S split) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 ;; (semantic-lex-spp-analyzer-push-tokens-for-symbol S 0 1)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 ;; (reverse semantic-lex-spp-analyzer-push-tokens-for-symbol))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
945 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
946 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
947 (defun semantic-lex-spp-stream-for-macro (eos) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
948 "Lex up a stream of tokens for a #define statement. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
949 Parsing starts at the current point location. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
950 EOS is the end of the stream to lex for this macro." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
951 (let ((stream nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
952 (while (< (point) eos) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
953 (let* ((tok (semantic-lex-spp-one-token-and-move-for-macro eos)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
954 (str (when tok |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
955 (semantic-lex-token-text tok))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
956 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
957 (if str |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
958 (push (semantic-lex-token (semantic-lex-token-class tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
959 (semantic-lex-token-start tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
960 (semantic-lex-token-end tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
961 str) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
962 stream) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
963 ;; Nothing to push. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
964 nil))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
965 (goto-char eos) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
966 ;; Fix the order |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
967 (nreverse stream) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
968 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
969 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
970 (defmacro define-lex-spp-macro-declaration-analyzer (name doc regexp tokidx |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
971 &rest valform) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
972 "Define a lexical analyzer for defining new MACROS. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
973 NAME is the name of the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
974 DOC is the documentation for the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
975 REGEXP is a regular expression for the analyzer to match. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
976 See `define-lex-regex-analyzer' for more on regexp. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
977 TOKIDX is an index into REGEXP for which a new lexical token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
978 of type `spp-macro-def' is to be created. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
979 VALFORM are forms that return the value to be saved for this macro, or nil. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
980 When implementing a macro, you can use `semantic-lex-spp-stream-for-macro' |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
981 to convert text into a lexical stream for storage in the macro." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
982 (let ((start (make-symbol "start")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
983 (end (make-symbol "end")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
984 (val (make-symbol "val")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
985 (startpnt (make-symbol "startpnt")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
986 (endpnt (make-symbol "endpnt"))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
987 `(define-lex-regex-analyzer ,name |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
988 ,doc |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
989 ,regexp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
990 (let ((,start (match-beginning ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
991 (,end (match-end ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
992 (,startpnt semantic-lex-end-point) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
993 (,val (save-match-data ,@valform)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
994 (,endpnt semantic-lex-end-point)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
995 (semantic-lex-spp-symbol-set |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
996 (buffer-substring-no-properties ,start ,end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
997 ,val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
998 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
999 (semantic-lex-token 'spp-macro-def |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1000 ,start ,end)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1001 ;; Preserve setting of the end point from the calling macro. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1002 (when (and (/= ,startpnt ,endpnt) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1003 (/= ,endpnt semantic-lex-end-point)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1004 (setq semantic-lex-end-point ,endpnt)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1005 )))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1006 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1007 (defmacro define-lex-spp-macro-undeclaration-analyzer (name doc regexp tokidx) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1008 "Undefine a lexical analyzer for defining new MACROS. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1009 NAME is the name of the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1010 DOC is the documentation for the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1011 REGEXP is a regular expression for the analyzer to match. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1012 See `define-lex-regex-analyzer' for more on regexp. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1013 TOKIDX is an index into REGEXP for which a new lexical token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1014 of type `spp-macro-undef' is to be created." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1015 (let ((start (make-symbol "start")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1016 (end (make-symbol "end"))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1017 `(define-lex-regex-analyzer ,name |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1018 ,doc |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1019 ,regexp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1020 (let ((,start (match-beginning ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1021 (,end (match-end ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1022 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1023 (semantic-lex-spp-symbol-remove |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1024 (buffer-substring-no-properties ,start ,end)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1025 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1026 (semantic-lex-token 'spp-macro-undef |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1027 ,start ,end)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1028 )))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1029 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1030 ;;; INCLUDES |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1031 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1032 ;; These analyzers help a language define how include files |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1033 ;; are identified. These are ONLY for languages that perform |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1034 ;; an actual textual includesion, and not for imports. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1035 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1036 ;; This section is supposed to allow the macros from the headers to be |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1037 ;; added to the local dynamic macro table, but that hasn't been |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1038 ;; written yet. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1039 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1040 (defcustom semantic-lex-spp-use-headers-flag nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1041 "*Non-nil means to pre-parse headers as we go. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1042 For languages that use the Semantic pre-processor, this can |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1043 improve the accuracy of parsed files where include files |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1044 can change the state of what's parsed in the current file. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1045 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1046 Note: Note implemented yet" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1047 :group 'semantic |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1048 :type 'boolean) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1049 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1050 (defun semantic-lex-spp-merge-header (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1051 "Extract and merge any macros from the header with NAME. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1052 Finds the header file belonging to NAME, gets the macros |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1053 from that file, and then merge the macros with our current |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1054 symbol table." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1055 (when semantic-lex-spp-use-headers-flag |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1056 ;; @todo - do this someday, ok? |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1057 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1058 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1059 (defmacro define-lex-spp-include-analyzer (name doc regexp tokidx |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1060 &rest valform) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1061 "Define a lexical analyzer for defining a new INCLUDE lexical token. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1062 Macros defined in the found include will be added to our running table |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1063 at the time the include statement is found. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1064 NAME is the name of the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1065 DOC is the documentation for the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1066 REGEXP is a regular expression for the analyzer to match. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1067 See `define-lex-regex-analyzer' for more on regexp. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1068 TOKIDX is an index into REGEXP for which a new lexical token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1069 of type `spp-macro-include' is to be created. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1070 VALFORM are forms that return the name of the thing being included, and the |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1071 type of include. The return value should be of the form: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1072 (NAME . TYPE) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1073 where NAME is the name of the include, and TYPE is the type of the include, |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1074 where a valid symbol is 'system, or nil." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1075 (let ((start (make-symbol "start")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1076 (end (make-symbol "end")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1077 (val (make-symbol "val")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1078 (startpnt (make-symbol "startpnt")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1079 (endpnt (make-symbol "endpnt"))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1080 `(define-lex-regex-analyzer ,name |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1081 ,doc |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1082 ,regexp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1083 (let ((,start (match-beginning ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1084 (,end (match-end ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1085 (,startpnt semantic-lex-end-point) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1086 (,val (save-match-data ,@valform)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1087 (,endpnt semantic-lex-end-point)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1088 ;;(message "(car ,val) -> %S" (car ,val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1089 (semantic-lex-spp-merge-header (car ,val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1090 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1091 (semantic-lex-token (if (eq (cdr ,val) 'system) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1092 'spp-system-include |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1093 'spp-include) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1094 ,start ,end |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1095 (car ,val))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1096 ;; Preserve setting of the end point from the calling macro. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1097 (when (and (/= ,startpnt ,endpnt) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1098 (/= ,endpnt semantic-lex-end-point)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1099 (setq semantic-lex-end-point ,endpnt)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1100 )))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1101 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1102 ;;; EIEIO USAGE |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1103 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1104 ;; Semanticdb can save off macro tables for quick lookup later. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1105 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1106 ;; These routines are for saving macro lists into an EIEIO persistent |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1107 ;; file. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1108 (defvar semantic-lex-spp-macro-max-length-to-save 200 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1109 "*Maximum length of an SPP macro before we opt to not save it.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1110 |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
1111 ;;;###autoload |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1112 (defun semantic-lex-spp-table-write-slot-value (value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1113 "Write out the VALUE of a slot for EIEIO. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1114 The VALUE is a spp lexical table." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1115 (if (not value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1116 (princ "nil") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1117 (princ "\n '(") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1118 ;(princ value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1119 (dolist (sym value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1120 (princ "(") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1121 (prin1 (car sym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1122 (let* ((first (car (cdr sym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1123 (rest (cdr sym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1124 (when (not (listp first)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1125 (error "Error in macro \"%s\"" (car sym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1126 (when (eq (car first) 'spp-arg-list) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1127 (princ " ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1128 (prin1 first) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1129 (setq rest (cdr rest)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1130 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1131 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1132 (when rest |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1133 (princ " . ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1134 (let ((len (length (cdr rest)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1135 (cond ((< len 2) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1136 (condition-case nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1137 (prin1 rest) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1138 (error |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1139 (princ "nil ;; Error writing macro\n")))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1140 ((< len semantic-lex-spp-macro-max-length-to-save) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1141 (princ "\n ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1142 (condition-case nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1143 (prin1 rest) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1144 (error |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1145 (princ "nil ;; Error writing macro\n "))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1146 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1147 (t ;; Too Long! |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1148 (princ "nil ;; Too Long!\n ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1149 )))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1150 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1151 (princ ")\n ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1152 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1153 (princ ")\n")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1154 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1155 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1156 ;;; MACRO TABLE DEBUG |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1157 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1158 (defun semantic-lex-spp-describe (&optional buffer) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1159 "Describe the current list of spp macros for BUFFER. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1160 If BUFFER is not provided, use the current buffer." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1161 (interactive) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1162 (let ((syms (save-excursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1163 (if buffer (set-buffer buffer)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1164 (semantic-lex-spp-macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1165 (sym nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1166 (with-output-to-temp-buffer "*SPP MACROS*" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1167 (princ "Macro\t\tValue\n") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1168 (while syms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1169 (setq sym (car syms) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1170 syms (cdr syms)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1171 (princ (symbol-name sym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1172 (princ "\t") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1173 (if (< (length (symbol-name sym)) 8) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1174 (princ "\t")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1175 (prin1 (symbol-value sym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1176 (princ "\n") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1177 )))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1178 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1179 ;;; EDEBUG Handlers |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1180 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1181 (add-hook |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1182 'edebug-setup-hook |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1183 #'(lambda () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1184 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1185 (def-edebug-spec define-lex-spp-macro-declaration-analyzer |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1186 (&define name stringp stringp form def-body) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1187 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1188 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1189 (def-edebug-spec define-lex-spp-macro-undeclaration-analyzer |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1190 (&define name stringp stringp form) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1191 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1192 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1193 (def-edebug-spec define-lex-spp-include-analyzer |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
1194 (&define name stringp stringp form def-body)))) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1195 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1196 (provide 'semantic/lex-spp) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1197 |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
1198 ;; Local variables: |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
1199 ;; generated-autoload-file: "loaddefs.el" |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
1200 ;; generated-autoload-load-name: "semantic/lex-spp" |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
1201 ;; End: |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
1202 |
105377 | 1203 ;; arch-tag: 8877d83e-07ea-4d86-a960-e3562138d8a5 |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1204 ;;; semantic-lex-spp.el ends here |