]> code.delx.au - gnu-emacs/blob - admin/grammars/scheme.by
1b67d624320a212562c7ddd923f5e319a604f553
[gnu-emacs] / admin / grammars / scheme.by
1 ;;; scheme.by -- Scheme BNF language specification
2
3 ;; Copyright (C) 2001-2015 Free Software Foundation, Inc.
4
5 ;; This file is part of GNU Emacs.
6
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.
11
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.
16
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/>.
19
20 %package semantic-scm-by
21 %provide semantic/bovine/scm-by
22
23 %languagemode scheme-mode
24 %start scheme
25
26 %token DEFINE "define"
27 %token DEFINE-MODULE "define-module"
28 %token MODULE "module"
29 %token LOAD "load"
30
31 %put DEFINE summary "Function: (define symbol expression)"
32 %put DEFINE-MODULE summary "Function: (define-module (name arg1 ...)) "
33 %put LOAD summary "Function: (load \"filename\")"
34
35 %token <open-paren> OPENPAREN "("
36 %token <close-paren> CLOSEPAREN ")"
37
38 %%
39
40 scheme : semantic-list
41 ( ,(let ((expand (EXPAND $1 scheme-list)))
42 (cond
43 ((semantic-tag-of-class-p expand 'module)
44 (TYPE-TAG (semantic-tag-name expand)
45 "module"
46 (EXPANDFULL $1 scheme)
47 nil) ;; Module contains more definitions like a type
48 )
49 (t
50 expand))))
51 ;
52
53 scheme-list : OPENPAREN scheme-in-list
54 ( ,$2 )
55 ;
56
57
58 scheme-in-list: DEFINE symbol expression
59 (VARIABLE-TAG $2 nil $3 )
60 | DEFINE name-args opt-doc
61 (FUNCTION-TAG (car ,$2) nil (cdr ,$2) )
62 | DEFINE-MODULE name-args
63 (PACKAGE-TAG (nth (length $2) $2 ) nil)
64 | MODULE symbol
65 (TAG $1 'module :members nil)
66 | LOAD string
67 (INCLUDE-TAG (file-name-nondirectory (read $2)) (read $2) )
68 | symbol sequence
69 (CODE-TAG $1 nil)
70 ;
71
72 name-args: semantic-list
73 (EXPAND $1 name-arg-list)
74 ;
75
76 name-arg-list : OPENPAREN name-arg-expand
77 ( ,$2 )
78 ;
79
80 name-arg-expand: symbol name-arg-expand
81 ( ,(cons $1 ,$2) )
82 | ;; EMPTY
83 ( )
84 ;
85
86 opt-doc : string
87 | ;; EMPTY
88 ;
89
90 sequence : expression sequence
91 | expression
92 ;
93
94 expression : symbol
95 | semantic-list
96 | string
97 | number
98 ;
99
100 ;;; scheme.by ends here
101