aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorChong Yidong2011-11-26 14:28:10 +0800
committerChong Yidong2011-11-26 14:28:10 +0800
commit78adbf9c3f71e4387d4b01697b76999c883735c4 (patch)
tree7a710875d877cffe0cce1eb07ae816591a3d4e9d /admin
parent91b4a718988e9d56c2e135d3d41ae3578cbacffd (diff)
downloademacs-78adbf9c3f71e4387d4b01697b76999c883735c4.tar.gz
emacs-78adbf9c3f71e4387d4b01697b76999c883735c4.zip
Add grammar files for grammar-wy.el and wrt-wy.el.
Regenerate the relevant CEDET parsers. * admin/grammars/bovine-grammar.el: * admin/grammars/wisent-grammar.el: Add scripts for generating the parsers.
Diffstat (limited to 'admin')
-rw-r--r--admin/grammars/README13
-rw-r--r--admin/grammars/bovine-grammar.el62
-rw-r--r--admin/grammars/grammar.wy434
-rw-r--r--admin/grammars/srecode-template.wy235
-rw-r--r--admin/grammars/wisent-grammar.el176
5 files changed, 909 insertions, 11 deletions
diff --git a/admin/grammars/README b/admin/grammars/README
index c8328bbc885..419797e0dcb 100644
--- a/admin/grammars/README
+++ b/admin/grammars/README
@@ -3,17 +3,8 @@ generate the parser data in the lisp/semantic/bovine/ and
3lisp/semantic/wisent/ directories. You can run the parser generators 3lisp/semantic/wisent/ directories. You can run the parser generators
4with 4with
5 5
6emacs -batch --no-site-file -l bovine-grammar.el -f semantic-mode \ 6emacs -batch -Q -l bovine-grammar.el -f bovine-make-parsers
7 -f semantic-grammar-batch-build-packages *.by 7emacs -batch -Q -l wisent-grammar.el -f wisent-make-parsers
8
9emacs -batch --no-site-file -l wisent-grammar.el -f semantic-mode \
10 -f semantic-grammar-batch-build-packages *.wy
11
12The output files were subsequently edited by hand to fix copyright
13headers, variable names (to follow library name conventions), and
14feature names. These changes do not alter the code logic, and can be
15viewed by diffing to the files in lisp/semantic/bovine/ and
16lisp/semantic/wisent/.
17 8
18Currently, the parser files in lisp/ are not generated directly from 9Currently, the parser files in lisp/ are not generated directly from
19these grammar files when making Emacs. This state of affairs, and the 10these grammar files when making Emacs. This state of affairs, and the
diff --git a/admin/grammars/bovine-grammar.el b/admin/grammars/bovine-grammar.el
index 0e8756e1c5b..3ff15fab66f 100644
--- a/admin/grammars/bovine-grammar.el
+++ b/admin/grammars/bovine-grammar.el
@@ -454,4 +454,66 @@ Menu items are appended to the common grammar menu.")
454 454
455(provide 'semantic/bovine/grammar) 455(provide 'semantic/bovine/grammar)
456 456
457(defun bovine-make-parsers ()
458 "Generate Emacs' built-in Bovine-based parser files."
459 (semantic-mode 1)
460 ;; Loop through each .by file in current directory, and run
461 ;; `semantic-grammar-batch-build-one-package' to build the grammar.
462 (dolist (f (directory-files default-directory nil ".by$"))
463 (let ((packagename
464 (condition-case err
465 (with-current-buffer (find-file-noselect f)
466 (semantic-grammar-create-package))
467 (error (message "%s" (error-message-string err)) nil)))
468 lang)
469 (when (and packagename
470 (string-match "^semantic-\\(.*\\)-by.el$" packagename))
471 (setq lang (match-string 1 packagename))
472 (with-temp-buffer
473 (insert-file-contents packagename)
474 (setq buffer-file-name (expand-file-name packagename))
475 ;; Fix copyright header:
476 (goto-char (point-min))
477 (re-search-forward "^;; Author:")
478 (setq copyright-end (match-beginning 0))
479 (re-search-forward "^;;; Code:\n")
480 (delete-region copyright-end (match-end 0))
481 (goto-char copyright-end)
482 (insert ";; This file is part of GNU Emacs.
483
484;; GNU Emacs is free software: you can redistribute it and/or modify
485;; it under the terms of the GNU General Public License as published by
486;; the Free Software Foundation, either version 3 of the License, or
487;; (at your option) any later version.
488
489;; GNU Emacs is distributed in the hope that it will be useful,
490;; but WITHOUT ANY WARRANTY; without even the implied warranty of
491;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
492;; GNU General Public License for more details.
493
494;; You should have received a copy of the GNU General Public License
495;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
496
497;;; Commentary:
498;;
499;; This file was generated from admin/grammars/"
500 lang ".by.
501
502;;; Code:
503
504\(require 'semantic/lex)
505\(eval-when-compile (require 'semantic/bovine))\n")
506 (goto-char (point-min))
507 (delete-region (point-min) (line-end-position))
508 (insert ";;; semantic/bovine/" lang
509 "-by.el --- Generated parser support file")
510 (delete-trailing-whitespace)
511 ;; Fix footer:
512 (goto-char (point-max))
513 (re-search-backward ".\n;;; Analyzers")
514 (delete-region (point) (point-max))
515 (insert "(provide 'semantic/bovine/" lang "-by)\n\n")
516 (insert ";;; semantic/bovine/" lang "-by.el ends here\n")
517 (save-buffer))))))
518
457;;; bovine-grammar.el ends here 519;;; bovine-grammar.el ends here
diff --git a/admin/grammars/grammar.wy b/admin/grammars/grammar.wy
new file mode 100644
index 00000000000..18e8b814303
--- /dev/null
+++ b/admin/grammars/grammar.wy
@@ -0,0 +1,434 @@
1;;; semantic-grammar.wy -- LALR grammar of Semantic input grammars
2;;
3;; Copyright (C) 2002-2011 Free Software Foundation, Inc.
4;;
5;; Author: David Ponce <david@dponce.com>
6;; Maintainer: David Ponce <david@dponce.com>
7;; Created: 26 Aug 2002
8;; Keywords: syntax
9;; X-RCS: $Id: semantic-grammar.wy,v 1.16 2005/09/30 20:20:27 zappo Exp $
10
11;; This file is part of GNU Emacs.
12
13;; GNU Emacs is free software: you can redistribute it and/or modify
14;; it under the terms of the GNU General Public License as published by
15;; the Free Software Foundation, either version 3 of the License, or
16;; (at your option) any later version.
17
18;; GNU Emacs is distributed in the hope that it will be useful,
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;; GNU General Public License for more details.
22
23;; You should have received a copy of the GNU General Public License
24;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25
26%{
27(defvar semantic-grammar-lex-c-char-re)
28
29;; Current parsed nonterminal name.
30(defvar semantic-grammar-wy--nterm nil)
31;; Index of rule in a nonterminal clause.
32(defvar semantic-grammar-wy--rindx nil)
33}
34
35%package semantic-grammar-wy
36
37%languagemode wy-mode
38
39;; Main
40%start grammar
41;; Reparse
42%start prologue epilogue declaration nonterminal rule
43;; EXPANDFULL
44%start put_names put_values use_names
45
46;; Keywords
47%type <keyword>
48%keyword DEFAULT-PREC "%default-prec"
49%keyword NO-DEFAULT-PREC "%no-default-prec"
50%keyword KEYWORD "%keyword"
51%keyword LANGUAGEMODE "%languagemode"
52%keyword LEFT "%left"
53%keyword NONASSOC "%nonassoc"
54%keyword PACKAGE "%package"
55%keyword PREC "%prec"
56%keyword PUT "%put"
57%keyword QUOTEMODE "%quotemode"
58%keyword RIGHT "%right"
59%keyword SCOPESTART "%scopestart"
60%keyword START "%start"
61%keyword TOKEN "%token"
62%keyword TYPE "%type"
63%keyword USE-MACROS "%use-macros"
64
65;; Literals
66%type <string>
67%token <string> STRING
68
69%type <symbol> syntax ":?\\(\\sw\\|\\s_\\)+"
70%token <symbol> SYMBOL
71%token <symbol> PERCENT_PERCENT "\\`%%\\'"
72
73%type <char> syntax semantic-grammar-lex-c-char-re
74%token <char> CHARACTER
75
76%type <qlist> matchdatatype sexp syntax "\\s'\\s-*("
77%token <qlist> PREFIXED_LIST
78
79%type <sexp> matchdatatype sexp syntax "\\="
80%token <sexp> SEXP
81
82;; Don't generate these analyzers which needs special handling code.
83%token <code> PROLOGUE "%{...%}"
84%token <code> EPILOGUE "%%...EOF"
85
86;; Blocks & Parenthesis
87%type <block>
88%token <block> PAREN_BLOCK "(LPAREN RPAREN)"
89%token <block> BRACE_BLOCK "(LBRACE RBRACE)"
90%token <open-paren> LPAREN "("
91%token <close-paren> RPAREN ")"
92%token <open-paren> LBRACE "{"
93%token <close-paren> RBRACE "}"
94
95;; Punctuations
96%type <punctuation>
97%token <punctuation> COLON ":"
98%token <punctuation> SEMI ";"
99%token <punctuation> OR "|"
100%token <punctuation> LT "<"
101%token <punctuation> GT ">"
102
103%%
104
105grammar:
106 prologue
107 | epilogue
108 | declaration
109 | nonterminal
110 | PERCENT_PERCENT
111 ;
112
113;;; Prologue/Epilogue
114;;
115prologue:
116 PROLOGUE
117 (CODE-TAG "prologue" nil)
118 ;
119
120epilogue:
121 EPILOGUE
122 (CODE-TAG "epilogue" nil)
123 ;
124
125;;; Declarations
126;;
127declaration:
128 decl
129 (eval $1)
130 ;
131
132decl:
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 ;
147
148default_prec_decl:
149 DEFAULT-PREC
150 `(TAG "default-prec" 'assoc :value '("t"))
151 ;
152
153no_default_prec_decl:
154 NO-DEFAULT-PREC
155 `(TAG "default-prec" 'assoc :value '("nil"))
156 ;
157
158languagemode_decl:
159 LANGUAGEMODE symbols
160 `(TAG ',(car $2) 'languagemode :rest ',(cdr $2))
161 ;
162
163package_decl:
164 PACKAGE SYMBOL
165 `(PACKAGE-TAG ',$2 nil)
166 ;
167
168precedence_decl:
169 associativity token_type_opt items
170 `(TAG ',$1 'assoc :type ',$2 :value ',$3)
171 ;
172
173associativity:
174 LEFT
175 (progn "left")
176 | RIGHT
177 (progn "right")
178 | NONASSOC
179 (progn "nonassoc")
180 ;
181
182put_decl:
183 PUT put_name put_value
184 `(TAG ',$2 'put :value ',(list $3))
185 | PUT put_name put_value_list
186 `(TAG ',$2 'put :value ',$3)
187 | PUT put_name_list put_value
188 `(TAG ',(car $2) 'put :rest ',(cdr $2) :value ',(list $3))
189 | PUT put_name_list put_value_list
190 `(TAG ',(car $2) 'put :rest ',(cdr $2) :value ',$3)
191 ;
192
193put_name_list:
194 BRACE_BLOCK
195 (mapcar 'semantic-tag-name (EXPANDFULL $1 put_names))
196 ;
197
198put_names:
199 LBRACE
200 ()
201 | RBRACE
202 ()
203 | put_name
204 ;; Must return a list of Semantic tags to EXPANDFULL!
205 (TAG $1 'put-name)
206 ;
207
208put_name:
209 SYMBOL
210 | token_type
211 ;
212
213put_value_list:
214 BRACE_BLOCK
215 (mapcar 'semantic-tag-code-detail (EXPANDFULL $1 put_values))
216 ;
217
218put_values:
219 LBRACE
220 ()
221 | RBRACE
222 ()
223 | put_value
224 ;; Must return a list of Semantic tags to EXPANDFULL!
225 (CODE-TAG "put-value" $1)
226 ;
227
228put_value:
229 SYMBOL any_value
230 (cons $1 $2)
231 ;
232
233scopestart_decl:
234 SCOPESTART SYMBOL
235 `(TAG ',$2 'scopestart)
236 ;
237
238quotemode_decl:
239 QUOTEMODE SYMBOL
240 `(TAG ',$2 'quotemode)
241 ;
242
243start_decl:
244 START symbols
245 `(TAG ',(car $2) 'start :rest ',(cdr $2))
246 ;
247
248keyword_decl:
249 KEYWORD SYMBOL string_value
250 `(TAG ',$2 'keyword :value ',$3)
251 ;
252
253token_decl:
254 TOKEN token_type_opt SYMBOL string_value
255 `(TAG ',$3 ',(if $2 'token 'keyword) :type ',$2 :value ',$4)
256 | TOKEN token_type_opt symbols
257 `(TAG ',(car $3) 'token :type ',$2 :rest ',(cdr $3))
258 ;
259
260token_type_opt:
261 ;; EMPTY
262 | token_type
263 ;
264
265token_type:
266 LT SYMBOL GT
267 (progn $2)
268 ;
269
270type_decl:
271 TYPE token_type plist_opt
272 `(TAG ',$2 'type :value ',$3)
273 ;
274
275plist_opt:
276 ;;EMPTY
277 | plist
278 ;
279
280plist:
281 plist put_value
282 (append (list $2) $1)
283 | put_value
284 (list $1)
285 ;
286
287use_name_list:
288 BRACE_BLOCK
289 (mapcar 'semantic-tag-name (EXPANDFULL $1 use_names))
290 ;
291
292use_names:
293 LBRACE
294 ()
295 | RBRACE
296 ()
297 | SYMBOL
298 ;; Must return a list of Semantic tags to EXPANDFULL!
299 (TAG $1 'use-name)
300 ;
301
302use_macros_decl:
303 USE-MACROS SYMBOL use_name_list
304 `(TAG "macro" 'macro :type ',$2 :value ',$3)
305 ;
306
307string_value:
308 STRING
309 (read $1)
310 ;
311
312;; Return a Lisp readable form
313any_value:
314 SYMBOL
315 | STRING
316 | PAREN_BLOCK
317 | PREFIXED_LIST
318 | SEXP
319 ;
320
321symbols:
322 lifo_symbols
323 (nreverse $1)
324 ;
325
326lifo_symbols:
327 lifo_symbols SYMBOL
328 (cons $2 $1)
329 | SYMBOL
330 (list $1)
331 ;
332
333;;; Grammar rules
334;;
335nonterminal:
336 SYMBOL
337 (setq semantic-grammar-wy--nterm $1
338 semantic-grammar-wy--rindx 0)
339 COLON rules SEMI
340 (TAG $1 'nonterminal :children $4)
341 ;
342
343rules:
344 lifo_rules
345 (apply 'nconc (nreverse $1))
346 ;
347
348lifo_rules:
349 lifo_rules OR rule
350 (cons $3 $1)
351 | rule
352 (list $1)
353 ;
354
355rule:
356 rhs
357 (let* ((nterm semantic-grammar-wy--nterm)
358 (rindx semantic-grammar-wy--rindx)
359 (rhs $1)
360 comps prec action elt)
361 (setq semantic-grammar-wy--rindx (1+ semantic-grammar-wy--rindx))
362 (while rhs
363 (setq elt (car rhs)
364 rhs (cdr rhs))
365 (cond
366 ;; precedence level
367 ((vectorp elt)
368 (if prec
369 (error "Duplicate %%prec in `%s:%d' rule" nterm rindx))
370 (setq prec (aref elt 0)))
371 ;; action
372 ((consp elt)
373 ;; don't forget that rhs items are in reverse order, so
374 ;; the end-of-rule semantic action is the first item.
375 (if (or action comps)
376 ;; a mid-rule action
377 (setq comps (cons elt comps)
378 ;; keep rule and action index synchronized
379 semantic-grammar-wy--rindx
380 (1+ semantic-grammar-wy--rindx))
381 ;; the end-of-rule action
382 (setq action (car elt))))
383 ;; item
384 (t
385 (setq comps (cons elt comps)))))
386 (EXPANDTAG
387 (TAG (format "%s:%d" nterm rindx) 'rule
388 :type (if comps "group" "empty")
389 :value comps :prec prec :expr action)))
390 ;
391
392rhs:
393 ;; EMPTY
394 | rhs item
395 (cons $2 $1)
396 | rhs action
397 (cons (list $2) $1)
398 | rhs PREC item
399 (cons (vector $3) $1)
400 ;
401
402action:
403 PAREN_BLOCK
404 | PREFIXED_LIST
405 | BRACE_BLOCK
406 (format "(progn\n%s)"
407 (let ((s $1))
408 (if (string-match "^{[\r\n\t ]*" s)
409 (setq s (substring s (match-end 0))))
410 (if (string-match "[\r\n\t ]*}$" s)
411 (setq s (substring s 0 (match-beginning 0))))
412 s))
413 ;
414
415items:
416 lifo_items
417 (nreverse $1)
418 ;
419
420lifo_items:
421 lifo_items item
422 (cons $2 $1)
423 | item
424 (list $1)
425 ;
426
427item:
428 SYMBOL
429 | CHARACTER
430 ;
431
432%%
433
434;;; grammar.wy ends here
diff --git a/admin/grammars/srecode-template.wy b/admin/grammars/srecode-template.wy
new file mode 100644
index 00000000000..4ff2d7e4e41
--- /dev/null
+++ b/admin/grammars/srecode-template.wy
@@ -0,0 +1,235 @@
1;;; srecode-template.wy --- Semantic Recoder Template parser
2
3;; Copyright (C) 2005-2011 Free Software Foundation, Inc.
4
5;; Author: Eric Ludlam <zappo@gnu.org>
6;; Keywords: syntax
7;; X-RCS: $Id: srecode-template.wy,v 1.10 2009-01-09 23:01:54 zappo Exp $
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software: you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24;;; Commentary:
25;;
26;; Parser for the Semantic Recoder template language
27;;
28;; Semantic Recoder templates are based on Google Templates
29;; and are at the bottom of the Semantic Recoder API.
30
31%languagemode srecode-mode
32
33%start template_file
34
35;;; KEYWORDS
36%type <keyword>
37%keyword SET "set"
38%put SET summary "set <name> <value>"
39%keyword SHOW "show"
40%put SHOW summary "show <name> ; to show a section"
41%keyword MACRO "macro"
42%put MACRO summary "... macro \"string\" ..."
43%keyword CONTEXT "context"
44%put CONTEXT summary "context <name>"
45%keyword TEMPLATE "template"
46%put TEMPLATE summary "template <name>\\n <template definition>"
47%keyword SECTIONDICTIONARY "sectiondictionary"
48%put SECTIONDICTIONARY summary "sectiondictionary <name>\\n <dictionary entries>"
49%keyword PROMPT "prompt"
50%keyword DEFAULT "default"
51%keyword DEFAULTMACRO "defaultmacro"
52%keyword READ "read"
53%put { PROMPT DEFAULT DEFAULTMACRO READ } summary "prompt <symbol> \"Describe Symbol: \" [default[macro] <lispsym>|\"valuetext\"] [read <lispsym>]"
54%keyword BIND "bind"
55%put BIND summary "bind \"<letter>\""
56
57;;; Punctuation Types
58%type <punctuation> syntax "\\s.+"
59%type <newline>
60%token <newline> newline
61
62%token <separator> TEMPLATE_BLOCK "^----"
63
64;;; Bland default types
65%type <property> ":\\(\\w\\|\\s_\\)*"
66%token <property> property
67
68%type <symbol>
69%token <symbol> symbol
70
71%type <string>
72%token <string> string
73
74%type <number>
75%token <number> number
76
77%%
78
79template_file
80 : newline ( )
81 | context
82 | prompt
83 | variable
84 | template
85 ;
86
87context
88 : CONTEXT symbol newline
89 (TAG $2 'context)
90 ;
91
92prompt
93 : PROMPT symbol string opt-default-fcn opt-read-fcn newline
94 (TAG $2 'prompt :text (read $3) :default $4 :read $5)
95 ;
96
97opt-default-fcn
98 : DEFAULT symbol
99 (progn (read $2))
100 | DEFAULT string
101 (progn (read $2))
102 | DEFAULTMACRO string
103 (progn (cons 'macro (read $2)))
104 | ()
105 ;
106
107opt-read-fcn
108 : READ symbol
109 (progn (read $2))
110 | ()
111 ;
112
113variable
114 : SET symbol insertable-string-list newline
115 (VARIABLE-TAG $2 nil $3)
116 | SHOW symbol newline
117 (VARIABLE-TAG $2 nil t)
118 ;
119
120insertable-string-list
121 : insertable-string
122 (list $1)
123 | insertable-string-list insertable-string
124 (append $1 (list $2))
125 ;
126
127insertable-string
128 : string
129 (read $1)
130 | MACRO string
131 (cons 'macro (read $2))
132 ;
133
134template
135 : TEMPLATE templatename opt-dynamic-arguments newline
136 opt-string
137 opt-section-dictionaries
138 TEMPLATE_BLOCK newline
139 opt-bind
140 (FUNCTION-TAG $2 nil $3 :documentation $5 :code $7
141 :dictionaries $6 :binding $9 )
142 ;
143
144templatename
145 : symbol
146 | PROMPT
147 | CONTEXT
148 | TEMPLATE
149 | DEFAULT
150 | MACRO
151 | DEFAULTMACRO
152 | READ
153 | SET
154 ;
155
156opt-dynamic-arguments
157 : property opt-dynamic-arguments
158 (cons $1 $2)
159 | ()
160 ;
161
162opt-string
163 : string newline
164 ( read $1 )
165 | ()
166 ;
167
168opt-section-dictionaries
169 : () ;; EMPTY
170 | section-dictionary-list
171 ;
172
173section-dictionary-list
174 : one-section-dictionary
175 (list $1)
176 | section-dictionary-list one-section-dictionary
177 (append $1 (list $2))
178 ;
179
180one-section-dictionary
181 : SECTIONDICTIONARY string newline
182 variable-list
183 (cons (read $2) $4)
184 ;
185
186variable-list
187 : variable
188 (EXPANDTAG $1)
189 | variable-list variable
190 (append $1 (EXPANDTAG $2))
191 ;
192
193opt-bind
194 : BIND string newline
195 ( read $2 )
196 | ()
197 ;
198
199%%
200(define-lex-simple-regex-analyzer srecode-template-property-analyzer
201 "Detect and create a dynamic argument properties."
202 ":\\(\\w\\|\\s_\\)*" 'property 0)
203
204(define-lex-regex-analyzer srecode-template-separator-block
205 "Detect and create a template quote block."
206 "^----\n"
207 (semantic-lex-push-token
208 (semantic-lex-token
209 'TEMPLATE_BLOCK
210 (match-end 0)
211 (semantic-lex-unterminated-syntax-protection 'TEMPLATE_BLOCK
212 (goto-char (match-end 0))
213 (re-search-forward "^----$")
214 (match-beginning 0))))
215 (setq semantic-lex-end-point (point)))
216
217
218(define-lex wisent-srecode-template-lexer
219 "Lexical analyzer that handles SRecode Template buffers.
220It ignores whitespace, newlines and comments."
221 semantic-lex-newline
222 semantic-lex-ignore-whitespace
223 semantic-lex-ignore-newline
224 semantic-lex-ignore-comments
225 srecode-template-separator-block
226 srecode-template-wy--<keyword>-keyword-analyzer
227 srecode-template-property-analyzer
228 srecode-template-wy--<symbol>-regexp-analyzer
229 srecode-template-wy--<number>-regexp-analyzer
230 srecode-template-wy--<string>-sexp-analyzer
231 srecode-template-wy--<punctuation>-string-analyzer
232 semantic-lex-default-action
233 )
234
235;;; wisent-dot.wy ends here
diff --git a/admin/grammars/wisent-grammar.el b/admin/grammars/wisent-grammar.el
index d7de1ee6f7b..98b0caee60b 100644
--- a/admin/grammars/wisent-grammar.el
+++ b/admin/grammars/wisent-grammar.el
@@ -358,4 +358,180 @@ Menu items are appended to the common grammar menu.")
358 ) 358 )
359 "Semantic grammar macros used in wisent grammars.") 359 "Semantic grammar macros used in wisent grammars.")
360 360
361(defvar wisent-make-parsers--emacs-license
362 ";; This file is part of GNU Emacs.
363
364;; GNU Emacs is free software: you can redistribute it and/or modify
365;; it under the terms of the GNU General Public License as published by
366;; the Free Software Foundation, either version 3 of the License, or
367;; (at your option) any later version.
368
369;; GNU Emacs is distributed in the hope that it will be useful,
370;; but WITHOUT ANY WARRANTY; without even the implied warranty of
371;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
372;; GNU General Public License for more details.
373
374;; You should have received a copy of the GNU General Public License
375;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.")
376
377(defvar wisent-make-parsers--python-license
378 ";; It is derived in part from the Python grammar, used under the
379;; following license:
380;;
381;; PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
382;; --------------------------------------------
383;; 1. This LICENSE AGREEMENT is between the Python Software Foundation
384;; (\"PSF\"), and the Individual or Organization (\"Licensee\") accessing
385;; and otherwise using this software (\"Python\") in source or binary
386;; form and its associated documentation.
387;;
388;; 2. Subject to the terms and conditions of this License Agreement,
389;; PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide
390;; license to reproduce, analyze, test, perform and/or display
391;; publicly, prepare derivative works, distribute, and otherwise use
392;; Python alone or in any derivative version, provided, however, that
393;; PSF's License Agreement and PSF's notice of copyright, i.e.,
394;; \"Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
395;; 2009, 2010 Python Software Foundation; All Rights Reserved\" are
396;; retained in Python alone or in any derivative version prepared by
397;; Licensee.
398;;
399;; 3. In the event Licensee prepares a derivative work that is based
400;; on or incorporates Python or any part thereof, and wants to make
401;; the derivative work available to others as provided herein, then
402;; Licensee hereby agrees to include in any such work a brief summary
403;; of the changes made to Python.
404;;
405;; 4. PSF is making Python available to Licensee on an \"AS IS\"
406;; basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
407;; IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
408;; DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
409;; FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
410;; INFRINGE ANY THIRD PARTY RIGHTS.
411;;
412;; 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
413;; FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
414;; RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR
415;; ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
416;;
417;; 6. This License Agreement will automatically terminate upon a
418;; material breach of its terms and conditions.
419;;
420;; 7. Nothing in this License Agreement shall be deemed to create any
421;; relationship of agency, partnership, or joint venture between PSF
422;; and Licensee. This License Agreement does not grant permission to
423;; use PSF trademarks or trade name in a trademark sense to endorse or
424;; promote products or services of Licensee, or any third party.
425;;
426;; 8. By copying, installing or otherwise using Python, Licensee
427;; agrees to be bound by the terms and conditions of this License
428;; Agreement.")
429
430(defvar wisent-make-parsers--ecmascript-license
431 "\n;; It is derived from the grammar in the ECMAScript Language
432;; Specification published at
433;;
434;; http://www.ecma-international.org/publications/standards/Ecma-262.htm
435;;
436;; and redistributed under the following license:
437;;
438;; Redistribution and use in source and binary forms, with or without
439;; modification, are permitted provided that the following conditions
440;; are met:
441;;
442;; 1. Redistributions of source code must retain the above copyright
443;; notice, this list of conditions and the following disclaimer.
444;;
445;; 2. Redistributions in binary form must reproduce the above
446;; copyright notice, this list of conditions and the following
447;; disclaimer in the documentation and/or other materials provided
448;; with the distribution.
449;;
450;; 3. Neither the name of the authors nor Ecma International may be
451;; used to endorse or promote products derived from this software
452;; without specific prior written permission. THIS SOFTWARE IS
453;; PROVIDED BY THE ECMA INTERNATIONAL \"AS IS\" AND ANY EXPRESS OR
454;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
455;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
456;; ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR
457;; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
458;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
459;; OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
460;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
461;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
462;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
463;; USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
464;; DAMAGE.")
465
466(defvar wisent-make-parsers--parser-file-name
467 `(("semantic-grammar-wy.el"
468 "semantic/grammar-wy")
469 ("srecode-template-wy.el"
470 "srecode/srt-wy")
471 ("wisent-javascript-jv-wy.el"
472 "semantic/wisent/js-wy"
473 "Copyright (C) 1998-2011 Ecma International"
474 ,wisent-make-parsers--ecmascript-license)
475 ("wisent-java-tags-wy.el"
476 "semantic/wisent/javat-wy")
477 ("wisent-python-wy.el"
478 "semantic/wisent/python-wy"
479 "Copyright (C) 2001-2010 Python Software Foundation"
480 ,wisent-make-parsers--python-license)))
481
482(defun wisent-make-parsers ()
483 "Generate Emacs' built-in Wisent-based parser files."
484 (semantic-mode 1)
485 ;; Loop through each .wy file in current directory, and run
486 ;; `semantic-grammar-batch-build-one-package' to build the grammar.
487 (dolist (f (directory-files default-directory nil ".wy$"))
488 (let ((packagename
489 (condition-case err
490 (with-current-buffer (find-file-noselect f)
491 (semantic-grammar-create-package))
492 (error (message "%s" (error-message-string err)) nil)))
493 output-data)
494 (when (setq output-data (assoc packagename wisent-make-parsers--parser-file-name))
495 (let ((require-name (nth 1 output-data))
496 (additional-copyright (nth 2 output-data))
497 (additional-license (nth 3 output-data))
498 copyright-end)
499 ;; Touch up the generated parsers for Emacs integration.
500 (with-temp-buffer
501 (insert-file-contents packagename)
502 ;; Fix copyright header:
503 (goto-char (point-min))
504 (when additional-copyright
505 (re-search-forward "Copyright (C).*$")
506 (insert "\n;; " additional-copyright))
507 (re-search-forward "^;; Author:")
508 (setq copyright-end (match-beginning 0))
509 (re-search-forward "^;;; Code:\n")
510 (delete-region copyright-end (match-end 0))
511 (goto-char copyright-end)
512 (insert wisent-make-parsers--emacs-license)
513 (insert "\n\n;;; Commentary:
514;;
515;; This file was generated from admin/grammars/"
516 f ".")
517 (when additional-license
518 (insert "\n" additional-license))
519 (insert "\n\n;;; Code:\n
520\(require 'semantic/lex)\n")
521 (goto-char (point-min))
522 (delete-region (point-min) (line-end-position))
523 (insert ";;; " require-name
524 ".el --- Generated parser support file")
525 (delete-trailing-whitespace)
526 (re-search-forward ";;\n(require 'semantic/lex)\n")
527 (delete-region (match-beginning 0) (match-end 0))
528 ;; Fix footer:
529 (goto-char (point-max))
530 (re-search-backward "^(provide")
531 (delete-region (match-beginning 0) (point-max))
532 (goto-char (point-max))
533 (insert "(provide '" require-name ")\n\n")
534 (insert ";;; " require-name ".el ends here\n")
535 (write-region nil nil (expand-file-name packagename))))))))
536
361;;; wisent-grammar.el ends here 537;;; wisent-grammar.el ends here