Commit | Line | Data |
---|---|---|
62f43d66 CY |
1 | ;;; make.by -- BY notation for Makefiles. |
2 | ||
3 | ;; Copyright (C) 1999-2011 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 |
469d2149 CY |
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 : bol newline (nil) | |
57 | | bol variable | |
58 | ( ,@$2 ) | |
59 | | bol rule | |
60 | ( ,@$2 ) | |
61 | | bol conditional | |
62 | ( ,@$2 ) | |
63 | | bol include | |
64 | ( ,@$2 ) | |
65 | | whitespace ( nil ) | |
66 | | newline ( nil ) | |
67 | ; | |
68 | ||
69 | variable: symbol opt-whitespace equals opt-whitespace element-list | |
70 | (VARIABLE-TAG ,$1 nil ,$5) | |
71 | ; | |
72 | ||
73 | rule: targets opt-whitespace colons opt-whitespace element-list commands | |
74 | (FUNCTION-TAG ,$1 nil ,$5) | |
75 | ; | |
76 | ||
77 | targets: target opt-whitespace targets | |
78 | ( (car ,$1) (car ,@$3) ) | |
79 | | target | |
80 | ( (car ,$1) ) | |
81 | ; | |
82 | ||
83 | target: sub-target target | |
84 | ( (concat (car ,$1) (car ,@$3) ) ) | |
85 | | sub-target | |
86 | ( (car ,$1) ) | |
87 | ; | |
88 | ||
89 | sub-target: symbol | |
90 | | string | |
91 | | varref | |
92 | ; | |
93 | ||
94 | conditional: IF some-whitespace symbol newline | |
95 | ( nil ) | |
96 | | IFDEF some-whitespace symbol newline | |
97 | ( nil ) | |
98 | | IFNDEF some-whitespace symbol newline | |
99 | ( nil ) | |
100 | | IFEQ some-whitespace expression newline | |
101 | ( nil ) | |
102 | | IFNEQ some-whitespace expression newline | |
103 | ( nil ) | |
104 | | ELSE newline | |
105 | ( nil ) | |
106 | | ENDIF newline | |
107 | ( nil ) | |
108 | ; | |
109 | ||
110 | expression : semantic-list | |
111 | ; | |
112 | ||
113 | include: INCLUDE some-whitespace element-list | |
114 | (INCLUDE-TAG ,$3 nil) | |
115 | ; | |
116 | ||
117 | equals: COLON EQUAL () | |
118 | | PLUS EQUAL () | |
119 | | EQUAL () | |
120 | ; | |
121 | ||
122 | colons: COLON COLON () | |
123 | | COLON () | |
124 | ; | |
125 | ||
126 | element-list: elements newline | |
127 | ( ,@$1 ) | |
128 | ; | |
129 | ||
130 | elements: element some-whitespace elements | |
131 | ( ,@$1 ,@$3 ) | |
132 | | element | |
133 | ( ,@$1 ) | |
134 | | ;;EMPTY | |
135 | ; | |
136 | ||
137 | element: sub-element element | |
138 | ( (concat (car ,$1) (car ,$2)) ) | |
139 | | ;;EMPTY | |
140 | ; | |
141 | ||
142 | sub-element: symbol | |
143 | | string | |
144 | | punctuation | |
145 | | semantic-list | |
146 | ( (buffer-substring-no-properties | |
147 | (identity start) (identity end)) ) | |
148 | ; | |
149 | ||
150 | varref: DOLLAR semantic-list | |
151 | ( (buffer-substring-no-properties (identity start) (identity end)) ) | |
152 | ; | |
153 | ||
154 | commands: bol shell-command newline commands | |
155 | ( ,$1 ,@$2 ) | |
156 | | ;;EMPTY | |
157 | ( ) | |
158 | ; | |
159 | ||
160 | opt-whitespace : some-whitespace ( nil ) | |
161 | | ;;EMPTY | |
162 | ; | |
163 | ||
164 | some-whitespace : whitespace some-whitespace (nil) | |
165 | | whitespace (nil) | |
166 | ; | |
167 | ||
62f43d66 | 168 | ;;; make.by ends here |