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/>.
22 ;; This file was generated from admin/grammars/srecode-template.wy.
26 (require 'semantic
/lex
)
27 (eval-when-compile (require 'semantic
/bovine
))
34 (defconst srecode-template-wy--keyword-table
35 (semantic-lex-make-keyword-table
40 ("template" . TEMPLATE
)
41 ("sectiondictionary" . SECTIONDICTIONARY
)
46 ("defaultmacro" . DEFAULTMACRO
)
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
75 (TEMPLATE_BLOCK .
"^----"))
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
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
)
104 ((CONTEXT symbol newline
)
106 (semantic-tag $
2 'context
))))
108 ((PROMPT symbol string opt-default-fcn opt-read-fcn newline
)
110 (semantic-tag $
2 'prompt
:text
112 :default $
4 :read $
5))))
120 ((DEFAULTMACRO string
)
131 ((SET symbol insertable-string-list newline
)
133 (semantic-tag-new-variable $
2 nil $
3)))
134 ((SET symbol number newline
)
136 (semantic-tag-new-variable $
2 nil
138 ((SHOW symbol newline
)
140 (semantic-tag-new-variable $
2 nil t
))))
141 (insertable-string-list
144 ((insertable-string-list insertable-string
)
154 ((TEMPLATE templatename opt-dynamic-arguments newline opt-string section-dictionary-list TEMPLATE_BLOCK newline opt-bind
)
156 (semantic-tag-new-function $
2 nil $
3 :documentation $
5 :code $
7 :dictionaries $
6 :binding $
9))))
167 (opt-dynamic-arguments
168 ((property opt-dynamic-arguments
)
175 (section-dictionary-list
177 ((section-dictionary-list flat-section-dictionary
)
180 ((section-dictionary-list section-dictionary
)
183 (flat-section-dictionary
184 ((SECTIONDICTIONARY string newline flat-dictionary-entry-list
)
188 (flat-dictionary-entry-list
190 ((flat-dictionary-entry-list flat-dictionary-entry
)
192 (flat-dictionary-entry
194 (wisent-cook-tag $
1)))
196 ((SECTION string newline dictionary-entry-list END newline
)
200 (dictionary-entry-list
202 ((dictionary-entry-list dictionary-entry
)
206 (wisent-cook-tag $
1))
207 ((section-dictionary)
210 ((BIND string newline
)
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
))
233 (define-lex-regex-type-analyzer srecode-template-wy--
<property
>-regexp-analyzer
234 "regexp analyzer for <property> tokens."
239 (define-lex-regex-type-analyzer srecode-template-wy--
<symbol
>-regexp-analyzer
240 "regexp analyzer for <symbol> tokens."
245 (define-lex-regex-type-analyzer srecode-template-wy--
<number
>-regexp-analyzer
246 "regexp analyzer for <number> tokens."
247 semantic-lex-number-expression
251 (define-lex-string-type-analyzer srecode-template-wy--
<punctuation
>-string-analyzer
252 "string analyzer for <punctuation> tokens."
257 (define-lex-sexp-type-analyzer srecode-template-wy--
<string
>-sexp-analyzer
258 "sexp analyzer for <string> tokens."
262 (define-lex-keyword-type-analyzer srecode-template-wy--
<keyword
>-keyword-analyzer
263 "keyword analyzer for <keyword> tokens."
264 "\\(\\sw\\|\\s_\\)+")
269 (define-lex-simple-regex-analyzer srecode-template-property-analyzer
270 "Detect and create a dynamic argument properties."
271 ":\\(\\w\\|\\s_\\)*" 'property
0)
273 (define-lex-regex-analyzer srecode-template-separator-block
274 "Detect and create a template quote block."
276 (semantic-lex-push-token
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)))
287 (define-lex wisent-srecode-template-lexer
288 "Lexical analyzer that handles SRecode Template buffers.
289 It ignores whitespace, newlines and comments."
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
297 srecode-template-wy--
<number
>-regexp-analyzer
298 srecode-template-wy--
<symbol
>-regexp-analyzer
299 srecode-template-wy--
<string
>-sexp-analyzer
300 srecode-template-wy--
<punctuation
>-string-analyzer
301 semantic-lex-default-action
304 (provide 'srecode
/srt-wy
)
306 ;;; srecode/srt-wy.el ends here