Mercurial > emacs
comparison lisp/cedet/semantic/grammar-wy.el @ 104524:fbd55cc47b77
* cedet/ede/system.el (ede-upload-html-documentation)
(ede-upload-distribution, ede-edit-web-page)
(ede-web-browse-home): Autoload.
* cedet/ede/proj-elisp.el: Add autoload for
semantic-ede-proj-target-grammar.
* cedet/semantic.el (navigate-menu): Show menu items only if
semantic-mode is enabled.
* cedet/ede.el: Remove comments.
* cedet/cedet.el (cedet-menu-map): Minor doc fix.
* cedet/semantic/grammar.el:
* cedet/semantic/grammar-wy.el:
* cedet/semantic/ede-grammar.el: New files.
* cedet/semantic/db-mode.el (global-semanticdb-minor-mode): Define
using define-minor-mode, so that the usual mode variable exists.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 27 Sep 2009 21:35:46 +0000 |
parents | |
children | 108a3a6d8be0 |
comparison
equal
deleted
inserted
replaced
104523:18ae68cd64bd | 104524:fbd55cc47b77 |
---|---|
1 ;;; semantic/grammar-wy.el --- Generated parser support file | |
2 | |
3 ;; Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: David Ponce <david@dponce.com> | |
6 ;; Keywords: syntax | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software: you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation, either version 3 of the License, or | |
13 ;; (at your option) any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
22 | |
23 ;;; Commentary: | |
24 ;; | |
25 ;; This file is generated from the grammar file semantic-grammar.wy in | |
26 ;; the upstream CEDET repository. | |
27 | |
28 ;;; Code: | |
29 | |
30 (require 'semantic/lex) | |
31 (defvar semantic-grammar-lex-c-char-re) | |
32 | |
33 ;; Current parsed nonterminal name. | |
34 (defvar semantic-grammar-wy--nterm nil) | |
35 ;; Index of rule in a nonterminal clause. | |
36 (defvar semantic-grammar-wy--rindx nil) | |
37 | |
38 ;;; Declarations | |
39 ;; | |
40 (defconst semantic-grammar-wy--keyword-table | |
41 (semantic-lex-make-keyword-table | |
42 '(("%default-prec" . DEFAULT-PREC) | |
43 ("%no-default-prec" . NO-DEFAULT-PREC) | |
44 ("%keyword" . KEYWORD) | |
45 ("%languagemode" . LANGUAGEMODE) | |
46 ("%left" . LEFT) | |
47 ("%nonassoc" . NONASSOC) | |
48 ("%package" . PACKAGE) | |
49 ("%prec" . PREC) | |
50 ("%put" . PUT) | |
51 ("%quotemode" . QUOTEMODE) | |
52 ("%right" . RIGHT) | |
53 ("%scopestart" . SCOPESTART) | |
54 ("%start" . START) | |
55 ("%token" . TOKEN) | |
56 ("%type" . TYPE) | |
57 ("%use-macros" . USE-MACROS)) | |
58 'nil) | |
59 "Table of language keywords.") | |
60 | |
61 (defconst semantic-grammar-wy--token-table | |
62 (semantic-lex-make-type-table | |
63 '(("punctuation" | |
64 (GT . ">") | |
65 (LT . "<") | |
66 (OR . "|") | |
67 (SEMI . ";") | |
68 (COLON . ":")) | |
69 ("close-paren" | |
70 (RBRACE . "}") | |
71 (RPAREN . ")")) | |
72 ("open-paren" | |
73 (LBRACE . "{") | |
74 (LPAREN . "(")) | |
75 ("block" | |
76 (BRACE_BLOCK . "(LBRACE RBRACE)") | |
77 (PAREN_BLOCK . "(LPAREN RPAREN)")) | |
78 ("code" | |
79 (EPILOGUE . "%%...EOF") | |
80 (PROLOGUE . "%{...%}")) | |
81 ("sexp" | |
82 (SEXP)) | |
83 ("qlist" | |
84 (PREFIXED_LIST)) | |
85 ("char" | |
86 (CHARACTER)) | |
87 ("symbol" | |
88 (PERCENT_PERCENT . "\\`%%\\'") | |
89 (SYMBOL)) | |
90 ("string" | |
91 (STRING))) | |
92 '(("punctuation" :declared t) | |
93 ("block" :declared t) | |
94 ("sexp" matchdatatype sexp) | |
95 ("sexp" syntax "\\=") | |
96 ("sexp" :declared t) | |
97 ("qlist" matchdatatype sexp) | |
98 ("qlist" syntax "\\s'\\s-*(") | |
99 ("qlist" :declared t) | |
100 ("char" syntax semantic-grammar-lex-c-char-re) | |
101 ("char" :declared t) | |
102 ("symbol" syntax ":?\\(\\sw\\|\\s_\\)+") | |
103 ("symbol" :declared t) | |
104 ("string" :declared t) | |
105 ("keyword" :declared t))) | |
106 "Table of lexical tokens.") | |
107 | |
108 (defconst semantic-grammar-wy--parse-table | |
109 (progn | |
110 (eval-when-compile | |
111 (require 'semantic/wisent/comp)) | |
112 (wisent-compile-grammar | |
113 '((DEFAULT-PREC NO-DEFAULT-PREC KEYWORD LANGUAGEMODE LEFT NONASSOC PACKAGE PREC PUT QUOTEMODE RIGHT SCOPESTART START TOKEN TYPE USE-MACROS STRING SYMBOL PERCENT_PERCENT CHARACTER PREFIXED_LIST SEXP PROLOGUE EPILOGUE PAREN_BLOCK BRACE_BLOCK LPAREN RPAREN LBRACE RBRACE COLON SEMI OR LT GT) | |
114 nil | |
115 (grammar | |
116 ((prologue)) | |
117 ((epilogue)) | |
118 ((declaration)) | |
119 ((nonterminal)) | |
120 ((PERCENT_PERCENT))) | |
121 (prologue | |
122 ((PROLOGUE) | |
123 (wisent-raw-tag | |
124 (semantic-tag-new-code "prologue" nil)))) | |
125 (epilogue | |
126 ((EPILOGUE) | |
127 (wisent-raw-tag | |
128 (semantic-tag-new-code "epilogue" nil)))) | |
129 (declaration | |
130 ((decl) | |
131 (eval $1))) | |
132 (decl | |
133 ((default_prec_decl)) | |
134 ((no_default_prec_decl)) | |
135 ((languagemode_decl)) | |
136 ((package_decl)) | |
137 ((precedence_decl)) | |
138 ((put_decl)) | |
139 ((quotemode_decl)) | |
140 ((scopestart_decl)) | |
141 ((start_decl)) | |
142 ((keyword_decl)) | |
143 ((token_decl)) | |
144 ((type_decl)) | |
145 ((use_macros_decl))) | |
146 (default_prec_decl | |
147 ((DEFAULT-PREC) | |
148 `(wisent-raw-tag | |
149 (semantic-tag "default-prec" 'assoc :value | |
150 '("t"))))) | |
151 (no_default_prec_decl | |
152 ((NO-DEFAULT-PREC) | |
153 `(wisent-raw-tag | |
154 (semantic-tag "default-prec" 'assoc :value | |
155 '("nil"))))) | |
156 (languagemode_decl | |
157 ((LANGUAGEMODE symbols) | |
158 `(wisent-raw-tag | |
159 (semantic-tag ',(car $2) | |
160 'languagemode :rest ',(cdr $2))))) | |
161 (package_decl | |
162 ((PACKAGE SYMBOL) | |
163 `(wisent-raw-tag | |
164 (semantic-tag-new-package ',$2 nil)))) | |
165 (precedence_decl | |
166 ((associativity token_type_opt items) | |
167 `(wisent-raw-tag | |
168 (semantic-tag ',$1 'assoc :type ',$2 :value ',$3)))) | |
169 (associativity | |
170 ((LEFT) | |
171 (progn "left")) | |
172 ((RIGHT) | |
173 (progn "right")) | |
174 ((NONASSOC) | |
175 (progn "nonassoc"))) | |
176 (put_decl | |
177 ((PUT put_name put_value) | |
178 `(wisent-raw-tag | |
179 (semantic-tag ',$2 'put :value ',(list $3)))) | |
180 ((PUT put_name put_value_list) | |
181 `(wisent-raw-tag | |
182 (semantic-tag ',$2 'put :value ',$3))) | |
183 ((PUT put_name_list put_value) | |
184 `(wisent-raw-tag | |
185 (semantic-tag ',(car $2) | |
186 'put :rest ',(cdr $2) | |
187 :value ',(list $3)))) | |
188 ((PUT put_name_list put_value_list) | |
189 `(wisent-raw-tag | |
190 (semantic-tag ',(car $2) | |
191 'put :rest ',(cdr $2) | |
192 :value ',$3)))) | |
193 (put_name_list | |
194 ((BRACE_BLOCK) | |
195 (mapcar 'semantic-tag-name | |
196 (semantic-parse-region | |
197 (car $region1) | |
198 (cdr $region1) | |
199 'put_names 1)))) | |
200 (put_names | |
201 ((LBRACE) | |
202 nil) | |
203 ((RBRACE) | |
204 nil) | |
205 ((put_name) | |
206 (wisent-raw-tag | |
207 (semantic-tag $1 'put-name)))) | |
208 (put_name | |
209 ((SYMBOL)) | |
210 ((token_type))) | |
211 (put_value_list | |
212 ((BRACE_BLOCK) | |
213 (mapcar 'semantic-tag-code-detail | |
214 (semantic-parse-region | |
215 (car $region1) | |
216 (cdr $region1) | |
217 'put_values 1)))) | |
218 (put_values | |
219 ((LBRACE) | |
220 nil) | |
221 ((RBRACE) | |
222 nil) | |
223 ((put_value) | |
224 (wisent-raw-tag | |
225 (semantic-tag-new-code "put-value" $1)))) | |
226 (put_value | |
227 ((SYMBOL any_value) | |
228 (cons $1 $2))) | |
229 (scopestart_decl | |
230 ((SCOPESTART SYMBOL) | |
231 `(wisent-raw-tag | |
232 (semantic-tag ',$2 'scopestart)))) | |
233 (quotemode_decl | |
234 ((QUOTEMODE SYMBOL) | |
235 `(wisent-raw-tag | |
236 (semantic-tag ',$2 'quotemode)))) | |
237 (start_decl | |
238 ((START symbols) | |
239 `(wisent-raw-tag | |
240 (semantic-tag ',(car $2) | |
241 'start :rest ',(cdr $2))))) | |
242 (keyword_decl | |
243 ((KEYWORD SYMBOL string_value) | |
244 `(wisent-raw-tag | |
245 (semantic-tag ',$2 'keyword :value ',$3)))) | |
246 (token_decl | |
247 ((TOKEN token_type_opt SYMBOL string_value) | |
248 `(wisent-raw-tag | |
249 (semantic-tag ',$3 ',(if $2 'token 'keyword) | |
250 :type ',$2 :value ',$4))) | |
251 ((TOKEN token_type_opt symbols) | |
252 `(wisent-raw-tag | |
253 (semantic-tag ',(car $3) | |
254 'token :type ',$2 :rest ',(cdr $3))))) | |
255 (token_type_opt | |
256 (nil) | |
257 ((token_type))) | |
258 (token_type | |
259 ((LT SYMBOL GT) | |
260 (progn $2))) | |
261 (type_decl | |
262 ((TYPE token_type plist_opt) | |
263 `(wisent-raw-tag | |
264 (semantic-tag ',$2 'type :value ',$3)))) | |
265 (plist_opt | |
266 (nil) | |
267 ((plist))) | |
268 (plist | |
269 ((plist put_value) | |
270 (append | |
271 (list $2) | |
272 $1)) | |
273 ((put_value) | |
274 (list $1))) | |
275 (use_name_list | |
276 ((BRACE_BLOCK) | |
277 (mapcar 'semantic-tag-name | |
278 (semantic-parse-region | |
279 (car $region1) | |
280 (cdr $region1) | |
281 'use_names 1)))) | |
282 (use_names | |
283 ((LBRACE) | |
284 nil) | |
285 ((RBRACE) | |
286 nil) | |
287 ((SYMBOL) | |
288 (wisent-raw-tag | |
289 (semantic-tag $1 'use-name)))) | |
290 (use_macros_decl | |
291 ((USE-MACROS SYMBOL use_name_list) | |
292 `(wisent-raw-tag | |
293 (semantic-tag "macro" 'macro :type ',$2 :value ',$3)))) | |
294 (string_value | |
295 ((STRING) | |
296 (read $1))) | |
297 (any_value | |
298 ((SYMBOL)) | |
299 ((STRING)) | |
300 ((PAREN_BLOCK)) | |
301 ((PREFIXED_LIST)) | |
302 ((SEXP))) | |
303 (symbols | |
304 ((lifo_symbols) | |
305 (nreverse $1))) | |
306 (lifo_symbols | |
307 ((lifo_symbols SYMBOL) | |
308 (cons $2 $1)) | |
309 ((SYMBOL) | |
310 (list $1))) | |
311 (nonterminal | |
312 ((SYMBOL | |
313 (setq semantic-grammar-wy--nterm $1 semantic-grammar-wy--rindx 0) | |
314 COLON rules SEMI) | |
315 (wisent-raw-tag | |
316 (semantic-tag $1 'nonterminal :children $4)))) | |
317 (rules | |
318 ((lifo_rules) | |
319 (apply 'nconc | |
320 (nreverse $1)))) | |
321 (lifo_rules | |
322 ((lifo_rules OR rule) | |
323 (cons $3 $1)) | |
324 ((rule) | |
325 (list $1))) | |
326 (rule | |
327 ((rhs) | |
328 (let* | |
329 ((nterm semantic-grammar-wy--nterm) | |
330 (rindx semantic-grammar-wy--rindx) | |
331 (rhs $1) | |
332 comps prec action elt) | |
333 (setq semantic-grammar-wy--rindx | |
334 (1+ semantic-grammar-wy--rindx)) | |
335 (while rhs | |
336 (setq elt | |
337 (car rhs) | |
338 rhs | |
339 (cdr rhs)) | |
340 (cond | |
341 ((vectorp elt) | |
342 (if prec | |
343 (error "duplicate %%prec in `%s:%d' rule" nterm rindx)) | |
344 (setq prec | |
345 (aref elt 0))) | |
346 ((consp elt) | |
347 (if | |
348 (or action comps) | |
349 (setq comps | |
350 (cons elt comps) | |
351 semantic-grammar-wy--rindx | |
352 (1+ semantic-grammar-wy--rindx)) | |
353 (setq action | |
354 (car elt)))) | |
355 (t | |
356 (setq comps | |
357 (cons elt comps))))) | |
358 (wisent-cook-tag | |
359 (wisent-raw-tag | |
360 (semantic-tag | |
361 (format "%s:%d" nterm rindx) | |
362 'rule :type | |
363 (if comps "group" "empty") | |
364 :value comps :prec prec :expr action)))))) | |
365 (rhs | |
366 (nil) | |
367 ((rhs item) | |
368 (cons $2 $1)) | |
369 ((rhs action) | |
370 (cons | |
371 (list $2) | |
372 $1)) | |
373 ((rhs PREC item) | |
374 (cons | |
375 (vector $3) | |
376 $1))) | |
377 (action | |
378 ((PAREN_BLOCK)) | |
379 ((PREFIXED_LIST)) | |
380 ((BRACE_BLOCK) | |
381 (format "(progn\n%s)" | |
382 (let | |
383 ((s $1)) | |
384 (if | |
385 (string-match "^{[ | |
386 \n ]*" s) | |
387 (setq s | |
388 (substring s | |
389 (match-end 0)))) | |
390 (if | |
391 (string-match "[ | |
392 \n ]*}$" s) | |
393 (setq s | |
394 (substring s 0 | |
395 (match-beginning 0)))) | |
396 s)))) | |
397 (items | |
398 ((lifo_items) | |
399 (nreverse $1))) | |
400 (lifo_items | |
401 ((lifo_items item) | |
402 (cons $2 $1)) | |
403 ((item) | |
404 (list $1))) | |
405 (item | |
406 ((SYMBOL)) | |
407 ((CHARACTER)))) | |
408 '(grammar prologue epilogue declaration nonterminal rule put_names put_values use_names))) | |
409 "Parser table.") | |
410 | |
411 (defun semantic-grammar-wy--install-parser () | |
412 "Setup the Semantic Parser." | |
413 (semantic-install-function-overrides | |
414 '((parse-stream . wisent-parse-stream))) | |
415 (setq semantic-parser-name "LALR" | |
416 semantic--parse-table semantic-grammar-wy--parse-table | |
417 semantic-debug-parser-source "semantic-grammar.wy" | |
418 semantic-flex-keywords-obarray semantic-grammar-wy--keyword-table | |
419 semantic-lex-types-obarray semantic-grammar-wy--token-table) | |
420 ;; Collect unmatched syntax lexical tokens | |
421 (semantic-make-local-hook 'wisent-discarding-token-functions) | |
422 (add-hook 'wisent-discarding-token-functions | |
423 'wisent-collect-unmatched-syntax nil t)) | |
424 | |
425 | |
426 ;;; Analyzers | |
427 | |
428 (define-lex-sexp-type-analyzer semantic-grammar-wy--<sexp>-sexp-analyzer | |
429 "sexp analyzer for <sexp> tokens." | |
430 "\\=" | |
431 'SEXP) | |
432 | |
433 (define-lex-sexp-type-analyzer semantic-grammar-wy--<qlist>-sexp-analyzer | |
434 "sexp analyzer for <qlist> tokens." | |
435 "\\s'\\s-*(" | |
436 'PREFIXED_LIST) | |
437 | |
438 (define-lex-keyword-type-analyzer semantic-grammar-wy--<keyword>-keyword-analyzer | |
439 "keyword analyzer for <keyword> tokens." | |
440 "\\(\\sw\\|\\s_\\)+") | |
441 | |
442 (define-lex-block-type-analyzer semantic-grammar-wy--<block>-block-analyzer | |
443 "block analyzer for <block> tokens." | |
444 "\\s(\\|\\s)" | |
445 '((("(" LPAREN PAREN_BLOCK) | |
446 ("{" LBRACE BRACE_BLOCK)) | |
447 (")" RPAREN) | |
448 ("}" RBRACE)) | |
449 ) | |
450 | |
451 (define-lex-regex-type-analyzer semantic-grammar-wy--<char>-regexp-analyzer | |
452 "regexp analyzer for <char> tokens." | |
453 semantic-grammar-lex-c-char-re | |
454 nil | |
455 'CHARACTER) | |
456 | |
457 (define-lex-sexp-type-analyzer semantic-grammar-wy--<string>-sexp-analyzer | |
458 "sexp analyzer for <string> tokens." | |
459 "\\s\"" | |
460 'STRING) | |
461 | |
462 (define-lex-regex-type-analyzer semantic-grammar-wy--<symbol>-regexp-analyzer | |
463 "regexp analyzer for <symbol> tokens." | |
464 ":?\\(\\sw\\|\\s_\\)+" | |
465 '((PERCENT_PERCENT . "\\`%%\\'")) | |
466 'SYMBOL) | |
467 | |
468 (define-lex-string-type-analyzer semantic-grammar-wy--<punctuation>-string-analyzer | |
469 "string analyzer for <punctuation> tokens." | |
470 "\\(\\s.\\|\\s$\\|\\s'\\)+" | |
471 '((GT . ">") | |
472 (LT . "<") | |
473 (OR . "|") | |
474 (SEMI . ";") | |
475 (COLON . ":")) | |
476 'punctuation) | |
477 | |
478 (provide 'semantic/grammar-wy) | |
479 | |
480 ;;; semantic/grammar-wy.el ends here |