Commit | Line | Data |
---|---|---|
469d2149 CY |
1 | ;;; semantic/bovine/make.by -- BY notation for Makefiles. |
2 | ;; | |
3 | ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2008 Eric M. Ludlam | |
4 | ;; | |
5 | ;; Author: Eric M. Ludlam <zappo@gnu.org> | |
6 | ;; | |
7 | ;; This program 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 | ||
23 | %package make-by | |
24 | ||
25 | %languagemode makefile-mode | |
26 | %start Makefile | |
27 | ||
28 | ;; This was always a test case. | |
29 | %quotemode backquote | |
30 | ||
31 | %token IF "if" | |
32 | %token IFDEF "ifdef" | |
33 | %token IFNDEF "ifndef" | |
34 | %token IFEQ "ifeq" | |
35 | %token IFNEQ "ifneq" | |
36 | %token ELSE "else" | |
37 | %token ENDIF "endif" | |
38 | %token INCLUDE "include" | |
39 | ||
40 | %put { IF ELSE ENDIF } summary "Conditional: if (expression) ... else ... endif" | |
41 | %put IFDEF summary "Conditional: ifdef (expression) ... else ... endif" | |
42 | %put IFNDEF summary "Conditional: ifndef (expression) ... else ... endif" | |
43 | %put IFEQ summary "Conditional: ifeq (expression) ... else ... endif" | |
44 | %put IFNEQ summary "Conditional: ifneq (expression) ... else ... endif" | |
45 | %put INCLUDE summary "Macro: include filename1 filename2 ..." | |
46 | ||
47 | %token <punctuation> COLON "\\`[:]\\'" | |
48 | %token <punctuation> PLUS "\\`[+]\\'" | |
49 | %token <punctuation> EQUAL "\\`[=]\\'" | |
50 | %token <punctuation> DOLLAR "\\`[$]\\'" | |
51 | %token <punctuation> BACKSLASH "\\`[\\]\\'" | |
52 | ||
53 | %% | |
54 | ||
55 | Makefile : bol newline (nil) | |
56 | | bol variable | |
57 | ( ,@$2 ) | |
58 | | bol rule | |
59 | ( ,@$2 ) | |
60 | | bol conditional | |
61 | ( ,@$2 ) | |
62 | | bol include | |
63 | ( ,@$2 ) | |
64 | | whitespace ( nil ) | |
65 | | newline ( nil ) | |
66 | ; | |
67 | ||
68 | variable: symbol opt-whitespace equals opt-whitespace element-list | |
69 | (VARIABLE-TAG ,$1 nil ,$5) | |
70 | ; | |
71 | ||
72 | rule: targets opt-whitespace colons opt-whitespace element-list commands | |
73 | (FUNCTION-TAG ,$1 nil ,$5) | |
74 | ; | |
75 | ||
76 | targets: target opt-whitespace targets | |
77 | ( (car ,$1) (car ,@$3) ) | |
78 | | target | |
79 | ( (car ,$1) ) | |
80 | ; | |
81 | ||
82 | target: sub-target target | |
83 | ( (concat (car ,$1) (car ,@$3) ) ) | |
84 | | sub-target | |
85 | ( (car ,$1) ) | |
86 | ; | |
87 | ||
88 | sub-target: symbol | |
89 | | string | |
90 | | varref | |
91 | ; | |
92 | ||
93 | conditional: IF some-whitespace symbol newline | |
94 | ( nil ) | |
95 | | IFDEF some-whitespace symbol newline | |
96 | ( nil ) | |
97 | | IFNDEF some-whitespace symbol newline | |
98 | ( nil ) | |
99 | | IFEQ some-whitespace expression newline | |
100 | ( nil ) | |
101 | | IFNEQ some-whitespace expression newline | |
102 | ( nil ) | |
103 | | ELSE newline | |
104 | ( nil ) | |
105 | | ENDIF newline | |
106 | ( nil ) | |
107 | ; | |
108 | ||
109 | expression : semantic-list | |
110 | ; | |
111 | ||
112 | include: INCLUDE some-whitespace element-list | |
113 | (INCLUDE-TAG ,$3 nil) | |
114 | ; | |
115 | ||
116 | equals: COLON EQUAL () | |
117 | | PLUS EQUAL () | |
118 | | EQUAL () | |
119 | ; | |
120 | ||
121 | colons: COLON COLON () | |
122 | | COLON () | |
123 | ; | |
124 | ||
125 | element-list: elements newline | |
126 | ( ,@$1 ) | |
127 | ; | |
128 | ||
129 | elements: element some-whitespace elements | |
130 | ( ,@$1 ,@$3 ) | |
131 | | element | |
132 | ( ,@$1 ) | |
133 | | ;;EMPTY | |
134 | ; | |
135 | ||
136 | element: sub-element element | |
137 | ( (concat (car ,$1) (car ,$2)) ) | |
138 | | ;;EMPTY | |
139 | ; | |
140 | ||
141 | sub-element: symbol | |
142 | | string | |
143 | | punctuation | |
144 | | semantic-list | |
145 | ( (buffer-substring-no-properties | |
146 | (identity start) (identity end)) ) | |
147 | ; | |
148 | ||
149 | varref: DOLLAR semantic-list | |
150 | ( (buffer-substring-no-properties (identity start) (identity end)) ) | |
151 | ; | |
152 | ||
153 | commands: bol shell-command newline commands | |
154 | ( ,$1 ,@$2 ) | |
155 | | ;;EMPTY | |
156 | ( ) | |
157 | ; | |
158 | ||
159 | opt-whitespace : some-whitespace ( nil ) | |
160 | | ;;EMPTY | |
161 | ; | |
162 | ||
163 | some-whitespace : whitespace some-whitespace (nil) | |
164 | | whitespace (nil) | |
165 | ; | |
166 | ||
167 | ;;; semantic/bovine/make.by ends here |