Mercurial > emacs
annotate lisp/cedet/semantic/lex-spp.el @ 104434:dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 30 Aug 2009 02:16:46 +0000 |
parents | c13af98da4d6 |
children | df08b7ab0ba0 |
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 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3 ;;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
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 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 (require 'semantic/lex) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 ;;; Code: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 (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
|
74 "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
|
75 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
|
76 `semantic-lex-spp-dynamic-macro-symbol-obarray'.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 (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
|
78 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 (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
|
80 "Table of macro keywords for this project. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 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
|
82 `semantic-lex-spp-dynamic-macro-symbol-obarray'.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 (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
|
84 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 (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
|
86 "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
|
87 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
|
88 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
|
89 added and removed from this symbol table.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 (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
|
91 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 (defvar 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
|
93 "A stack of obarrays for temporarilly scoped macro values.") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 (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
|
95 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 (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
|
97 "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
|
98 ;; 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
|
99 ;; 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
|
100 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 ;;; NON-RECURSIVE MACRO STACK |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 ;; 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
|
103 ;; 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
|
104 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 (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
|
106 "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
|
107 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
|
108 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
|
109 currently being expanded." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 `(unwind-protect |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 (progn |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 (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
|
113 ,@body) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 (pop semantic-lex-spp-expanded-macro-stack))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 (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
|
116 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 (add-hook |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 'edebug-setup-hook |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 #'(lambda () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 (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
|
122 (symbolp def-body) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 ) |
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 ;;; MACRO TABLE UTILS |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 ;; 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
|
130 ;; 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
|
131 ;; 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
|
132 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 (defsubst semantic-lex-spp-symbol (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 "Return spp symbol with NAME or nil if not found. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 The searcy priority is: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 1. DYNAMIC symbols |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 2. PROJECT specified symbols. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 3. SYSTEM specified symbols." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 (and |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 ;; Only strings... |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 (stringp name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 ;; Make sure we don't recurse. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 (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
|
144 ;; Do the check of the various tables. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 (or |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 ;; DYNAMIC |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 (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
|
148 (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
|
149 ;; PROJECT |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 (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
|
151 (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
|
152 ;; SYSTEM |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 (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
|
154 (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
|
155 ;; ... |
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 (defsubst semantic-lex-spp-symbol-p (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 "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
|
160 (if (semantic-lex-spp-symbol name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 t)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 (defsubst semantic-lex-spp-dynamic-map () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 "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
|
165 (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
|
166 (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
|
167 (make-vector 13 0)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 (defsubst semantic-lex-spp-dynamic-map-stack () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 "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
|
171 (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
|
172 (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
|
173 (make-vector 13 0)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 (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
|
176 "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
|
177 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
|
178 the dynamic map." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 (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
|
180 (set (intern name (or obarray-in |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 (semantic-lex-spp-dynamic-map))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 value)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 (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
|
185 "Remove the spp symbol with NAME. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 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
|
187 the dynamic map." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 (unintern name (or obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 (semantic-lex-spp-dynamic-map)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 (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
|
192 "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
|
193 Reverse with `semantic-lex-spp-symbol-pop'." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (let* ((map (semantic-lex-spp-dynamic-map)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (stack (semantic-lex-spp-dynamic-map-stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 (mapsym (intern name map)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 (stacksym (intern name stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (mapvalue (when (boundp mapsym) (symbol-value mapsym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 (when (boundp mapsym) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 ;; Make sure there is a stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 (if (not (boundp stacksym)) (set stacksym nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 ;; 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
|
204 (set stacksym (cons mapvalue (symbol-value stacksym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 ;; Set our new value here. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 (set mapsym value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 )) |
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 (defun semantic-lex-spp-symbol-pop (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 "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
|
212 Reverse with `semantic-lex-spp-symbol-pop'." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 (let* ((map (semantic-lex-spp-dynamic-map)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 (stack (semantic-lex-spp-dynamic-map-stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (mapsym (intern name map)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 (stacksym (intern name stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 (oldvalue nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 (if (or (not (boundp stacksym) ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 (= (length (symbol-value stacksym)) 0)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 ;; Nothing to pop, remove it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 (unintern name map) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 ;; 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
|
224 (set mapsym (car (symbol-value stacksym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 (set stacksym (cdr (symbol-value stacksym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 ))) |
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 (defsubst semantic-lex-spp-symbol-stream (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 "Return replacement stream of macro with NAME." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 (let ((spp (semantic-lex-spp-symbol name))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 (if spp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 (symbol-value spp)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 (defun semantic-lex-make-spp-table (specs) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 "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
|
236 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
|
237 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 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
|
239 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
|
240 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 ;; Create the symbol hash table |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 (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
|
243 spec) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 ;; fill it with stuff |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 (while specs |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 (setq spec (car specs) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 specs (cdr specs)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 (semantic-lex-spp-symbol-set |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 (car spec) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 (cdr spec) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 semantic-lex-spp-macro-symbol-obarray)) |
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 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 (defun semantic-lex-spp-save-table () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 "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
|
256 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
|
257 (let (macros) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 (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
|
259 (mapatoms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 #'(lambda (symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (setq macros (cons (cons (symbol-name symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 (symbol-value symbol)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 semantic-lex-spp-dynamic-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 macros)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 (defun semantic-lex-spp-macros () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 "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
|
269 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
|
270 (let (macros) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 (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
|
272 (mapatoms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 #'(lambda (symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 (setq macros (cons symbol macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 semantic-lex-spp-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 (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
|
277 (mapatoms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 #'(lambda (symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 (setq macros (cons symbol macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 semantic-lex-spp-project-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 (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
|
282 (mapatoms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 #'(lambda (symbol) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 (setq macros (cons symbol macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 semantic-lex-spp-dynamic-macro-symbol-obarray)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 macros)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 (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
|
289 "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
|
290 For use with semanticdb restoration of state." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 (dolist (e new-entries) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 ;; 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
|
293 (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
|
294 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 (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
|
296 "Reset anything needed by SPP for parsing. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 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
|
298 START is (point-min). |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 END is not used." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 (when (= start (point-min)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 (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
|
302 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
|
303 ;; 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
|
304 semantic-lex-spp-expanded-macro-stack nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 )) |
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 ;;; MACRO EXPANSION: Simple cases |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 ;; 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
|
310 ;; 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
|
311 ;; various analyzers that are available. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 (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
|
314 "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
|
315 Return non-nil if it matches" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 (let* ((condition (car analyzer)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 (regex (cond ((eq (car condition) 'looking-at) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 (nth 1 condition)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 (t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 nil)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 (when regex |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 (string-match regex value)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 )) |
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 (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
|
326 "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
|
327 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
|
328 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
|
329 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
|
330 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 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
|
332 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
|
333 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
|
334 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
|
335 (cond |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 ;; We perform a replacement. Technically, this should |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 ;; 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
|
338 ;; 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
|
339 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 ;; 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
|
341 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 semantic-lex-symbol-or-keyword val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 (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
|
345 beg end |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 val))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 ;; 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
|
349 ;; 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
|
350 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 semantic-lex-punctuation val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 (semantic-lex-token 'punctuation beg end val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 semantic-lex-number val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 (semantic-lex-token 'number beg end val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 semantic-lex-paren-or-list val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 (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
|
359 ((semantic-lex-spp-extract-regex-and-compare |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 semantic-lex-string val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 (semantic-lex-token 'string beg end val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (t nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 )) |
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 ;;; MACRO EXPANSION : Lexical token replacement |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 ;; 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
|
368 ;; 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
|
369 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 ;; 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
|
371 ;; table during replacement. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 ;; 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
|
374 ;; 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
|
375 ;; macro symbol. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 ;; 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
|
378 ;; of a replacement value. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 |
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
|
380 (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
|
381 "Convert the token TOK into a string. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 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
|
383 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
|
384 combines the text of two previously distinct symbols. For |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 exampe, in c: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 |
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
|
387 #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
|
388 |
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 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
|
390 continue processing recursively." |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (let ((txt (semantic-lex-token-text tok)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 (sym nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 ) |
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
|
394 (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
|
395 ;; 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
|
396 ((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
|
397 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 ;; 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
|
399 ((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
|
400 (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
|
401 (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
|
402 ) |
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 ;; 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
|
404 (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
|
405 (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
|
406 ;; 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
|
407 ((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
|
408 (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
|
409 (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
|
410 ;; 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
|
411 ((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
|
412 (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
|
413 (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
|
414 (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
|
415 (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
|
416 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
|
417 "")) |
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 ;; 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
|
419 ;; 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
|
420 ((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
|
421 ;; 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
|
422 (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
|
423 )) |
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 ((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
|
425 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 (t nil)) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 )) |
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 (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
|
430 "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
|
431 (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
|
432 (eq 'spp-arg-list (car (car val)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 (car (cdr (car val))))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 (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
|
436 "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
|
437 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
|
438 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
|
439 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
|
440 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
|
441 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
|
442 and what valid VAL values are." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
444 ;; 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
|
445 ;; 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
|
446 ;; 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
|
447 ;; 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
|
448 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
449 ;; CASE 1: Simple token stream |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
450 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 ;; #define SUPER mysuper:: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
452 ;; ==> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 ;;((symbol "mysuper" 480 . 487) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 ;; (punctuation ":" 487 . 488) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 ;; (punctuation ":" 488 . 489)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
457 ;; CASE 2: Token stream with argument list |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
458 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
459 ;; #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
|
460 ;; ==> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 ;; ((spp-arg-list ("name") 558 . 564) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 ;; (INT "int" 565 . 568) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 ;; (symbol "name" 569 . 573) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
464 ;; (semantic-list "(int in)" 574 . 582)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
465 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
466 ;; 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
|
467 ;; first entry. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 ;; CASE 3: Symbol text merge |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 ;; #define TMP(a) foo_ ## a |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 ;; ==> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 ;; ((spp-arg-list ("a") 20 . 23) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 ;; (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
|
475 ;; 24 . 33)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 ;; 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
|
478 ;; 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
|
479 ;; 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
|
480 ;; 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
|
481 ;; 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
|
482 ;; 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
|
483 ;; passed in from the arg list "a". |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 ;; CASE 4: Nested token streams |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 ;; #define FOO(f) f |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 ;; #define BLA bla FOO(foo) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
489 ;; ==> |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
490 ;; ((INT "int" 82 . 85) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
491 ;; (symbol "FOO" 86 . 89) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 ;; (semantic-list "(foo)" 89 . 94)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 ;; 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
|
495 ;; 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
|
496 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
497 (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
|
498 (argalist nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 (val-tmp nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 (v nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 ;; CASE 2: Dealing with the arg list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
503 (when arglist |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
504 ;; Skip the arg list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
505 (setq val (cdr val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 ;; Push args into the replacement list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 (let ((AV argvalues)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 (dolist (A arglist) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 (let* ((argval (car AV))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 (semantic-lex-spp-symbol-push A argval) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 (setq argalist (cons (cons A argval) argalist)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
514 (setq AV (cdr AV))))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
515 ) |
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 ;; Set val-tmp after stripping arguments. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 (setq val-tmp val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 ;; 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
|
521 ;; 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
|
522 ;; as CASE 1. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 (while val-tmp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 (setq v (car val-tmp)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 (setq val-tmp (cdr val-tmp)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
526 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 (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
|
528 (txt (car (cdr v))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 ;; 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
|
530 ;; not a macro, use nil. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 (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
|
532 ;; 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
|
533 ;; list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 (macro-and-args |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 (when txt-macro-or-nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 (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
|
537 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
538 ;; 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
|
539 ;; used macros with arg lists. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 (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
|
541 ) |
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 (cond |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
544 ;; CASE 3: Merge symbols together. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 ((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
|
546 ;; 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
|
547 ;; and produce a single symbol from it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 (let ((newsym |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 (mapconcat (lambda (tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 (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
|
551 txt |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 ""))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 (semantic-lex-token 'symbol beg end newsym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 )) |
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 ;; 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
|
558 ;; 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
|
559 ;; in the new value. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 ((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
|
561 (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
|
562 (not macro-and-args)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 (let ((AV nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 (when macro-and-args |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 (setq AV |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 (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
|
568 ;; 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
|
569 (setq val-tmp (cdr val-tmp)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 ) |
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 (semantic-lex-with-macro-used txt |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
573 ;; 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
|
574 ;; convenient to have plain string replacements too. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
575 (semantic-lex-spp-macro-to-macro-stream |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 (symbol-value txt-macro-or-nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
577 beg end AV)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
578 )) |
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 ;; 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
|
581 ;; 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
|
582 ;; some C specific text manipulations. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
583 ((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
|
584 ;; 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
|
585 (when argalist |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
586 (setq txt (concat txt)) ; Copy the text. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
587 (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
|
588 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
589 (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
|
590 ) |
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 ;; 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
|
593 (t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
594 ;; Nothing new. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
595 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
596 (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
|
597 ) |
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 ;; 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
|
601 ;; must now be removed. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 (dolist (A arglist) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 (semantic-lex-spp-symbol-pop A)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 )) |
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 ;;; Macro Merging |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 ;; 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
|
609 ;; Merged macro streams perform in place replacements. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
611 (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
|
612 "Merge elements from the RAW-STREAM together. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 Handle spp-concat symbol concatenation. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
614 Handle Nested macro replacements. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
615 Return the cooked stream." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 (let ((cooked-stream nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 ;; Merge the stream |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
618 (while raw-stream |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 (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
|
620 ;; handle hashhash, by skipping it. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 (setq raw-stream (cdr raw-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 ;; Now merge the symbols. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 (let ((prev-tok (car cooked-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 (next-tok (car raw-stream))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
625 (setq cooked-stream (cdr cooked-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 (push (semantic-lex-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
627 'spp-symbol-merge |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 (semantic-lex-token-start prev-tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 (semantic-lex-token-end next-tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 (list prev-tok next-tok)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 cooked-stream) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 (t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 (push (car raw-stream) cooked-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 (setq raw-stream (cdr raw-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 ) |
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 (nreverse cooked-stream)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 ) |
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 ;;; MACRO EXPANSION |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 ;; There are two types of expansion. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 ;; 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
|
647 ;; 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
|
648 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 (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
|
650 "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
|
651 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
|
652 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
|
653 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
|
654 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
|
655 (cond |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
656 ;; 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
|
657 ((null val) t) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 ;; 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
|
659 ((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
|
660 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 (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
|
662 ;; Test for a token list. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
663 ((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
|
664 (symbolp (car (car val)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 (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
|
666 ;; Test for miscellaneous strings. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
667 ((stringp val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 (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
|
669 )) |
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 ;;; ANALYZERS: |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 ;;; |
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 ;;; Symbol Is Macro |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 ;; 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
|
679 ;; of the macro symbol. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
681 (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
|
682 "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
|
683 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
|
684 (if (not val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
685 (setq semantic-lex-end-point end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 (let ((arg-in nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 (arg-parsed nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 (arg-split nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 ) |
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 ;; Check for arguments. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 (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
|
693 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 (when arg-in |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (save-excursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 (goto-char end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 (setq arg-parsed |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 (semantic-lex-spp-one-token-and-move-for-macro |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 (point-at-eol))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
700 (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
|
701 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 (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
|
703 (setq arg-split |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 ;; 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
|
705 (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
|
706 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
707 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
708 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 ;; 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
|
710 (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
|
711 (setq semantic-lex-end-point end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
712 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 )) |
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 (defvar semantic-lex-spp-replacements-enabled t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 "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
|
717 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
|
718 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 (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
|
720 "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
|
721 STR occurs in the current buffer between BEG and END." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 (let (sym val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 (cond |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
725 ;; 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
|
726 ((and semantic-lex-spp-replacements-enabled |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 (semantic-lex-spp-symbol-p str)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
728 (setq sym (semantic-lex-spp-symbol str) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 val (symbol-value sym) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
730 count 0) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
731 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 (let ((semantic-lex-spp-expanded-macro-stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
733 semantic-lex-spp-expanded-macro-stack)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
734 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 (semantic-lex-with-macro-used str |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 ;; 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
|
737 ;; 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
|
738 ;; 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
|
739 (while (and val (consp val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 (semantic-lex-token-p (car val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 (eq (length val) 1) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 (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
|
743 (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
|
744 (< count 10) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
745 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
746 (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
|
747 (setq sym (semantic-lex-spp-symbol str) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
748 val (symbol-value sym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
749 ;; Prevent recursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
750 (setq count (1+ count)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
751 ;; This prevents a different kind of recursion. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
752 (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
|
753 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 (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
|
756 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 ;; Anything else. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 (t |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
760 ;; A regular keyword. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
761 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
762 (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
|
763 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 (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
|
767 "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
|
768 "\\(\\sw\\|\\s_\\)+" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (let ((str (match-string 0)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 (beg (match-beginning 0)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 (end (match-end 0))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 (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
|
773 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 ;;; ANALYZERS FOR NEW MACROS |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
776 ;; 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
|
777 ;; 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
|
778 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
779 ;; 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
|
780 ;; a macro. |
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 (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
|
783 "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
|
784 (when (and (consp token) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 (symbolp (car token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 (eq 'semantic-list (car token))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
787 ;; Convert TOKEN in place. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
788 (let ((argsplit (cedet-split-string (semantic-lex-token-text token) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
789 "[(), ]" t))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 (setcar token 'spp-arg-list) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 (setcar (nthcdr 1 token) argsplit)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 (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
|
795 "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
|
796 Don't go past MAX." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
797 (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
|
798 (if (not ans) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (progn (goto-char max) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
800 nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
801 (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
|
802 (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
|
803 (setcdr bounds max))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
804 (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
|
805 (car ans)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
806 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
807 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
808 (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
|
809 "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
|
810 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
|
811 (let ((end (semantic-lex-token-end token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 (fresh-toks nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
813 (toks nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 (save-excursion |
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 (if (stringp (nth 1 token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
817 ;; 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
|
818 ;; 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
|
819 ;; 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
|
820 ;; nice to parse its contents. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 (let ((txt (semantic-lex-token-text token))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 (semantic-lex-spp-lex-text-string |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
823 (substring txt 1 (1- (length txt))))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
824 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
825 ;; This part is like the original |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
826 (goto-char (semantic-lex-token-start token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
827 ;; 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
|
828 (forward-char 1) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 (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
|
830 (dolist (tok fresh-toks) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 (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
|
832 (setq toks (cons tok toks)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
833 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 (nreverse toks))))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 (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
|
837 "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
|
838 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
|
839 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
|
840 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
|
841 and variable state from the current buffer." |
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
|
842 ;; @TODO - will this fcn recurse? |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
843 (let* ((buf (get-buffer-create " *SPP parse hack*")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
844 (mode major-mode) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
845 (fresh-toks nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
846 (toks nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
847 (origbuff (current-buffer)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 (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
|
849 semantic-lex-spp-project-macro-symbol-obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 semantic-lex-spp-dynamic-macro-symbol-obarray |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
851 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
|
852 semantic-lex-spp-expanded-macro-stack |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
853 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
854 ) |
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
|
855 (save-excursion |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
856 (set-buffer buf) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
857 (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
|
858 ;; 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
|
859 (when (not (eq major-mode mode)) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
860 (funcall mode) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
861 ;; Hack in mode-local |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
862 (activate-mode-local-bindings) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
863 ;; CHEATER! The following 3 lines are from |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
864 ;; `semantic-new-buffer-fcn', but we don't want to turn |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
865 ;; on all the other annoying modes for this little task. |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
866 (setq semantic-new-buffer-fcn-was-run t) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
867 (semantic-lex-init) |
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 (semantic-clear-toplevel-cache) |
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 (remove-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook |
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 t) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
871 ) |
dcacd65a31ec
cedet/semantic/lex-spp.el: Synch to 2009-08-29 version in CEDET CVS.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
872 |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
873 ;; Second Cheat: copy key variables reguarding 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
|
874 ;; 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
|
875 ;; since the state changes. |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
876 (dolist (V important-vars) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
877 (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
|
878 (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
|
879 (goto-char (point-min)) |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
880 |
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
|
881 (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
|
882 |
104414
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
883 (dolist (tok fresh-toks) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
884 (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
|
885 (setq toks (cons tok toks)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
886 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
887 (nreverse toks))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
888 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
889 ;;;; FIRST DRAFT |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
890 ;; 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
|
891 ;; 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
|
892 ;; 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
|
893 ;; 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
|
894 ;; larger than the current buffer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
895 ;;(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
|
896 ;; "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
|
897 ;; 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
|
898 ;; (save-excursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
899 ;; (let ((end (semantic-lex-token-end token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
900 ;; (fresh-toks nil) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
901 ;; (toks nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
902 ;; (goto-char (semantic-lex-token-start token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
903 ;; ;; 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
|
904 ;; (forward-char 1) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
905 ;; (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
|
906 ;; (dolist (tok fresh-toks) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
907 ;; (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
|
908 ;; (setq toks (cons tok toks)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
909 ;; (nreverse toks)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
910 ;; )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
911 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 ;;;; USING SPLIT |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
913 ;; 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
|
914 ;; 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
|
915 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
916 ;; 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
|
917 ;; (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
|
918 ;; "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
|
919 ;; 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
|
920 ;; (let* ((txt (semantic-lex-token-text token)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
921 ;; (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
|
922 ;; "(), " t)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
923 ;; ;; Hack for lexing. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 ;; (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
|
925 ;; (dolist (S split) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
926 ;; (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
|
927 ;; (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
|
928 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
929 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 (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
|
931 "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
|
932 Parsing starts at the current point location. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
933 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
|
934 (let ((stream nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
935 (while (< (point) eos) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
936 (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
|
937 (str (when tok |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
938 (semantic-lex-token-text tok))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
939 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
940 (if str |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
941 (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
|
942 (semantic-lex-token-start tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 (semantic-lex-token-end tok) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 str) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
945 stream) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
946 ;; Nothing to push. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
947 nil))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
948 (goto-char eos) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
949 ;; Fix the order |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
950 (nreverse stream) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
951 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
952 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
953 (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
|
954 &rest valform) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
955 "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
|
956 NAME is the name of the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
957 DOC is the documentation for the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
958 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
|
959 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
|
960 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
|
961 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
|
962 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
|
963 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
|
964 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
|
965 (let ((start (make-symbol "start")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
966 (end (make-symbol "end")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
967 (val (make-symbol "val")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
968 (startpnt (make-symbol "startpnt")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
969 (endpnt (make-symbol "endpnt"))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
970 `(define-lex-regex-analyzer ,name |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
971 ,doc |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
972 ,regexp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
973 (let ((,start (match-beginning ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
974 (,end (match-end ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
975 (,startpnt semantic-lex-end-point) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
976 (,val (save-match-data ,@valform)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
977 (,endpnt semantic-lex-end-point)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
978 (semantic-lex-spp-symbol-set |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
979 (buffer-substring-no-properties ,start ,end) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
980 ,val) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
981 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
982 (semantic-lex-token 'spp-macro-def |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
983 ,start ,end)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
984 ;; 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
|
985 (when (and (/= ,startpnt ,endpnt) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
986 (/= ,endpnt semantic-lex-end-point)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
987 (setq semantic-lex-end-point ,endpnt)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
988 )))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
989 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
990 (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
|
991 "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
|
992 NAME is the name of the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
993 DOC is the documentation for the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
994 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
|
995 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
|
996 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
|
997 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
|
998 (let ((start (make-symbol "start")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
999 (end (make-symbol "end"))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1000 `(define-lex-regex-analyzer ,name |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1001 ,doc |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1002 ,regexp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1003 (let ((,start (match-beginning ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1004 (,end (match-end ,tokidx)) |
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 (semantic-lex-spp-symbol-remove |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1007 (buffer-substring-no-properties ,start ,end)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1008 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1009 (semantic-lex-token 'spp-macro-undef |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1010 ,start ,end)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1011 )))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1012 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1013 ;;; INCLUDES |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1014 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1015 ;; 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
|
1016 ;; 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
|
1017 ;; 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
|
1018 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1019 ;; 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
|
1020 ;; 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
|
1021 ;; written yet. |
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 (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
|
1024 "*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
|
1025 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
|
1026 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
|
1027 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
|
1028 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1029 Note: Note implemented yet" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1030 :group 'semantic |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1031 :type 'boolean) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1032 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1033 (defun semantic-lex-spp-merge-header (name) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1034 "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
|
1035 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
|
1036 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
|
1037 symbol table." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1038 (when semantic-lex-spp-use-headers-flag |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1039 ;; @todo - do this someday, ok? |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1040 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1041 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1042 (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
|
1043 &rest valform) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1044 "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
|
1045 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
|
1046 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
|
1047 NAME is the name of the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1048 DOC is the documentation for the analyzer. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1049 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
|
1050 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
|
1051 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
|
1052 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
|
1053 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
|
1054 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
|
1055 (NAME . TYPE) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1056 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
|
1057 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
|
1058 (let ((start (make-symbol "start")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1059 (end (make-symbol "end")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1060 (val (make-symbol "val")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1061 (startpnt (make-symbol "startpnt")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1062 (endpnt (make-symbol "endpnt"))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1063 `(define-lex-regex-analyzer ,name |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1064 ,doc |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1065 ,regexp |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1066 (let ((,start (match-beginning ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1067 (,end (match-end ,tokidx)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1068 (,startpnt semantic-lex-end-point) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1069 (,val (save-match-data ,@valform)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1070 (,endpnt semantic-lex-end-point)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1071 ;;(message "(car ,val) -> %S" (car ,val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1072 (semantic-lex-spp-merge-header (car ,val)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1073 (semantic-lex-push-token |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1074 (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
|
1075 'spp-system-include |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1076 'spp-include) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1077 ,start ,end |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1078 (car ,val))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1079 ;; 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
|
1080 (when (and (/= ,startpnt ,endpnt) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1081 (/= ,endpnt semantic-lex-end-point)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1082 (setq semantic-lex-end-point ,endpnt)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1083 )))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1084 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1085 ;;; EIEIO USAGE |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1086 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1087 ;; 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
|
1088 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1089 ;; 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
|
1090 ;; file. |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1091 (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
|
1092 "*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
|
1093 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1094 (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
|
1095 "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
|
1096 The VALUE is a spp lexical table." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1097 (if (not value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1098 (princ "nil") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1099 (princ "\n '(") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1100 ;(princ value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1101 (dolist (sym value) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1102 (princ "(") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1103 (prin1 (car sym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1104 (let* ((first (car (cdr sym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1105 (rest (cdr sym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1106 (when (not (listp first)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1107 (error "Error in macro \"%s\"" (car sym))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1108 (when (eq (car first) 'spp-arg-list) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1109 (princ " ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1110 (prin1 first) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1111 (setq rest (cdr rest)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1112 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1113 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1114 (when rest |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1115 (princ " . ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1116 (let ((len (length (cdr rest)))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1117 (cond ((< len 2) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1118 (condition-case nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1119 (prin1 rest) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1120 (error |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1121 (princ "nil ;; Error writing macro\n")))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1122 ((< 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
|
1123 (princ "\n ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1124 (condition-case nil |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1125 (prin1 rest) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1126 (error |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1127 (princ "nil ;; Error writing macro\n "))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1128 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1129 (t ;; Too Long! |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1130 (princ "nil ;; Too Long!\n ") |
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 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1133 (princ ")\n ") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1134 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1135 (princ ")\n")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1136 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1137 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1138 ;;; TESTS |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1139 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1140 (defun semantic-lex-spp-write-test () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1141 "Test the semantic tag writer against the current buffer." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1142 (interactive) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1143 (with-output-to-temp-buffer "*SPP Write Test*" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1144 (semantic-lex-spp-table-write-slot-value |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1145 (semantic-lex-spp-save-table)))) |
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 (defun semantic-lex-spp-write-utest () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1148 "Unit test using the test spp file to test the slot write fcn." |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1149 (interactive) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1150 (let* ((sem (locate-library "semantic-lex-spp.el")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1151 (dir (file-name-directory sem))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1152 (save-excursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1153 (set-buffer (find-file-noselect |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1154 (expand-file-name "tests/testsppreplace.c" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1155 dir))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1156 (semantic-lex-spp-write-test)))) |
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 ;;; MACRO TABLE DEBUG |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1159 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1160 (defun semantic-lex-spp-describe (&optional buffer) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1161 "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
|
1162 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
|
1163 (interactive) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1164 (let ((syms (save-excursion |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1165 (if buffer (set-buffer buffer)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1166 (semantic-lex-spp-macros))) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1167 (sym nil)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1168 (with-output-to-temp-buffer "*SPP MACROS*" |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1169 (princ "Macro\t\tValue\n") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1170 (while syms |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1171 (setq sym (car syms) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1172 syms (cdr syms)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1173 (princ (symbol-name sym)) |
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 (if (< (length (symbol-name sym)) 8) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1176 (princ "\t")) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1177 (prin1 (symbol-value sym)) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1178 (princ "\n") |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1179 )))) |
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 ;;; EDEBUG Handlers |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1182 ;; |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1183 (add-hook |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1184 'edebug-setup-hook |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1185 #'(lambda () |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1186 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1187 (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
|
1188 (&define name stringp stringp form def-body) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1189 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1190 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1191 (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
|
1192 (&define name stringp stringp form) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1193 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1194 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1195 (def-edebug-spec define-lex-spp-include-analyzer |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1196 (&define name stringp stringp form def-body) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1197 ) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1198 )) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1199 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1200 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1201 (provide 'semantic/lex-spp) |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1202 |
b2b72cdd9d90
cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1203 ;;; semantic-lex-spp.el ends here |