annotate lisp/cedet/srecode/compile.el @ 112445:93fcbcb698b0

Improve configuration of makeinfo. * Makefile.in (MAKEINFO): Now controlled by `configure'. (MAKEINFO_OPTS): New variable. Use it where appropriate. (ENVADD): Updated.
author Werner Lemberg <wl@gnu.org>
date Sun, 23 Jan 2011 11:38:14 +0100
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; srecode/compile --- Compilation of srecode template files.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 110531
diff changeset
3 ;; Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Keywords: codegeneration
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; (at your option) any later version.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;; Commentary:
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; Compile a Semantic Recoder template file.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; Template files are parsed using a Semantic/Wisent parser into
105328
2f2bc20297c6 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105279
diff changeset
28 ;; a tag table. The code therein is then further parsed down using
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; a regular expression parser.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; The output are a series of EIEIO objects which represent the
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; templates in a way that could be inserted later.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105441
diff changeset
34 (eval-when-compile (require 'cl))
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 (require 'semantic)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 (require 'eieio)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 (require 'eieio-base)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 (require 'srecode/table)
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
39 (require 'srecode/dictionary)
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40
105279
6969c5b2e0b2 Mark declarations not understood by check-declare.
Glenn Morris <rgm@gnu.org>
parents: 104506
diff changeset
41 (declare-function srecode-template-inserter-newline-child-p "srecode/insert"
6969c5b2e0b2 Mark declarations not understood by check-declare.
Glenn Morris <rgm@gnu.org>
parents: 104506
diff changeset
42 t t)
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;;; Code:
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;;; Template Class
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ;;
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
48 ;; Templates describe a pattern of text that can be inserted into a
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;; buffer.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 (defclass srecode-template (eieio-named)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ((context :initarg :context
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 :initform nil
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 :documentation
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 "Context this template belongs to.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 (args :initarg :args
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 :documentation
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 "List of arguments that this template requires.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 (code :initarg :code
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 :documentation
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 "Compiled text from the template.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 (dictionary :initarg :dictionary
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 :type (or null srecode-dictionary)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 :documentation
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 "List of section dictinaries.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 The compiled template can contain lists of section dictionaries,
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 or values that are expected to be passed down into different
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 section macros. The template section dictionaries are merged in with
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 any incomming dictionaries values.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 (binding :initarg :binding
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 :documentation
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 "Preferred keybinding for this template in `srecode-minor-mode-map'.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 (active :allocation :class
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 :initform nil
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 :documentation
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 "During template insertion, this is the stack of active templates.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 The top-most template is the 'active' template. Use the accessor methods
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 for push, pop, and peek for the active template.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (table :initarg :table
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 :documentation
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 "The table this template lives in.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 "Class defines storage for semantic recoder templates.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 (defun srecode-flush-active-templates ()
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 "Flush the active template storage.
105328
2f2bc20297c6 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105279
diff changeset
87 Useful if something goes wrong in SRecode, and the active template
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 stack is broken."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 (interactive)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (if (oref srecode-template active)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 (when (y-or-n-p (format "%d active templates. Flush? "
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 (length (oref srecode-template active))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 (oset-default srecode-template active nil))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 (message "No active templates to flush."))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 ;;; Inserters
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 ;; Each inserter object manages a different thing that
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 ;; might be inserted into a template output stream.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 ;; The 'srecode-insert-method' on each inserter does the actual
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 ;; work, and the smaller, simple inserter object is saved in
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 ;; the compiled templates.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 ;; See srecode-insert.el for the specialized classes.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (defclass srecode-template-inserter (eieio-named)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 ((secondname :initarg :secondname
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 :type (or null string)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 :documentation
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 "If there is a colon in the inserter's name, it represents
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 additional static argument data."))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 "This represents an item to be inserted via a template macro.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 Plain text strings are not handled via this baseclass."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 :abstract t)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 (defmethod srecode-parse-input ((ins srecode-template-inserter)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 tag input STATE)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 "For the template inserter INS, parse INPUT.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 Shorten input only by the amount needed.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 Return the remains of INPUT.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 STATE is the current compilation state."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 input)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (defmethod srecode-match-end ((ins srecode-template-inserter) name)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 "For the template inserter INS, do I end a section called NAME?"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (defmethod srecode-inserter-apply-state ((ins srecode-template-inserter) STATE)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 "For the template inserter INS, apply information from STATE."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (defmethod srecode-inserter-prin-example :STATIC ((ins srecode-template-inserter)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 escape-start escape-end)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 "Insert an example using inserter INS.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 Arguments ESCAPE-START and ESCAPE-END are the current escape sequences in use."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (princ " ")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (princ escape-start)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (when (and (slot-exists-p ins 'key) (oref ins key))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (princ (format "%c" (oref ins key))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 (princ "VARNAME")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (princ escape-end)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (terpri)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 ;;; Compile State
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (defclass srecode-compile-state ()
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 ((context :initform "declaration"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 :documentation "The active context.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 (prompts :initform nil
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 :documentation "The active prompts.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 (escape_start :initform "{{"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 :documentation "The starting escape sequence.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (escape_end :initform "}}"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 :documentation "The ending escape sequence.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 "Current state of the compile.")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (defmethod srecode-compile-add-prompt ((state srecode-compile-state)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 prompttag)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 "Add PROMPTTAG to the current list of prompts."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (with-slots (prompts) state
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (let ((match (assoc (semantic-tag-name prompttag) prompts))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (newprompts prompts))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 (when match
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (let ((tmp prompts))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (setq newprompts nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 (while tmp
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 (when (not (string= (car (car tmp))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 (car prompttag)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (setq newprompts (cons (car tmp)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 newprompts)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (setq tmp (cdr tmp)))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (setq prompts (cons prompttag newprompts)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 ))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 ;;; TEMPLATE COMPILER
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (defun srecode-compile-file (fname)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 "Compile the templates from the file FNAME."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (let ((peb (get-file-buffer fname)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (save-excursion
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 ;; Make whatever it is local.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (if (not peb)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 (set-buffer (semantic-find-file-noselect fname))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (set-buffer peb))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 ;; Do the compile.
105441
457c7a0ec078 * cedet/semantic.el (semantic-new-buffer-setup-functions): New
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
190 (unless (semantic-active-p)
457c7a0ec078 * cedet/semantic.el (semantic-new-buffer-setup-functions): New
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
191 (semantic-new-buffer-fcn))
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (srecode-compile-templates)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 ;; Trash the buffer if we had to read it in.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (if (not peb)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (kill-buffer (current-buffer)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 )))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 ;;;###autoload
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (defun srecode-compile-templates ()
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 "Compile a semantic recode template file into a mode-local variable."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (interactive)
104506
801834237f9c * menu-bar.el: Remove ediff-misc from Tools menu.
Chong Yidong <cyd@stupidchicken.com>
parents: 104501
diff changeset
202 (require 'srecode/insert)
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (message "Compiling template %s..."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (file-name-nondirectory (buffer-file-name)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (let ((tags (semantic-fetch-tags))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 (tag nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (class nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 (table nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (STATE (srecode-compile-state (file-name-nondirectory
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (buffer-file-name))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 (mode nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (application nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (priority nil)
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
214 (project nil)
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 (vars nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 ;; COMPILE
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (while tags
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (setq tag (car tags)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 class (semantic-tag-class tag))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 ;; What type of item is it?
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (cond
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 ;; CONTEXT tags specify the context all future tags
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 ;; belong to.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 ((eq class 'context)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 (oset STATE context (semantic-tag-name tag))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 ;; PROMPT tags specify prompts for dictionary ? inserters
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 ;; which appear in the following templates
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 ((eq class 'prompt)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 (srecode-compile-add-prompt STATE tag)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ;; VARIABLE tags can specify operational control
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ((eq class 'variable)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 (let* ((name (semantic-tag-name tag))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 (value (semantic-tag-variable-default tag))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (firstvalue (car value)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 ;; If it is a single string, and one value, then
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 ;; look to see if it is one of our special variables.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (if (and (= (length value) 1) (stringp firstvalue))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (cond ((string= name "mode")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (setq mode (intern firstvalue)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 ((string= name "escape_start")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 (oset STATE escape_start firstvalue)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 ((string= name "escape_end")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (oset STATE escape_end firstvalue)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 ((string= name "application")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (setq application (read firstvalue)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 ((string= name "priority")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 (setq priority (read firstvalue)))
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
258 ((string= name "project")
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
259 (setq project firstvalue))
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (t
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 ;; Assign this into some table of variables.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (setq vars (cons (cons name firstvalue) vars))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 ))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 ;; If it isn't a single string, then the value of the
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 ;; variable belongs to a compound dictionary value.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 ;; Create a compound dictionary value from "value".
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (require 'srecode/dictionary)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 (let ((cv (srecode-dictionary-compound-variable
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 name :value value)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (setq vars (cons (cons name cv) vars)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 ))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 ;; FUNCTION tags are really templates.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 ((eq class 'function)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (setq table (cons (srecode-compile-one-template-tag tag STATE)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 table))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 ;; Ooops
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 (t (error "Unknown TAG class %s" class))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 ;; Continue
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (setq tags (cdr tags)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 ;; MSG - Before install since nreverse whacks our list.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (message "%d templates compiled for %s"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (length table) mode)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 ;; APPLY TO MODE
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (if (not mode)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (error "You must specify a MODE for your templates"))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 ;; Calculate priority
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (if (not priority)
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
301 (let ((d (expand-file-name (file-name-directory (buffer-file-name))))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
302 (sd (expand-file-name (file-name-directory (locate-library "srecode"))))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
303 (defaultdelta (if (eq mode 'default) 0 10)))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
304 ;; @TODO : WHEN INTEGRATING INTO EMACS
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
305 ;; The location of Emacs default templates needs to be specified
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
306 ;; here to also have a lower priority.
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
307 (if (string-match (concat "^" sd) d)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
308 (setq priority (+ 30 defaultdelta))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
309 ;; If the user created template is for a project, then
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
310 ;; don't add as much as if it is unique to just some user.
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
311 (if (stringp project)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
312 (setq priority (+ 50 defaultdelta))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
313 (setq priority (+ 80 defaultdelta))))
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (message "Templates %s has estimated priority of %d"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (file-name-nondirectory (buffer-file-name))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 priority))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (message "Compiling templates %s priority %d... done!"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (file-name-nondirectory (buffer-file-name))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 priority))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 ;; Save it up!
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
322 (srecode-compile-template-table table mode priority application project vars)
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
326 (defun srecode-compile-one-template-tag (tag state)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
327 "Compile a template tag TAG into a srecode template object.
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
328 STATE is the current compile state as an object of class
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
329 `srecode-compile-state'."
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
330 (let* ((context (oref state context))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
331 (code (cdr (srecode-compile-split-code
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
332 tag (semantic-tag-get-attribute tag :code)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
333 state)))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
334 (args (semantic-tag-function-arguments tag))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
335 (binding (semantic-tag-get-attribute tag :binding))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
336 (dict-tags (semantic-tag-get-attribute tag :dictionaries))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
337 (root-dict (when dict-tags
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
338 (srecode-create-dictionaries-from-tags
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
339 dict-tags state)))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
340 (addargs))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
341 ;; Examine arguments.
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
342 (dolist (arg args)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
343 (let ((symbol (intern arg)))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
344 (push symbol addargs)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
345
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
346 ;; If we have a wrap, then put wrap inserters on both ends of
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
347 ;; the code.
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
348 (when (eq symbol :blank)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
349 (setq code (append
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
350 (list (srecode-compile-inserter
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
351 "BLANK"
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
352 "\r"
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
353 state
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
354 :secondname nil
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
355 :where 'begin))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
356 code
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
357 (list (srecode-compile-inserter
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
358 "BLANK"
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
359 "\r"
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
360 state
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
361 :secondname nil
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
362 :where 'end)))))))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
363
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
364 ;; Construct and return the template object.
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (srecode-template (semantic-tag-name tag)
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
366 :context context
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
367 :args (nreverse addargs)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
368 :dictionary root-dict
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
369 :binding binding
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
370 :code code))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
371 )
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (defun srecode-compile-do-hard-newline-p (comp)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 "Examine COMP to decide if the upcoming newline should be hard.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 It is hard if the previous inserter is a newline object."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (while (and comp (stringp (car comp)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (setq comp (cdr comp)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (or (not comp)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (require 'srecode/insert)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (srecode-template-inserter-newline-child-p (car comp))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (defun srecode-compile-split-code (tag str STATE
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 &optional end-name)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 "Split the code for TAG into something templatable.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 STR is the string of code from TAG to split.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 STATE is the current compile state.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 ESCAPE_START and ESCAPE_END are regexps that indicate the beginning
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 escape character, and end escape character pattern for expandable
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 macro names.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 Optional argument END-NAME specifies the name of a token upon which
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 parsing should stop.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 If END-NAME is specified, and the input string"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (let* ((what str)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (end-token nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (comp nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (regex (concat "\n\\|" (regexp-quote (oref STATE escape_start))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (regexend (regexp-quote (oref STATE escape_end)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (while (and what (not end-token))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (cond
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 ((string-match regex what)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (let* ((prefix (substring what 0 (match-beginning 0)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (match (substring what
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (match-beginning 0)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (match-end 0)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (namestart (match-end 0))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 (junk (string-match regexend what namestart))
104501
b5dbdf25d1c5 * cedet/srecode/compile.el (srecode-compile-split-code)
Chong Yidong <cyd@stupidchicken.com>
parents: 104498
diff changeset
408 end tail name key)
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 ;; Add string to compiled output
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 (when (> (length prefix) 0)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 (setq comp (cons prefix comp)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 (if (string= match "\n")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 ;; Do newline thingy.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (let ((new-inserter
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 (srecode-compile-inserter
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 "INDENT"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 "\n"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 STATE
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 :secondname nil
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 ;; This newline is "hard" meaning ALWAYS do it
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 ;; if the previous entry is also a newline.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 ;; Without it, user entered blank lines will be
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 ;; ignored.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 :hard (srecode-compile-do-hard-newline-p comp)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 )))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 ;; Trim WHAT back.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 (setq what (substring what namestart))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 (when (> (length what) 0)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 ;; make the new inserter, but only if we aren't last.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 (setq comp (cons new-inserter comp))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 ))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 ;; Regular inserter thingy.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (setq end (if junk
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (match-beginning 0)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (error "Could not find end escape for %s"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 (semantic-tag-name tag)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 tail (match-end 0))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 (cond ((not end)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 (error "No matching escape end for %s"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 (semantic-tag-name tag)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 ((<= end namestart)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 (error "Stray end escape for %s"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (semantic-tag-name tag)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 ;; Add string to compiled output
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (setq name (substring what namestart end)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 key nil)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 ;; Trim WHAT back.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (setq what (substring what tail))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 ;; Get the inserter
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 (let ((new-inserter
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (srecode-compile-parse-inserter name STATE))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 ;; If this is an end inserter, then assign into
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 ;; the end-token.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (if (srecode-match-end new-inserter end-name)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 (setq end-token new-inserter))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 ;; Add the inserter to our compilation stream.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (setq comp (cons new-inserter comp))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 ;; Allow the inserter an opportunity to modify
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 ;; the input stream.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (setq what (srecode-parse-input new-inserter tag what
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 STATE))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 )))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 (t
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 (if end-name
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 (error "Unmatched section end %s" end-name))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (setq comp (cons what comp)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 what nil))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (cons what (nreverse comp))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 (defun srecode-compile-parse-inserter (txt STATE)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 "Parse the inserter TXT with the current STATE.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 Return an inserter object."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (let ((key (aref txt 0))
104501
b5dbdf25d1c5 * cedet/srecode/compile.el (srecode-compile-split-code)
Chong Yidong <cyd@stupidchicken.com>
parents: 104498
diff changeset
477 name
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (if (and (or (< key ?A) (> key ?Z))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 (or (< key ?a) (> key ?z)) )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 (setq name (substring txt 1))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 (setq name txt
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 key nil))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 (let* ((junk (string-match ":" name))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 (namepart (if junk
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (substring name 0 (match-beginning 0))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 name))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 (secondname (if junk
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 (substring name (match-end 0))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 nil))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 (new-inserter (srecode-compile-inserter
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 namepart key STATE
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 :secondname secondname
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 )))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 ;; Return the new inserter
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 new-inserter)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 (defun srecode-compile-inserter (name key STATE &rest props)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 "Create an srecode inserter object for some macro NAME.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 KEY indicates a single character key representing a type
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 of inserter to create.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 STATE is the current compile state.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 PROPS are additional properties that might need to be passed
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 to the inserter constructor."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 ;;(message "Compile: %s %S" name props)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 (if (not key)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 (apply 'srecode-template-inserter-variable name props)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 (let ((classes (class-children srecode-template-inserter))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (new nil))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 ;; Loop over the various subclasses and
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 ;; create the correct inserter.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 (while (and (not new) classes)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 (setq classes (append classes (class-children (car classes))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 ;; Do we have a match?
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 (when (and (not (class-abstract-p (car classes)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 (equal (oref (car classes) key) key))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 ;; Create the new class, and apply state.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 (setq new (apply (car classes) name props))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 (srecode-inserter-apply-state new STATE)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 (setq classes (cdr classes)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 (if (not new) (error "SRECODE: Unknown macro code %S" key))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 new)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
525 (defun srecode-compile-template-table (templates mode priority application project vars)
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 "Compile a list of TEMPLATES into an semantic recode table.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 The table being compiled is for MODE, or the string \"default\".
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 PRIORITY is a numerical value that indicates this tables location
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 in an ordered search.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 APPLICATION is the name of the application these templates belong to.
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
531 PROJECT is a directory name which these templates scope to.
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 A list of defined variables VARS provides a variable table."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 (let ((namehash (make-hash-table :test 'equal
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 :size (length templates)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 (contexthash (make-hash-table :test 'equal :size 10))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 (lp templates)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 (while lp
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 (let* ((objname (oref (car lp) :object-name))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 (context (oref (car lp) :context))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543 (globalname (concat context ":" objname))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 ;; Place this template object into the global name hash.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 (puthash globalname (car lp) namehash)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 ;; Place this template into the specific context name hash.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 (let ((hs (gethash context contexthash)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 ;; Make a new context if none was available.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 (when (not hs)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 (setq hs (make-hash-table :test 'equal :size 20))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 (puthash context hs contexthash))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 ;; Put into that contenxt's hash.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 (puthash objname (car lp) hs)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 (setq lp (cdr lp))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
561 (when (stringp project)
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
562 (setq project (expand-file-name project)))
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
563
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564 (let* ((table (srecode-mode-table-new mode (buffer-file-name)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 :templates (nreverse templates)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 :namehash namehash
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 :contexthash contexthash
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568 :variables vars
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 :major-mode mode
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 :priority priority
110531
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
571 :application application
67ff8ad45bd5 Synch SRecode to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
572 :project project))
104498
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 (tmpl (oref table templates)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574 ;; Loop over all the templates, and xref.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575 (while tmpl
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 (oset (car tmpl) :table table)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577 (setq tmpl (cdr tmpl))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578 ))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 ;;; DEBUG
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 ;; Dump out information about the current srecoder compiled templates.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 ;;
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587 (defmethod srecode-dump ((tmp srecode-template))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 "Dump the contents of the SRecode template tmp."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 (princ "== Template \"")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
590 (princ (object-name-string tmp))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
591 (princ "\" in context ")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 (princ (oref tmp context))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
593 (princ "\n")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (when (oref tmp args)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 (princ " Arguments: ")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
596 (prin1 (oref tmp args))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597 (princ "\n"))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 (when (oref tmp dictionary)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 (princ " Section Dictionaries:\n")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600 (srecode-dump (oref tmp dictionary) 4)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
601 ;(princ "\n")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
602 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 (when (and (slot-boundp tmp 'binding) (oref tmp binding))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 (princ " Binding: ")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
605 (prin1 (oref tmp binding))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 (princ "\n"))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 (princ " Compiled Codes:\n")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 (srecode-dump-code-list (oref tmp code) " ")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609 (princ "\n\n")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 (defun srecode-dump-code-list (code indent)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 "Dump the CODE from a template code list to standard output.
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614 Argument INDENT specifies the indentation level for the list."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 (let ((i 1))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616 (while code
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 (princ indent)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618 (prin1 i)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 (princ ") ")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620 (cond ((stringp (car code))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
621 (prin1 (car code)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622 ((srecode-template-inserter-child-p (car code))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 (srecode-dump (car code) indent))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624 (t
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 (princ "Unknown Code: ")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
626 (prin1 (car code))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627 (setq code (cdr code)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
628 i (1+ i))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629 (when code
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 (princ "\n"))))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 (defmethod srecode-dump ((ins srecode-template-inserter) indent)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 "Dump the state of the SRecode template inserter INS."
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 (princ "INS: \"")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
636 (princ (object-name-string ins))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637 (when (oref ins :secondname)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 (princ "\" : \"")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639 (princ (oref ins :secondname)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 (princ "\" type \"")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 (let* ((oc (symbol-name (object-class ins)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 (junk (string-match "srecode-template-inserter-" oc))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 (on (if junk
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (substring oc (match-end 0))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 oc)))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646 (princ on))
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 (princ "\"")
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 )
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650 (provide 'srecode/compile)
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 ;; Local variables:
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 ;; generated-autoload-file: "loaddefs.el"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 ;; generated-autoload-load-name: "srecode/compile"
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 ;; End:
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656
41dc39934483 lisp/cedet/srecode.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 ;;; srecode/compile.el ends here