Commit | Line | Data |
---|---|---|
4d902e6f CY |
1 | ;;; srecode/srt-wy.el --- Generated parser support file |
2 | ||
ab422c4d | 3 | ;; Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc. |
4d902e6f CY |
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: | |
78adbf9c CY |
21 | ;; |
22 | ;; This file was generated from admin/grammars/srecode-template.wy. | |
4d902e6f CY |
23 | |
24 | ;;; Code: | |
25 | ||
26 | (require 'semantic/lex) | |
62a81506 | 27 | (eval-when-compile (require 'semantic/bovine)) |
4d902e6f CY |
28 | \f |
29 | ;;; Prologue | |
30 | ;; | |
31 | \f | |
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) | |
62a81506 CY |
42 | ("section" . SECTION) |
43 | ("end" . END) | |
4d902e6f CY |
44 | ("prompt" . PROMPT) |
45 | ("default" . DEFAULT) | |
46 | ("defaultmacro" . DEFAULTMACRO) | |
47 | ("read" . READ) | |
48 | ("bind" . BIND)) | |
49 | '(("bind" summary "bind \"<letter>\"") | |
50 | ("read" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]") | |
51 | ("defaultmacro" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]") | |
52 | ("default" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]") | |
53 | ("prompt" summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]") | |
62a81506 CY |
54 | ("end" summary "section ... end") |
55 | ("section" summary "section <name>\\n <dictionary entries>\\n end") | |
4d902e6f CY |
56 | ("sectiondictionary" summary "sectiondictionary <name>\\n <dictionary entries>") |
57 | ("template" summary "template <name>\\n <template definition>") | |
58 | ("context" summary "context <name>") | |
59 | ("macro" summary "... macro \"string\" ...") | |
60 | ("show" summary "show <name> ; to show a section") | |
61 | ("set" summary "set <name> <value>"))) | |
62 | "Table of language keywords.") | |
63 | ||
64 | (defconst srecode-template-wy--token-table | |
65 | (semantic-lex-make-type-table | |
66 | '(("number" | |
67 | (number)) | |
68 | ("string" | |
69 | (string)) | |
70 | ("symbol" | |
71 | (symbol)) | |
72 | ("property" | |
73 | (property)) | |
74 | ("separator" | |
75 | (TEMPLATE_BLOCK . "^----")) | |
76 | ("newline" | |
77 | (newline))) | |
78 | '(("number" :declared t) | |
79 | ("string" :declared t) | |
80 | ("symbol" :declared t) | |
62a81506 | 81 | ("property" syntax ":\\(\\w\\|\\s_\\)*") |
4d902e6f CY |
82 | ("property" :declared t) |
83 | ("newline" :declared t) | |
84 | ("punctuation" syntax "\\s.+") | |
85 | ("punctuation" :declared t) | |
86 | ("keyword" :declared t))) | |
87 | "Table of lexical tokens.") | |
88 | ||
89 | (defconst srecode-template-wy--parse-table | |
90 | (progn | |
91 | (eval-when-compile | |
92 | (require 'semantic/wisent/comp)) | |
93 | (wisent-compile-grammar | |
62a81506 | 94 | '((SET SHOW MACRO CONTEXT TEMPLATE SECTIONDICTIONARY SECTION END PROMPT DEFAULT DEFAULTMACRO READ BIND newline TEMPLATE_BLOCK property symbol string number) |
4d902e6f CY |
95 | nil |
96 | (template_file | |
97 | ((newline) | |
98 | nil) | |
99 | ((context)) | |
100 | ((prompt)) | |
101 | ((variable)) | |
102 | ((template))) | |
103 | (context | |
104 | ((CONTEXT symbol newline) | |
105 | (wisent-raw-tag | |
106 | (semantic-tag $2 'context)))) | |
107 | (prompt | |
108 | ((PROMPT symbol string opt-default-fcn opt-read-fcn newline) | |
109 | (wisent-raw-tag | |
110 | (semantic-tag $2 'prompt :text | |
111 | (read $3) | |
112 | :default $4 :read $5)))) | |
113 | (opt-default-fcn | |
114 | ((DEFAULT symbol) | |
115 | (progn | |
116 | (read $2))) | |
117 | ((DEFAULT string) | |
118 | (progn | |
119 | (read $2))) | |
120 | ((DEFAULTMACRO string) | |
121 | (progn | |
122 | (cons 'macro | |
123 | (read $2)))) | |
124 | (nil nil)) | |
125 | (opt-read-fcn | |
126 | ((READ symbol) | |
127 | (progn | |
128 | (read $2))) | |
129 | (nil nil)) | |
130 | (variable | |
131 | ((SET symbol insertable-string-list newline) | |
132 | (wisent-raw-tag | |
133 | (semantic-tag-new-variable $2 nil $3))) | |
caaeb0e8 DE |
134 | ((SET symbol number newline) |
135 | (wisent-raw-tag | |
136 | (semantic-tag-new-variable $2 nil | |
137 | (list $3)))) | |
4d902e6f CY |
138 | ((SHOW symbol newline) |
139 | (wisent-raw-tag | |
140 | (semantic-tag-new-variable $2 nil t)))) | |
141 | (insertable-string-list | |
142 | ((insertable-string) | |
143 | (list $1)) | |
144 | ((insertable-string-list insertable-string) | |
145 | (append $1 | |
146 | (list $2)))) | |
147 | (insertable-string | |
148 | ((string) | |
149 | (read $1)) | |
150 | ((MACRO string) | |
151 | (cons 'macro | |
152 | (read $2)))) | |
153 | (template | |
62a81506 | 154 | ((TEMPLATE templatename opt-dynamic-arguments newline opt-string section-dictionary-list TEMPLATE_BLOCK newline opt-bind) |
4d902e6f CY |
155 | (wisent-raw-tag |
156 | (semantic-tag-new-function $2 nil $3 :documentation $5 :code $7 :dictionaries $6 :binding $9)))) | |
157 | (templatename | |
158 | ((symbol)) | |
159 | ((PROMPT)) | |
160 | ((CONTEXT)) | |
161 | ((TEMPLATE)) | |
162 | ((DEFAULT)) | |
163 | ((MACRO)) | |
164 | ((DEFAULTMACRO)) | |
165 | ((READ)) | |
166 | ((SET))) | |
167 | (opt-dynamic-arguments | |
168 | ((property opt-dynamic-arguments) | |
169 | (cons $1 $2)) | |
170 | (nil nil)) | |
171 | (opt-string | |
172 | ((string newline) | |
173 | (read $1)) | |
174 | (nil nil)) | |
4d902e6f | 175 | (section-dictionary-list |
62a81506 CY |
176 | (nil nil) |
177 | ((section-dictionary-list flat-section-dictionary) | |
178 | (append $1 | |
179 | (list $2))) | |
180 | ((section-dictionary-list section-dictionary) | |
4d902e6f CY |
181 | (append $1 |
182 | (list $2)))) | |
62a81506 CY |
183 | (flat-section-dictionary |
184 | ((SECTIONDICTIONARY string newline flat-dictionary-entry-list) | |
185 | (cons | |
186 | (read $2) | |
187 | $4))) | |
188 | (flat-dictionary-entry-list | |
189 | (nil nil) | |
190 | ((flat-dictionary-entry-list flat-dictionary-entry) | |
191 | (append $1 $2))) | |
192 | (flat-dictionary-entry | |
193 | ((variable) | |
194 | (wisent-cook-tag $1))) | |
195 | (section-dictionary | |
196 | ((SECTION string newline dictionary-entry-list END newline) | |
4d902e6f CY |
197 | (cons |
198 | (read $2) | |
199 | $4))) | |
62a81506 CY |
200 | (dictionary-entry-list |
201 | (nil nil) | |
202 | ((dictionary-entry-list dictionary-entry) | |
203 | (append $1 $2))) | |
204 | (dictionary-entry | |
4d902e6f CY |
205 | ((variable) |
206 | (wisent-cook-tag $1)) | |
62a81506 CY |
207 | ((section-dictionary) |
208 | (list $1))) | |
4d902e6f CY |
209 | (opt-bind |
210 | ((BIND string newline) | |
211 | (read $2)) | |
212 | (nil nil))) | |
213 | '(template_file))) | |
214 | "Parser table.") | |
215 | ||
216 | (defun srecode-template-wy--install-parser () | |
217 | "Setup the Semantic Parser." | |
218 | (semantic-install-function-overrides | |
219 | '((parse-stream . wisent-parse-stream))) | |
220 | (setq semantic-parser-name "LALR" | |
221 | semantic--parse-table srecode-template-wy--parse-table | |
222 | semantic-debug-parser-source "srecode-template.wy" | |
223 | semantic-flex-keywords-obarray srecode-template-wy--keyword-table | |
224 | semantic-lex-types-obarray srecode-template-wy--token-table) | |
225 | ;; Collect unmatched syntax lexical tokens | |
226 | (semantic-make-local-hook 'wisent-discarding-token-functions) | |
227 | (add-hook 'wisent-discarding-token-functions | |
228 | 'wisent-collect-unmatched-syntax nil t)) | |
229 | ||
230 | \f | |
231 | ;;; Analyzers | |
62a81506 CY |
232 | ;; |
233 | (define-lex-regex-type-analyzer srecode-template-wy--<property>-regexp-analyzer | |
234 | "regexp analyzer for <property> tokens." | |
235 | ":\\(\\w\\|\\s_\\)*" | |
78adbf9c | 236 | nil |
62a81506 | 237 | 'property) |
4d902e6f CY |
238 | |
239 | (define-lex-regex-type-analyzer srecode-template-wy--<symbol>-regexp-analyzer | |
240 | "regexp analyzer for <symbol> tokens." | |
241 | "\\(\\sw\\|\\s_\\)+" | |
242 | nil | |
243 | 'symbol) | |
244 | ||
4d902e6f CY |
245 | (define-lex-regex-type-analyzer srecode-template-wy--<number>-regexp-analyzer |
246 | "regexp analyzer for <number> tokens." | |
247 | semantic-lex-number-expression | |
248 | nil | |
249 | 'number) | |
250 | ||
62a81506 CY |
251 | (define-lex-string-type-analyzer srecode-template-wy--<punctuation>-string-analyzer |
252 | "string analyzer for <punctuation> tokens." | |
253 | "\\s.+" | |
254 | nil | |
255 | 'punctuation) | |
256 | ||
78adbf9c CY |
257 | (define-lex-sexp-type-analyzer srecode-template-wy--<string>-sexp-analyzer |
258 | "sexp analyzer for <string> tokens." | |
259 | "\\s\"" | |
260 | 'string) | |
261 | ||
262 | (define-lex-keyword-type-analyzer srecode-template-wy--<keyword>-keyword-analyzer | |
263 | "keyword analyzer for <keyword> tokens." | |
264 | "\\(\\sw\\|\\s_\\)+") | |
4d902e6f CY |
265 | |
266 | \f | |
267 | ;;; Epilogue | |
268 | ;; | |
269 | (define-lex-simple-regex-analyzer srecode-template-property-analyzer | |
270 | "Detect and create a dynamic argument properties." | |
271 | ":\\(\\w\\|\\s_\\)*" 'property 0) | |
272 | ||
273 | (define-lex-regex-analyzer srecode-template-separator-block | |
274 | "Detect and create a template quote block." | |
275 | "^----\n" | |
276 | (semantic-lex-push-token | |
277 | (semantic-lex-token | |
278 | 'TEMPLATE_BLOCK | |
279 | (match-end 0) | |
280 | (semantic-lex-unterminated-syntax-protection 'TEMPLATE_BLOCK | |
281 | (goto-char (match-end 0)) | |
282 | (re-search-forward "^----$") | |
283 | (match-beginning 0)))) | |
284 | (setq semantic-lex-end-point (point))) | |
285 | ||
286 | ||
287 | (define-lex wisent-srecode-template-lexer | |
288 | "Lexical analyzer that handles SRecode Template buffers. | |
289 | It ignores whitespace, newlines and comments." | |
290 | semantic-lex-newline | |
291 | semantic-lex-ignore-whitespace | |
292 | semantic-lex-ignore-newline | |
293 | semantic-lex-ignore-comments | |
294 | srecode-template-separator-block | |
295 | srecode-template-wy--<keyword>-keyword-analyzer | |
296 | srecode-template-property-analyzer | |
4d902e6f | 297 | srecode-template-wy--<number>-regexp-analyzer |
caaeb0e8 | 298 | srecode-template-wy--<symbol>-regexp-analyzer |
4d902e6f CY |
299 | srecode-template-wy--<string>-sexp-analyzer |
300 | srecode-template-wy--<punctuation>-string-analyzer | |
301 | semantic-lex-default-action | |
302 | ) | |
303 | ||
304 | (provide 'srecode/srt-wy) | |
305 | ||
306 | ;;; srecode/srt-wy.el ends here |