Add Semantic grammar files to etc/grammars
[bpt/emacs.git] / etc / grammars / scheme.by
CommitLineData
469d2149
CY
1;;; semantic/bovine/scheme.by -- Scheme BNF language specification
2;;
3;; Copyright (C) 2001, 2003, 2009 Eric M. Ludlam
4;;
5;; Author: Eric M. Ludlam <zappo@gnu.org>
6;;
7;; This 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 2, or (at your option)
10;; any later version.
11;;
12;; This software 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; see the file COPYING. If not, write to the
19;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20;; Boston, MA 02110-1301, USA.
21
22%package scm-by
23
24%languagemode scheme-mode
25%start scheme
26
27%token DEFINE "define"
28%token DEFINE-MODULE "define-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
40scheme : semantic-list
41 (EXPAND $1 scheme-list)
42 ;
43
44scheme-list : OPENPAREN scheme-in-list CLOSEPAREN
45 ( ,$2 )
46 ;
47
48scheme-in-list: DEFINE symbol expression
49 (VARIABLE-TAG $2 nil $3 )
50 | DEFINE name-args opt-doc sequence
51 (FUNCTION-TAG (car ,$2) nil (cdr ,$2) )
52 | DEFINE-MODULE name-args
53 (PACKAGE-TAG (nth (length $2) $2 ) nil)
54 | LOAD string
55 (INCLUDE-TAG (file-name-nondirectory (read $2)) (read $2) )
56 | symbol
57 (CODE-TAG $1 nil)
58 ;
59
60name-args: semantic-list
61 (EXPAND $1 name-arg-expand)
62 ;
63
64name-arg-expand : open-paren name-arg-expand
65 ( ,$2 )
66 | symbol name-arg-expand
67 ( ,(cons $1 ,$2) )
68 | ;; EMPTY
69 ( )
70 ;
71
72opt-doc : string
73 | ;; EMPTY
74 ;
75
76sequence : expression sequence
77 | expression
78 ;
79
80expression : symbol
81 | semantic-list
82 | string
83 | number
84 ;
85
86;;; semantic/bovine/scheme.by ends here