104498
|
1 ;;; srecode/srt-wy.el --- Generated parser support file
|
|
2
|
106815
|
3 ;; Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
104498
|
4
|
|
5 ;; This file is part of GNU Emacs.
|
|
6
|
|
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
8 ;; it under the terms of the GNU General Public License as published by
|
|
9 ;; the Free Software Foundation, either version 3 of the License, or
|
|
10 ;; (at your option) any later version.
|
|
11
|
|
12 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 ;; GNU General Public License for more details.
|
|
16
|
|
17 ;; You should have received a copy of the GNU General Public License
|
|
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
|
20 ;;; Commentary:
|
|
21
|
|
22 ;; Generated from srecode-template.wy in the CEDET repository.
|
|
23
|
|
24 ;;; Code:
|
|
25
|
|
26 (require 'semantic/lex)
|
|
27
|
|
28
|
|
29 ;;; Prologue
|
|
30 ;;
|
|
31
|
|
32 ;;; Declarations
|
|
33 ;;
|
|
34 (defconst srecode-template-wy--keyword-table
|
|
35 (semantic-lex-make-keyword-table
|
|
36 '(("set" . SET)
|
|
37 ("show" . SHOW)
|
|
38 ("macro" . MACRO)
|
|
39 ("context" . CONTEXT)
|
|
40 ("template" . TEMPLATE)
|
|
41 ("sectiondictionary" . SECTIONDICTIONARY)
|
|
42 ("prompt" . PROMPT)
|
|
43 ("default" . DEFAULT)
|
|
44 ("defaultmacro" . DEFAULTMACRO)
|
|
45 ("read" . READ)
|
|
46 ("bind" . BIND))
|
|
47 '(("bind" summary "bind \"<letter>\"")
|
|
48 ("read" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]")
|
|
49 ("defaultmacro" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]")
|
|
50 ("default" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]")
|
|
51 ("prompt" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]")
|
|
52 ("sectiondictionary" summary "sectiondictionary <name>\\n <dictionary entries>")
|
|
53 ("template" summary "template <name>\\n <template definition>")
|
|
54 ("context" summary "context <name>")
|
|
55 ("macro" summary "... macro \"string\" ...")
|
|
56 ("show" summary "show <name> ; to show a section")
|
|
57 ("set" summary "set <name> <value>")))
|
|
58 "Table of language keywords.")
|
|
59
|
|
60 (defconst srecode-template-wy--token-table
|
|
61 (semantic-lex-make-type-table
|
|
62 '(("number"
|
|
63 (number))
|
|
64 ("string"
|
|
65 (string))
|
|
66 ("symbol"
|
|
67 (symbol))
|
|
68 ("property"
|
|
69 (property))
|
|
70 ("separator"
|
|
71 (TEMPLATE_BLOCK . "^----"))
|
|
72 ("newline"
|
|
73 (newline)))
|
|
74 '(("number" :declared t)
|
|
75 ("string" :declared t)
|
|
76 ("symbol" :declared t)
|
|
77 ("property" :declared t)
|
|
78 ("newline" :declared t)
|
|
79 ("punctuation" syntax "\\s.+")
|
|
80 ("punctuation" :declared t)
|
|
81 ("keyword" :declared t)))
|
|
82 "Table of lexical tokens.")
|
|
83
|
|
84 (defconst srecode-template-wy--parse-table
|
|
85 (progn
|
|
86 (eval-when-compile
|
|
87 (require 'semantic/wisent/comp))
|
|
88 (wisent-compile-grammar
|
|
89 '((SET SHOW MACRO CONTEXT TEMPLATE SECTIONDICTIONARY PROMPT DEFAULT DEFAULTMACRO READ BIND newline TEMPLATE_BLOCK property symbol string number)
|
|
90 nil
|
|
91 (template_file
|
|
92 ((newline)
|
|
93 nil)
|
|
94 ((context))
|
|
95 ((prompt))
|
|
96 ((variable))
|
|
97 ((template)))
|
|
98 (context
|
|
99 ((CONTEXT symbol newline)
|
|
100 (wisent-raw-tag
|
|
101 (semantic-tag $2 'context))))
|
|
102 (prompt
|
|
103 ((PROMPT symbol string opt-default-fcn opt-read-fcn newline)
|
|
104 (wisent-raw-tag
|
|
105 (semantic-tag $2 'prompt :text
|
|
106 (read $3)
|
|
107 :default $4 :read $5))))
|
|
108 (opt-default-fcn
|
|
109 ((DEFAULT symbol)
|
|
110 (progn
|
|
111 (read $2)))
|
|
112 ((DEFAULT string)
|
|
113 (progn
|
|
114 (read $2)))
|
|
115 ((DEFAULTMACRO string)
|
|
116 (progn
|
|
117 (cons 'macro
|
|
118 (read $2))))
|
|
119 (nil nil))
|
|
120 (opt-read-fcn
|
|
121 ((READ symbol)
|
|
122 (progn
|
|
123 (read $2)))
|
|
124 (nil nil))
|
|
125 (variable
|
|
126 ((SET symbol insertable-string-list newline)
|
|
127 (wisent-raw-tag
|
|
128 (semantic-tag-new-variable $2 nil $3)))
|
|
129 ((SHOW symbol newline)
|
|
130 (wisent-raw-tag
|
|
131 (semantic-tag-new-variable $2 nil t))))
|
|
132 (insertable-string-list
|
|
133 ((insertable-string)
|
|
134 (list $1))
|
|
135 ((insertable-string-list insertable-string)
|
|
136 (append $1
|
|
137 (list $2))))
|
|
138 (insertable-string
|
|
139 ((string)
|
|
140 (read $1))
|
|
141 ((MACRO string)
|
|
142 (cons 'macro
|
|
143 (read $2))))
|
|
144 (template
|
|
145 ((TEMPLATE templatename opt-dynamic-arguments newline opt-string opt-section-dictionaries TEMPLATE_BLOCK newline opt-bind)
|
|
146 (wisent-raw-tag
|
|
147 (semantic-tag-new-function $2 nil $3 :documentation $5 :code $7 :dictionaries $6 :binding $9))))
|
|
148 (templatename
|
|
149 ((symbol))
|
|
150 ((PROMPT))
|
|
151 ((CONTEXT))
|
|
152 ((TEMPLATE))
|
|
153 ((DEFAULT))
|
|
154 ((MACRO))
|
|
155 ((DEFAULTMACRO))
|
|
156 ((READ))
|
|
157 ((SET)))
|
|
158 (opt-dynamic-arguments
|
|
159 ((property opt-dynamic-arguments)
|
|
160 (cons $1 $2))
|
|
161 (nil nil))
|
|
162 (opt-string
|
|
163 ((string newline)
|
|
164 (read $1))
|
|
165 (nil nil))
|
|
166 (opt-section-dictionaries
|
|
167 (nil nil)
|
|
168 ((section-dictionary-list)))
|
|
169 (section-dictionary-list
|
|
170 ((one-section-dictionary)
|
|
171 (list $1))
|
|
172 ((section-dictionary-list one-section-dictionary)
|
|
173 (append $1
|
|
174 (list $2))))
|
|
175 (one-section-dictionary
|
|
176 ((SECTIONDICTIONARY string newline variable-list)
|
|
177 (cons
|
|
178 (read $2)
|
|
179 $4)))
|
|
180 (variable-list
|
|
181 ((variable)
|
|
182 (wisent-cook-tag $1))
|
|
183 ((variable-list variable)
|
|
184 (append $1
|
|
185 (wisent-cook-tag $2))))
|
|
186 (opt-bind
|
|
187 ((BIND string newline)
|
|
188 (read $2))
|
|
189 (nil nil)))
|
|
190 '(template_file)))
|
|
191 "Parser table.")
|
|
192
|
|
193 (defun srecode-template-wy--install-parser ()
|
|
194 "Setup the Semantic Parser."
|
|
195 (semantic-install-function-overrides
|
|
196 '((parse-stream . wisent-parse-stream)))
|
|
197 (setq semantic-parser-name "LALR"
|
|
198 semantic--parse-table srecode-template-wy--parse-table
|
|
199 semantic-debug-parser-source "srecode-template.wy"
|
|
200 semantic-flex-keywords-obarray srecode-template-wy--keyword-table
|
|
201 semantic-lex-types-obarray srecode-template-wy--token-table)
|
|
202 ;; Collect unmatched syntax lexical tokens
|
|
203 (semantic-make-local-hook 'wisent-discarding-token-functions)
|
|
204 (add-hook 'wisent-discarding-token-functions
|
|
205 'wisent-collect-unmatched-syntax nil t))
|
|
206
|
|
207
|
|
208 ;;; Analyzers
|
|
209 ;;
|
|
210 (define-lex-keyword-type-analyzer srecode-template-wy--<keyword>-keyword-analyzer
|
|
211 "keyword analyzer for <keyword> tokens."
|
|
212 "\\(\\sw\\|\\s_\\)+")
|
|
213
|
|
214 (define-lex-regex-type-analyzer srecode-template-wy--<symbol>-regexp-analyzer
|
|
215 "regexp analyzer for <symbol> tokens."
|
|
216 "\\(\\sw\\|\\s_\\)+"
|
|
217 nil
|
|
218 'symbol)
|
|
219
|
|
220 (define-lex-sexp-type-analyzer srecode-template-wy--<string>-sexp-analyzer
|
|
221 "sexp analyzer for <string> tokens."
|
|
222 "\\s\""
|
|
223 'string)
|
|
224
|
|
225 (define-lex-regex-type-analyzer srecode-template-wy--<number>-regexp-analyzer
|
|
226 "regexp analyzer for <number> tokens."
|
|
227 semantic-lex-number-expression
|
|
228 nil
|
|
229 'number)
|
|
230
|
|
231 (define-lex-string-type-analyzer srecode-template-wy--<punctuation>-string-analyzer
|
|
232 "string analyzer for <punctuation> tokens."
|
|
233 "\\s.+"
|
|
234 nil
|
|
235 'punctuation)
|
|
236
|
|
237
|
|
238 ;;; Epilogue
|
|
239 ;;
|
|
240 (define-lex-simple-regex-analyzer srecode-template-property-analyzer
|
|
241 "Detect and create a dynamic argument properties."
|
|
242 ":\\(\\w\\|\\s_\\)*" 'property 0)
|
|
243
|
|
244 (define-lex-regex-analyzer srecode-template-separator-block
|
|
245 "Detect and create a template quote block."
|
|
246 "^----\n"
|
|
247 (semantic-lex-push-token
|
|
248 (semantic-lex-token
|
|
249 'TEMPLATE_BLOCK
|
|
250 (match-end 0)
|
|
251 (semantic-lex-unterminated-syntax-protection 'TEMPLATE_BLOCK
|
|
252 (goto-char (match-end 0))
|
|
253 (re-search-forward "^----$")
|
|
254 (match-beginning 0))))
|
|
255 (setq semantic-lex-end-point (point)))
|
|
256
|
|
257
|
|
258 (define-lex wisent-srecode-template-lexer
|
|
259 "Lexical analyzer that handles SRecode Template buffers.
|
|
260 It ignores whitespace, newlines and comments."
|
|
261 semantic-lex-newline
|
|
262 semantic-lex-ignore-whitespace
|
|
263 semantic-lex-ignore-newline
|
|
264 semantic-lex-ignore-comments
|
|
265 srecode-template-separator-block
|
|
266 srecode-template-wy--<keyword>-keyword-analyzer
|
|
267 srecode-template-property-analyzer
|
|
268 srecode-template-wy--<symbol>-regexp-analyzer
|
|
269 srecode-template-wy--<number>-regexp-analyzer
|
|
270 srecode-template-wy--<string>-sexp-analyzer
|
|
271 srecode-template-wy--<punctuation>-string-analyzer
|
|
272 semantic-lex-default-action
|
|
273 )
|
|
274
|
|
275 (provide 'srecode/srt-wy)
|
|
276
|
105377
|
277 ;; arch-tag: 1be4c0bc-2a79-4f75-a07a-1ac518f41271
|
104498
|
278 ;;; srecode/srt-wy.el ends here
|