Update copyright notices for 2013.
[emacs.git] / lisp / cedet / srecode / srt-wy.el
blob5560d35a70c41bc522ea31bba7bc0b02d4227839
1 ;;; srecode/srt-wy.el --- Generated parser support file
3 ;; Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
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.
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.
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/>.
20 ;;; Commentary:
22 ;; This file was generated from admin/grammars/srecode-template.wy.
24 ;;; Code:
26 (require 'semantic/lex)
27 (eval-when-compile (require 'semantic/bovine))
29 ;;; Prologue
32 ;;; Declarations
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 ("section" . SECTION)
43 ("end" . END)
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>]")
54 ("end" summary "section ... end")
55 ("section" summary "section <name>\\n <dictionary entries>\\n end")
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.")
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)
81 ("property" syntax ":\\(\\w\\|\\s_\\)*")
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.")
89 (defconst srecode-template-wy--parse-table
90 (progn
91 (eval-when-compile
92 (require 'semantic/wisent/comp))
93 (wisent-compile-grammar
94 '((SET SHOW MACRO CONTEXT TEMPLATE SECTIONDICTIONARY SECTION END PROMPT DEFAULT DEFAULTMACRO READ BIND newline TEMPLATE_BLOCK property symbol string number)
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)))
134 ((SHOW symbol newline)
135 (wisent-raw-tag
136 (semantic-tag-new-variable $2 nil t))))
137 (insertable-string-list
138 ((insertable-string)
139 (list $1))
140 ((insertable-string-list insertable-string)
141 (append $1
142 (list $2))))
143 (insertable-string
144 ((string)
145 (read $1))
146 ((MACRO string)
147 (cons 'macro
148 (read $2))))
149 (template
150 ((TEMPLATE templatename opt-dynamic-arguments newline opt-string section-dictionary-list TEMPLATE_BLOCK newline opt-bind)
151 (wisent-raw-tag
152 (semantic-tag-new-function $2 nil $3 :documentation $5 :code $7 :dictionaries $6 :binding $9))))
153 (templatename
154 ((symbol))
155 ((PROMPT))
156 ((CONTEXT))
157 ((TEMPLATE))
158 ((DEFAULT))
159 ((MACRO))
160 ((DEFAULTMACRO))
161 ((READ))
162 ((SET)))
163 (opt-dynamic-arguments
164 ((property opt-dynamic-arguments)
165 (cons $1 $2))
166 (nil nil))
167 (opt-string
168 ((string newline)
169 (read $1))
170 (nil nil))
171 (section-dictionary-list
172 (nil nil)
173 ((section-dictionary-list flat-section-dictionary)
174 (append $1
175 (list $2)))
176 ((section-dictionary-list section-dictionary)
177 (append $1
178 (list $2))))
179 (flat-section-dictionary
180 ((SECTIONDICTIONARY string newline flat-dictionary-entry-list)
181 (cons
182 (read $2)
183 $4)))
184 (flat-dictionary-entry-list
185 (nil nil)
186 ((flat-dictionary-entry-list flat-dictionary-entry)
187 (append $1 $2)))
188 (flat-dictionary-entry
189 ((variable)
190 (wisent-cook-tag $1)))
191 (section-dictionary
192 ((SECTION string newline dictionary-entry-list END newline)
193 (cons
194 (read $2)
195 $4)))
196 (dictionary-entry-list
197 (nil nil)
198 ((dictionary-entry-list dictionary-entry)
199 (append $1 $2)))
200 (dictionary-entry
201 ((variable)
202 (wisent-cook-tag $1))
203 ((section-dictionary)
204 (list $1)))
205 (opt-bind
206 ((BIND string newline)
207 (read $2))
208 (nil nil)))
209 '(template_file)))
210 "Parser table.")
212 (defun srecode-template-wy--install-parser ()
213 "Setup the Semantic Parser."
214 (semantic-install-function-overrides
215 '((parse-stream . wisent-parse-stream)))
216 (setq semantic-parser-name "LALR"
217 semantic--parse-table srecode-template-wy--parse-table
218 semantic-debug-parser-source "srecode-template.wy"
219 semantic-flex-keywords-obarray srecode-template-wy--keyword-table
220 semantic-lex-types-obarray srecode-template-wy--token-table)
221 ;; Collect unmatched syntax lexical tokens
222 (semantic-make-local-hook 'wisent-discarding-token-functions)
223 (add-hook 'wisent-discarding-token-functions
224 'wisent-collect-unmatched-syntax nil t))
227 ;;; Analyzers
229 (define-lex-regex-type-analyzer srecode-template-wy--<property>-regexp-analyzer
230 "regexp analyzer for <property> tokens."
231 ":\\(\\w\\|\\s_\\)*"
233 'property)
235 (define-lex-regex-type-analyzer srecode-template-wy--<symbol>-regexp-analyzer
236 "regexp analyzer for <symbol> tokens."
237 "\\(\\sw\\|\\s_\\)+"
239 'symbol)
241 (define-lex-regex-type-analyzer srecode-template-wy--<number>-regexp-analyzer
242 "regexp analyzer for <number> tokens."
243 semantic-lex-number-expression
245 'number)
247 (define-lex-string-type-analyzer srecode-template-wy--<punctuation>-string-analyzer
248 "string analyzer for <punctuation> tokens."
249 "\\s.+"
251 'punctuation)
253 (define-lex-sexp-type-analyzer srecode-template-wy--<string>-sexp-analyzer
254 "sexp analyzer for <string> tokens."
255 "\\s\""
256 'string)
258 (define-lex-keyword-type-analyzer srecode-template-wy--<keyword>-keyword-analyzer
259 "keyword analyzer for <keyword> tokens."
260 "\\(\\sw\\|\\s_\\)+")
263 ;;; Epilogue
265 (define-lex-simple-regex-analyzer srecode-template-property-analyzer
266 "Detect and create a dynamic argument properties."
267 ":\\(\\w\\|\\s_\\)*" 'property 0)
269 (define-lex-regex-analyzer srecode-template-separator-block
270 "Detect and create a template quote block."
271 "^----\n"
272 (semantic-lex-push-token
273 (semantic-lex-token
274 'TEMPLATE_BLOCK
275 (match-end 0)
276 (semantic-lex-unterminated-syntax-protection 'TEMPLATE_BLOCK
277 (goto-char (match-end 0))
278 (re-search-forward "^----$")
279 (match-beginning 0))))
280 (setq semantic-lex-end-point (point)))
283 (define-lex wisent-srecode-template-lexer
284 "Lexical analyzer that handles SRecode Template buffers.
285 It ignores whitespace, newlines and comments."
286 semantic-lex-newline
287 semantic-lex-ignore-whitespace
288 semantic-lex-ignore-newline
289 semantic-lex-ignore-comments
290 srecode-template-separator-block
291 srecode-template-wy--<keyword>-keyword-analyzer
292 srecode-template-property-analyzer
293 srecode-template-wy--<symbol>-regexp-analyzer
294 srecode-template-wy--<number>-regexp-analyzer
295 srecode-template-wy--<string>-sexp-analyzer
296 srecode-template-wy--<punctuation>-string-analyzer
297 semantic-lex-default-action
300 (provide 'srecode/srt-wy)
302 ;;; srecode/srt-wy.el ends here