Initial Commit
[packages] / xemacs-packages / semantic / bovine / make.by
1 ;;; make.by -- BY notation for Makefiles.
2 ;;
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Eric M. Ludlam
4 ;;
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; X-RCS: $Id: make.by,v 1.1 2007-11-26 15:11:52 michaels Exp $
7 ;;
8 ;; make.bnf is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
11 ;; any later version.
12 ;;
13 ;; This software is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17 ;;
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
22 ;;
23
24 %package semantic-make-by
25
26 %languagemode  makefile-mode
27 %start         Makefile
28
29 ;; This was always a test case.
30 %quotemode     backquote
31
32 %token IF      "if"
33 %token IFDEF   "ifdef"
34 %token IFNDEF  "ifndef"
35 %token IFEQ    "ifeq"
36 %token IFNEQ   "ifneq"
37 %token ELSE    "else"
38 %token ENDIF   "endif"
39 %token INCLUDE "include"
40
41 %put { IF ELSE ENDIF } summary "Conditional: if (expression) ... else ... endif"
42 %put IFDEF   summary "Conditional: ifdef (expression) ... else ... endif"
43 %put IFNDEF  summary "Conditional: ifndef (expression) ... else ... endif"
44 %put IFEQ    summary "Conditional: ifeq (expression) ... else ... endif"
45 %put IFNEQ   summary "Conditional: ifneq (expression) ... else ... endif"
46 %put INCLUDE summary "Macro: include filename1 filename2 ..."
47
48 %token <punctuation> COLON     "\\`[:]\\'"
49 %token <punctuation> PLUS      "\\`[+]\\'"
50 %token <punctuation> EQUAL     "\\`[=]\\'"
51 %token <punctuation> DOLLAR    "\\`[$]\\'"
52 %token <punctuation> BACKSLASH "\\`[\\]\\'"
53
54 %%
55
56 Makefile : variable
57          | rule
58          | conditional
59          | include
60          | whitespace ( nil )
61          | newline ( nil )
62          ;
63
64 variable: symbol opt-whitespace equals opt-whitespace element-list
65           (VARIABLE-TAG ,$1 nil ,$5)
66         ;
67
68 rule: targets opt-whitespace colons opt-whitespace element-list commands
69       (FUNCTION-TAG ,$1 nil ,$5)
70     ;
71
72 targets: target opt-whitespace targets
73          ( (car ,$1) (car ,@$3) )
74        | target
75          ( (car ,$1) )
76        ;
77
78 target: sub-target target
79         ( (concat (car ,$1) (car ,@$3) ) )
80       | sub-target
81         ( (car ,$1) )
82       ;
83
84 sub-target: symbol
85           | string
86           | varref
87           ;
88
89 conditional: IF whitespace symbol newline
90              ( nil )
91            | IFDEF whitespace symbol newline
92              ( nil )
93            | IFNDEF whitespace symbol newline
94              ( nil )
95            | IFEQ whitespace expression newline
96              ( nil )
97            | IFNEQ whitespace expression newline
98              ( nil )
99            | ELSE newline
100              ( nil )
101            | ENDIF newline
102              ( nil )
103            ;
104
105 expression : semantic-list
106            ;
107
108 include: INCLUDE whitespace element-list
109          (INCLUDE-TAG ,$3 nil)
110        ;
111
112 equals: COLON EQUAL ()
113       | PLUS EQUAL ()
114       | EQUAL ()
115       ;
116
117 colons: COLON COLON ()
118       | COLON ()
119       ;
120
121 element-list: elements newline
122               ( ,@$1 )
123             ;
124
125 elements: element whitespace elements
126           ( ,@$1 ,@$3 )
127         | element
128           ( ,@$1 )
129         | ;;EMPTY
130         ;
131   
132 element: sub-element element
133          ( (concat (car ,$1) (car ,$2)) )
134        | ;;EMPTY
135        ;
136
137 sub-element: symbol
138            | string
139            | punctuation
140            | semantic-list
141              ( (buffer-substring-no-properties
142                  (identity start) (identity end)) )
143            ;
144
145 varref: DOLLAR semantic-list
146         ( (buffer-substring-no-properties (identity start) (identity end)) )
147       ;
148
149 commands: shell-command newline commands
150           ( ,$1 ,@$2 )
151         | ;;EMPTY
152           ( )
153         ;
154
155 opt-whitespace : whitespace ( nil )
156                | ;;EMPTY
157                ;
158
159 ;;; make.by ends here