annotate lisp/cedet/semantic/lex-spp.el @ 104414:b2b72cdd9d90

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