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