| 1 | ;;; scheme.by -- Scheme BNF language specification |
| 2 | |
| 3 | ;; Copyright (C) 2001-2012 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 | |
| 22 | %languagemode scheme-mode |
| 23 | %start scheme |
| 24 | |
| 25 | %token DEFINE "define" |
| 26 | %token DEFINE-MODULE "define-module" |
| 27 | %token LOAD "load" |
| 28 | |
| 29 | %put DEFINE summary "Function: (define symbol expression)" |
| 30 | %put DEFINE-MODULE summary "Function: (define-module (name arg1 ...)) " |
| 31 | %put LOAD summary "Function: (load \"filename\")" |
| 32 | |
| 33 | %token <open-paren> OPENPAREN "(" |
| 34 | %token <close-paren> CLOSEPAREN ")" |
| 35 | |
| 36 | %% |
| 37 | |
| 38 | scheme : semantic-list |
| 39 | (EXPAND $1 scheme-list) |
| 40 | ; |
| 41 | |
| 42 | scheme-list : OPENPAREN scheme-in-list CLOSEPAREN |
| 43 | ( ,$2 ) |
| 44 | ; |
| 45 | |
| 46 | scheme-in-list: DEFINE symbol expression |
| 47 | (VARIABLE-TAG $2 nil $3 ) |
| 48 | | DEFINE name-args opt-doc sequence |
| 49 | (FUNCTION-TAG (car ,$2) nil (cdr ,$2) ) |
| 50 | | DEFINE-MODULE name-args |
| 51 | (PACKAGE-TAG (nth (length $2) $2 ) nil) |
| 52 | | LOAD string |
| 53 | (INCLUDE-TAG (file-name-nondirectory (read $2)) (read $2) ) |
| 54 | | symbol |
| 55 | (CODE-TAG $1 nil) |
| 56 | ; |
| 57 | |
| 58 | name-args: semantic-list |
| 59 | (EXPAND $1 name-arg-expand) |
| 60 | ; |
| 61 | |
| 62 | name-arg-expand : open-paren name-arg-expand |
| 63 | ( ,$2 ) |
| 64 | | symbol name-arg-expand |
| 65 | ( ,(cons $1 ,$2) ) |
| 66 | | ;; EMPTY |
| 67 | ( ) |
| 68 | ; |
| 69 | |
| 70 | opt-doc : string |
| 71 | | ;; EMPTY |
| 72 | ; |
| 73 | |
| 74 | sequence : expression sequence |
| 75 | | expression |
| 76 | ; |
| 77 | |
| 78 | expression : symbol |
| 79 | | semantic-list |
| 80 | | string |
| 81 | | number |
| 82 | ; |
| 83 | |
| 84 | ;;; scheme.by ends here |