1 ;;; semantic/grammar-wy.el --- Generated parser support file
3 ;; Copyright (C) 2002, 2003, 2004, 2009, 2010 Free Software Foundation, Inc.
5 ;; Author: David Ponce <david@dponce.com>
8 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 ;; This file is generated from the grammar file semantic-grammar.wy in
26 ;; the upstream CEDET repository.
30 (require 'semantic
/lex
)
31 (defvar semantic-grammar-lex-c-char-re
)
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
)
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
)
47 ("%nonassoc" . NONASSOC
)
48 ("%package" . PACKAGE
)
51 ("%quotemode" . QUOTEMODE
)
53 ("%scopestart" . SCOPESTART
)
57 ("%use-macros" . USE-MACROS
))
59 "Table of language keywords.")
61 (defconst semantic-grammar-wy--token-table
62 (semantic-lex-make-type-table
76 (BRACE_BLOCK .
"(LBRACE RBRACE)")
77 (PAREN_BLOCK .
"(LPAREN RPAREN)"))
79 (EPILOGUE .
"%%...EOF")
80 (PROLOGUE .
"%{...%}"))
88 (PERCENT_PERCENT .
"\\`%%\\'")
92 '(("punctuation" :declared t
)
94 ("sexp" matchdatatype sexp
)
97 ("qlist" matchdatatype sexp
)
98 ("qlist" syntax
"\\s'\\s-*(")
100 ("char" syntax semantic-grammar-lex-c-char-re
)
102 ("symbol" syntax
":?\\(\\sw\\|\\s_\\)+")
103 ("symbol" :declared t
)
104 ("string" :declared t
)
105 ("keyword" :declared t
)))
106 "Table of lexical tokens.")
108 (defconst semantic-grammar-wy--parse-table
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
)
124 (semantic-tag-new-code "prologue" nil
))))
128 (semantic-tag-new-code "epilogue" nil
))))
133 ((default_prec_decl))
134 ((no_default_prec_decl))
135 ((languagemode_decl))
149 (semantic-tag "default-prec" 'assoc
:value
151 (no_default_prec_decl
154 (semantic-tag "default-prec" 'assoc
:value
157 ((LANGUAGEMODE symbols
)
159 (semantic-tag ',(car $
2)
160 'languagemode
:rest
',(cdr $
2)))))
164 (semantic-tag-new-package ',$
2 nil
))))
166 ((associativity token_type_opt items
)
168 (semantic-tag ',$
1 'assoc
:type
',$
2 :value
',$
3))))
177 ((PUT put_name put_value
)
179 (semantic-tag ',$
2 'put
:value
',(list $
3))))
180 ((PUT put_name put_value_list
)
182 (semantic-tag ',$
2 'put
:value
',$
3)))
183 ((PUT put_name_list put_value
)
185 (semantic-tag ',(car $
2)
186 'put
:rest
',(cdr $
2)
187 :value
',(list $
3))))
188 ((PUT put_name_list put_value_list
)
190 (semantic-tag ',(car $
2)
191 'put
:rest
',(cdr $
2)
195 (mapcar 'semantic-tag-name
196 (semantic-parse-region
207 (semantic-tag $
1 'put-name
))))
213 (mapcar 'semantic-tag-code-detail
214 (semantic-parse-region
225 (semantic-tag-new-code "put-value" $
1))))
232 (semantic-tag ',$
2 'scopestart
))))
236 (semantic-tag ',$
2 'quotemode
))))
240 (semantic-tag ',(car $
2)
241 'start
:rest
',(cdr $
2)))))
243 ((KEYWORD SYMBOL string_value
)
245 (semantic-tag ',$
2 'keyword
:value
',$
3))))
247 ((TOKEN token_type_opt SYMBOL string_value
)
249 (semantic-tag ',$
3 ',(if $
2 'token
'keyword
)
250 :type
',$
2 :value
',$
4)))
251 ((TOKEN token_type_opt symbols
)
253 (semantic-tag ',(car $
3)
254 'token
:type
',$
2 :rest
',(cdr $
3)))))
262 ((TYPE token_type plist_opt
)
264 (semantic-tag ',$
2 'type
:value
',$
3))))
277 (mapcar 'semantic-tag-name
278 (semantic-parse-region
289 (semantic-tag $
1 'use-name
))))
291 ((USE-MACROS SYMBOL use_name_list
)
293 (semantic-tag "macro" 'macro
:type
',$
2 :value
',$
3))))
307 ((lifo_symbols SYMBOL
)
313 (setq semantic-grammar-wy--nterm $
1 semantic-grammar-wy--rindx
0)
316 (semantic-tag $
1 'nonterminal
:children $
4))))
322 ((lifo_rules OR rule
)
329 ((nterm semantic-grammar-wy--nterm
)
330 (rindx semantic-grammar-wy--rindx
)
332 comps prec action elt
)
333 (setq semantic-grammar-wy--rindx
334 (1+ semantic-grammar-wy--rindx
))
343 (error "Duplicate %%prec in `%s:%d' rule" nterm rindx
))
351 semantic-grammar-wy--rindx
352 (1+ semantic-grammar-wy--rindx
))
361 (format "%s:%d" nterm rindx
)
363 (if comps
"group" "empty")
364 :value comps
:prec prec
:expr action
))))))
381 (format "(progn\n%s)"
385 (string-match "^{[
\n ]*" s
)
390 (string-match "[
\n ]*}$" s
)
393 (match-beginning 0))))
406 '(grammar prologue epilogue declaration nonterminal rule put_names put_values use_names
)))
409 (defun semantic-grammar-wy--install-parser ()
410 "Setup the Semantic Parser."
411 (semantic-install-function-overrides
412 '((parse-stream . wisent-parse-stream
)))
413 (setq semantic-parser-name
"LALR"
414 semantic--parse-table semantic-grammar-wy--parse-table
415 semantic-debug-parser-source
"semantic-grammar.wy"
416 semantic-flex-keywords-obarray semantic-grammar-wy--keyword-table
417 semantic-lex-types-obarray semantic-grammar-wy--token-table
)
418 ;; Collect unmatched syntax lexical tokens
419 (semantic-make-local-hook 'wisent-discarding-token-functions
)
420 (add-hook 'wisent-discarding-token-functions
421 'wisent-collect-unmatched-syntax nil t
))
426 (define-lex-sexp-type-analyzer semantic-grammar-wy--
<sexp
>-sexp-analyzer
427 "sexp analyzer for <sexp> tokens."
431 (define-lex-sexp-type-analyzer semantic-grammar-wy--
<qlist
>-sexp-analyzer
432 "sexp analyzer for <qlist> tokens."
436 (define-lex-keyword-type-analyzer semantic-grammar-wy--
<keyword
>-keyword-analyzer
437 "keyword analyzer for <keyword> tokens."
438 "\\(\\sw\\|\\s_\\)+")
440 (define-lex-block-type-analyzer semantic-grammar-wy--
<block
>-block-analyzer
441 "block analyzer for <block> tokens."
443 '((("(" LPAREN PAREN_BLOCK
)
444 ("{" LBRACE BRACE_BLOCK
))
449 (define-lex-regex-type-analyzer semantic-grammar-wy--
<char
>-regexp-analyzer
450 "regexp analyzer for <char> tokens."
451 semantic-grammar-lex-c-char-re
455 (define-lex-sexp-type-analyzer semantic-grammar-wy--
<string
>-sexp-analyzer
456 "sexp analyzer for <string> tokens."
460 (define-lex-regex-type-analyzer semantic-grammar-wy--
<symbol
>-regexp-analyzer
461 "regexp analyzer for <symbol> tokens."
462 ":?\\(\\sw\\|\\s_\\)+"
463 '((PERCENT_PERCENT .
"\\`%%\\'"))
466 (define-lex-string-type-analyzer semantic-grammar-wy--
<punctuation
>-string-analyzer
467 "string analyzer for <punctuation> tokens."
468 "\\(\\s.\\|\\s$\\|\\s'\\)+"
476 (provide 'semantic
/grammar-wy
)
478 ;; arch-tag: dd050eb7-84a8-421c-b734-478dd2bd55bc
479 ;;; semantic/grammar-wy.el ends here