1 ;;; srecode/srt-wy.el --- Generated parser support file
3 ;; Copyright (C) 2005, 2007-2011 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)
33 (defconst srecode-template-wy--keyword-table
34 (semantic-lex-make-keyword-table
39 ("template" . TEMPLATE)
40 ("sectiondictionary" . SECTIONDICTIONARY)
43 ("defaultmacro" . DEFAULTMACRO)
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.")
59 (defconst srecode-template-wy--token-table
60 (semantic-lex-make-type-table
70 (TEMPLATE_BLOCK . "^----"))
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.")
83 (defconst srecode-template-wy--parse-table
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)
98 ((CONTEXT symbol newline)
100 (semantic-tag $2 'context))))
102 ((PROMPT symbol string opt-default-fcn opt-read-fcn newline)
104 (semantic-tag $2 'prompt :text
106 :default $4 :read $5))))
114 ((DEFAULTMACRO string)
125 ((SET symbol insertable-string-list newline)
127 (semantic-tag-new-variable $2 nil $3)))
128 ((SHOW symbol newline)
130 (semantic-tag-new-variable $2 nil t))))
131 (insertable-string-list
134 ((insertable-string-list insertable-string)
144 ((TEMPLATE templatename opt-dynamic-arguments newline opt-string opt-section-dictionaries TEMPLATE_BLOCK newline opt-bind)
146 (semantic-tag-new-function $2 nil $3 :documentation $5 :code $7 :dictionaries $6 :binding $9))))
157 (opt-dynamic-arguments
158 ((property opt-dynamic-arguments)
165 (opt-section-dictionaries
167 ((section-dictionary-list)))
168 (section-dictionary-list
169 ((one-section-dictionary)
171 ((section-dictionary-list one-section-dictionary)
174 (one-section-dictionary
175 ((SECTIONDICTIONARY string newline variable-list)
181 (wisent-cook-tag $1))
182 ((variable-list variable)
184 (wisent-cook-tag $2))))
186 ((BIND string newline)
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))
209 (define-lex-string-type-analyzer srecode-template-wy--<punctuation>-string-analyzer
210 "string analyzer for <punctuation> tokens."
215 (define-lex-regex-type-analyzer srecode-template-wy--<symbol>-regexp-analyzer
216 "regexp analyzer for <symbol> tokens."
221 (define-lex-regex-type-analyzer srecode-template-wy--<number>-regexp-analyzer
222 "regexp analyzer for <number> tokens."
223 semantic-lex-number-expression
227 (define-lex-sexp-type-analyzer srecode-template-wy--<string>-sexp-analyzer
228 "sexp analyzer for <string> tokens."
232 (define-lex-keyword-type-analyzer srecode-template-wy--<keyword>-keyword-analyzer
233 "keyword analyzer for <keyword> tokens."
234 "\\(\\sw\\|\\s_\\)+")
239 (define-lex-simple-regex-analyzer srecode-template-property-analyzer
240 "Detect and create a dynamic argument properties."
241 ":\\(\\w\\|\\s_\\)*" 'property 0)
243 (define-lex-regex-analyzer srecode-template-separator-block
244 "Detect and create a template quote block."
246 (semantic-lex-push-token
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)))
257 (define-lex wisent-srecode-template-lexer
258 "Lexical analyzer that handles SRecode Template buffers.
259 It ignores whitespace, newlines and comments."
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
274 (provide 'srecode/srt-wy)
276 ;;; srecode/srt-wy.el ends here