Initial Commit
[packages] / xemacs-packages / semantic / bovine / bovine-grammar-macros.el
1 ;;; bovine-grammar-macros.el --- Semantic macros for LL grammars
2 ;;
3 ;; Copyright (C) 2003, 2005 David Ponce
4 ;;
5 ;; Author: David Ponce <david@dponce.com>
6 ;; Maintainer: David Ponce <david@dponce.com>
7 ;; Created: 02 Aug 2003
8 ;; Keywords: syntax
9 ;; X-RCS: $Id: bovine-grammar-macros.el,v 1.1 2007-11-26 15:11:50 michaels Exp $
10 ;;
11 ;; This file is not part of GNU Emacs.
12 ;;
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
17 ;;
18 ;; This software is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22 ;;
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
27
28 ;;; Commentary:
29 ;;
30 ;; This library defines the default set of Semantic grammar macros
31 ;; used in bovine (.by) grammars.
32
33 ;;; History:
34 ;;
35
36 ;;; Code:
37
38 (defun bovine-grammar-EXPAND (bounds nonterm)
39   "Expand call to EXPAND grammar macro.
40 Return the form to parse from within a nonterminal between BOUNDS.
41 NONTERM is the nonterminal symbol to start with."
42   `(semantic-bovinate-from-nonterminal
43     (car ,bounds) (cdr ,bounds) ',nonterm))
44
45 (defun bovine-grammar-EXPANDFULL (bounds nonterm)
46   "Expand call to EXPANDFULL grammar macro.
47 Return the form to recursively parse the area between BOUNDS.
48 NONTERM is the nonterminal symbol to start with."
49   `(semantic-parse-region
50     (car ,bounds) (cdr ,bounds) ',nonterm 1))
51
52 (defun bovine-grammar-TAG (name class &rest attributes)
53   "Expand call to TAG grammar macro.
54 Return the form to create a generic semantic tag.
55 See the function `semantic-tag' for the meaning of arguments NAME,
56 CLASS and ATTRIBUTES."
57   `(semantic-tag ,name ,class ,@attributes))
58
59 (defun bovine-grammar-VARIABLE-TAG (name type default-value &rest attributes)
60   "Expand call to VARIABLE-TAG grammar macro.
61 Return the form to create a semantic tag of class variable.
62 See the function `semantic-tag-new-variable' for the meaning of
63 arguments NAME, TYPE, DEFAULT-VALUE and ATTRIBUTES."
64   `(semantic-tag-new-variable ,name ,type ,default-value ,@attributes))
65
66 (defun bovine-grammar-FUNCTION-TAG (name type arg-list &rest attributes)
67   "Expand call to FUNCTION-TAG grammar macro.
68 Return the form to create a semantic tag of class function.
69 See the function `semantic-tag-new-function' for the meaning of
70 arguments NAME, TYPE, ARG-LIST and ATTRIBUTES."
71   `(semantic-tag-new-function ,name ,type ,arg-list ,@attributes))
72
73 (defun bovine-grammar-TYPE-TAG (name type members parents &rest attributes)
74   "Expand call to TYPE-TAG grammar macro.
75 Return the form to create a semantic tag of class type.
76 See the function `semantic-tag-new-type' for the meaning of arguments
77 NAME, TYPE, MEMBERS, PARENTS and ATTRIBUTES."
78   `(semantic-tag-new-type ,name ,type ,members ,parents ,@attributes))
79
80 (defun bovine-grammar-INCLUDE-TAG (name system-flag &rest attributes)
81   "Expand call to INCLUDE-TAG grammar macro.
82 Return the form to create a semantic tag of class include.
83 See the function `semantic-tag-new-include' for the meaning of
84 arguments NAME, SYSTEM-FLAG and ATTRIBUTES."
85   `(semantic-tag-new-include ,name ,system-flag ,@attributes))
86
87 (defun bovine-grammar-PACKAGE-TAG (name detail &rest attributes)
88   "Expand call to PACKAGE-TAG grammar macro.
89 Return the form to create a semantic tag of class package.
90 See the function `semantic-tag-new-package' for the meaning of
91 arguments NAME, DETAIL and ATTRIBUTES."
92   `(semantic-tag-new-package ,name ,detail ,@attributes))
93
94 (defun bovine-grammar-CODE-TAG (name detail &rest attributes)
95   "Expand call to CODE-TAG grammar macro.
96 Return the form to create a semantic tag of class code.
97 See the function `semantic-tag-new-code' for the meaning of arguments
98 NAME, DETAIL and ATTRIBUTES."
99   `(semantic-tag-new-code ,name ,detail ,@attributes))
100
101 (defun bovine-grammar-ALIAS-TAG (name aliasclass definition &rest attributes)
102   "Expand call to ALIAS-TAG grammar macro.
103 Return the form to create a semantic tag of class alias.
104 See the function `semantic-tag-new-alias' for the meaning of arguments
105 NAME, ALIASCLASS, DEFINITION and ATTRIBUTES."
106   `(semantic-tag-new-alias ,name ,aliasclass ,definition ,@attributes))
107
108 (defvar-mode-local bovine-grammar-mode semantic-grammar-macros
109   '(
110     (ASSOC          . semantic-grammar-ASSOC)
111     (EXPAND         . bovine-grammar-EXPAND)
112     (EXPANDFULL     . bovine-grammar-EXPANDFULL)
113     (TAG            . bovine-grammar-TAG)
114     (VARIABLE-TAG   . bovine-grammar-VARIABLE-TAG)
115     (FUNCTION-TAG   . bovine-grammar-FUNCTION-TAG)
116     (TYPE-TAG       . bovine-grammar-TYPE-TAG)
117     (INCLUDE-TAG    . bovine-grammar-INCLUDE-TAG)
118     (PACKAGE-TAG    . bovine-grammar-PACKAGE-TAG)
119     (CODE-TAG       . bovine-grammar-CODE-TAG)
120     (ALIAS-TAG      . bovine-grammar-ALIAS-TAG)
121     )
122   "Semantic grammar macros used in bovine grammars.")
123
124 (provide 'bovine-grammar-macros)
125
126 ;;; bovine-grammar-macros.el ends here