1 ;;; semantic/grammar-wy.el --- Generated parser support file
3 ;; Copyright (C) 2002-2004, 2009-2018 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 <https://www.gnu.org/licenses/>.
22 ;; This file was generated from admin/grammars/grammar.wy.
30 (defvar semantic-grammar-lex-c-char-re
)
32 ;; Current parsed nonterminal name.
33 (defvar semantic-grammar-wy--nterm nil
)
34 ;; Index of rule in a nonterminal clause.
35 (defvar semantic-grammar-wy--rindx nil
)
39 (defconst semantic-grammar-wy--keyword-table
40 (semantic-lex-make-keyword-table
41 '(("%default-prec" . DEFAULT-PREC
)
42 ("%no-default-prec" . NO-DEFAULT-PREC
)
43 ("%keyword" . KEYWORD
)
44 ("%languagemode" . LANGUAGEMODE
)
46 ("%nonassoc" . NONASSOC
)
47 ("%package" . PACKAGE
)
48 ("%provide" . PROVIDE
)
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 PROVIDE 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))
150 (semantic-tag "default-prec" 'assoc
:value
152 (no_default_prec_decl
155 (semantic-tag "default-prec" 'assoc
:value
158 ((LANGUAGEMODE symbols
)
160 (semantic-tag ',(car $
2)
161 'languagemode
:rest
',(cdr $
2)))))
165 (semantic-tag-new-package ',$
2 nil
))))
169 (semantic-tag ',$
2 'provide
))))
171 ((associativity token_type_opt items
)
173 (semantic-tag ',$
1 'assoc
:type
',$
2 :value
',$
3))))
182 ((PUT put_name put_value
)
184 (semantic-tag ',$
2 'put
:value
',(list $
3))))
185 ((PUT put_name put_value_list
)
187 (semantic-tag ',$
2 'put
:value
',$
3)))
188 ((PUT put_name_list put_value
)
190 (semantic-tag ',(car $
2)
191 'put
:rest
',(cdr $
2)
192 :value
',(list $
3))))
193 ((PUT put_name_list put_value_list
)
195 (semantic-tag ',(car $
2)
196 'put
:rest
',(cdr $
2)
200 (mapcar 'semantic-tag-name
201 (semantic-parse-region
212 (semantic-tag $
1 'put-name
))))
218 (mapcar 'semantic-tag-code-detail
219 (semantic-parse-region
230 (semantic-tag-new-code "put-value" $
1))))
237 (semantic-tag ',$
2 'scopestart
))))
241 (semantic-tag ',$
2 'quotemode
))))
245 (semantic-tag ',(car $
2)
246 'start
:rest
',(cdr $
2)))))
248 ((KEYWORD SYMBOL string_value
)
250 (semantic-tag ',$
2 'keyword
:value
',$
3))))
252 ((TOKEN token_type_opt SYMBOL string_value
)
254 (semantic-tag ',$
3 ',(if $
2 'token
'keyword
)
255 :type
',$
2 :value
',$
4)))
256 ((TOKEN token_type_opt symbols
)
258 (semantic-tag ',(car $
3)
259 'token
:type
',$
2 :rest
',(cdr $
3)))))
267 ((TYPE token_type plist_opt
)
269 (semantic-tag ',$
2 'type
:value
',$
3))))
282 (mapcar 'semantic-tag-name
283 (semantic-parse-region
294 (semantic-tag $
1 'use-name
))))
296 ((USE-MACROS SYMBOL use_name_list
)
298 (semantic-tag "macro" 'macro
:type
',$
2 :value
',$
3))))
312 ((lifo_symbols SYMBOL
)
318 (setq semantic-grammar-wy--nterm $
1 semantic-grammar-wy--rindx
0)
321 (semantic-tag $
1 'nonterminal
:children $
4))))
327 ((lifo_rules OR rule
)
334 ((nterm semantic-grammar-wy--nterm
)
335 (rindx semantic-grammar-wy--rindx
)
337 comps prec action elt
)
338 (setq semantic-grammar-wy--rindx
339 (1+ semantic-grammar-wy--rindx
))
348 (error "Duplicate %%prec in `%s:%d' rule" nterm rindx
))
356 semantic-grammar-wy--rindx
357 (1+ semantic-grammar-wy--rindx
))
366 (format "%s:%d" nterm rindx
)
368 (if comps
"group" "empty")
369 :value comps
:prec prec
:expr action
))))))
386 (format "(progn\n%s)"
390 (string-match "^{[\r\n\t ]*" s
)
395 (string-match "[\r\n\t ]*}$" s
)
398 (match-beginning 0))))
411 '(grammar prologue epilogue declaration nonterminal rule put_names put_values use_names
)))
414 (defun semantic-grammar-wy--install-parser ()
415 "Setup the Semantic Parser."
416 (semantic-install-function-overrides
417 '((parse-stream . wisent-parse-stream
)))
418 (setq semantic-parser-name
"LALR"
419 semantic--parse-table semantic-grammar-wy--parse-table
420 semantic-debug-parser-source
"grammar.wy"
421 semantic-flex-keywords-obarray semantic-grammar-wy--keyword-table
422 semantic-lex-types-obarray semantic-grammar-wy--token-table
)
423 ;; Collect unmatched syntax lexical tokens
424 (semantic-make-local-hook 'wisent-discarding-token-functions
)
425 (add-hook 'wisent-discarding-token-functions
426 'wisent-collect-unmatched-syntax nil t
))
431 (define-lex-block-type-analyzer semantic-grammar-wy--
<block
>-block-analyzer
432 "block analyzer for <block> tokens."
434 '((("(" LPAREN PAREN_BLOCK
)
435 ("{" LBRACE BRACE_BLOCK
))
440 (define-lex-regex-type-analyzer semantic-grammar-wy--
<char
>-regexp-analyzer
441 "regexp analyzer for <char> tokens."
442 semantic-grammar-lex-c-char-re
446 (define-lex-regex-type-analyzer semantic-grammar-wy--
<symbol
>-regexp-analyzer
447 "regexp analyzer for <symbol> tokens."
448 ":?\\(\\sw\\|\\s_\\)+"
449 '((PERCENT_PERCENT .
"\\`%%\\'"))
452 (define-lex-sexp-type-analyzer semantic-grammar-wy--
<qlist
>-sexp-analyzer
453 "sexp analyzer for <qlist> tokens."
457 (define-lex-sexp-type-analyzer semantic-grammar-wy--
<string
>-sexp-analyzer
458 "sexp analyzer for <string> tokens."
462 (define-lex-string-type-analyzer semantic-grammar-wy--
<punctuation
>-string-analyzer
463 "string analyzer for <punctuation> tokens."
464 "\\(\\s.\\|\\s$\\|\\s'\\)+"
472 (define-lex-keyword-type-analyzer semantic-grammar-wy--
<keyword
>-keyword-analyzer
473 "keyword analyzer for <keyword> tokens."
474 "\\(\\sw\\|\\s_\\)+")
476 (define-lex-sexp-type-analyzer semantic-grammar-wy--
<sexp
>-sexp-analyzer
477 "sexp analyzer for <sexp> tokens."
488 (provide 'semantic
/grammar-wy
)
490 ;;; semantic/grammar-wy.el ends here