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