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