Line 0
Link Here
|
|
|
1 |
--- libaegis/sub/plural_gram.y.orig 2020-06-17 17:52:35.548476000 -0400 |
2 |
+++ libaegis/sub/plural_gram.y 2020-06-17 17:52:46.221850000 -0400 |
3 |
@@ -1,22 +1,24 @@ |
4 |
/* |
5 |
- * aegis - project change supervisor |
6 |
- * Copyright (C) 2002-2008 Peter Miller |
7 |
+ * aegis - project change supervisor |
8 |
+ * Copyright (C) 2002-2008 Peter Miller |
9 |
+ * Copyright (C) 2020 Aryeh M. Friedman |
10 |
* |
11 |
- * This program is free software; you can redistribute it and/or modify |
12 |
- * it under the terms of the GNU General Public License as published by |
13 |
- * the Free Software Foundation; either version 3 of the License, or |
14 |
- * (at your option) any later version. |
15 |
+ * This program is free software; you can redistribute it and/or modify |
16 |
+ * it under the terms of the GNU General Public License as published by |
17 |
+ * the Free Software Foundation; either version 3 of the License, or |
18 |
+ * (at your option) any later version. |
19 |
* |
20 |
- * This program is distributed in the hope that it will be useful, |
21 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 |
- * GNU General Public License for more details. |
24 |
+ * This program is distributed in the hope that it will be useful, |
25 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
26 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
27 |
+ * GNU General Public License for more details. |
28 |
* |
29 |
- * You should have received a copy of the GNU General Public License |
30 |
- * along with this program. If not, see |
31 |
- * <http://www.gnu.org/licenses/>. |
32 |
+ * You should have received a copy of the GNU General Public License |
33 |
+ * along with this program. If not, see |
34 |
+ * <http://www.gnu.org/licenses/>. |
35 |
*/ |
36 |
|
37 |
+%define api.prefix {sub_plural_gram_} |
38 |
%{ |
39 |
|
40 |
#include <common/ac/stdarg.h> |
41 |
@@ -114,9 +116,9 @@ |
42 |
|
43 |
trace(("}\n")); |
44 |
if (bad) |
45 |
- return 0; |
46 |
+ return 0; |
47 |
if (plural >= nplurals) |
48 |
- return 0; |
49 |
+ return 0; |
50 |
return plural; |
51 |
} |
52 |
|
53 |
@@ -132,35 +134,35 @@ |
54 |
/* |
55 |
* jiggery-pokery for yacc |
56 |
* |
57 |
- * Replace all calls to printf with a call to trace_printf. The |
58 |
- * trace_where_ is needed to set the location, and is safe, because |
59 |
- * yacc only invokes the printf with an if (be careful, the printf |
60 |
- * is not in a compound statement). |
61 |
+ * Replace all calls to printf with a call to trace_printf. The |
62 |
+ * trace_where_ is needed to set the location, and is safe, because |
63 |
+ * yacc only invokes the printf with an if (be careful, the printf |
64 |
+ * is not in a compound statement). |
65 |
*/ |
66 |
#define printf trace_where_, trace_printf |
67 |
|
68 |
/* |
69 |
* jiggery-pokery for bison |
70 |
* |
71 |
- * Replace all calls to fprintf with a call to yydebugger. Ignore |
72 |
- * the first argument, it will be "stderr". The trace_where_ is |
73 |
- * needed to set the location, and is safe, because bison only |
74 |
- * invokes the printf with an if (be careful, the fprintf is not in |
75 |
- * a compound statement). |
76 |
+ * Replace all calls to fprintf with a call to yydebugger. Ignore |
77 |
+ * the first argument, it will be "stderr". The trace_where_ is |
78 |
+ * needed to set the location, and is safe, because bison only |
79 |
+ * invokes the printf with an if (be careful, the fprintf is not in |
80 |
+ * a compound statement). |
81 |
*/ |
82 |
#define fprintf trace_where_, yydebugger |
83 |
|
84 |
static void |
85 |
yydebugger(void *, const char *fmt, ...) |
86 |
{ |
87 |
- va_list ap; |
88 |
- string_ty *s; |
89 |
+ va_list ap; |
90 |
+ string_ty *s; |
91 |
|
92 |
- va_start(ap, fmt); |
93 |
- s = str_vformat(fmt, ap); |
94 |
- va_end(ap); |
95 |
- trace_printf("%s", s->str_text); |
96 |
- str_free(s); |
97 |
+ va_start(ap, fmt); |
98 |
+ s = str_vformat(fmt, ap); |
99 |
+ va_end(ap); |
100 |
+ trace_printf("%s", s->str_text); |
101 |
+ str_free(s); |
102 |
} |
103 |
|
104 |
#endif |
105 |
@@ -170,138 +172,139 @@ |
106 |
%% |
107 |
|
108 |
grammar: |
109 |
- nplurals SEMI plural |
110 |
- ; |
111 |
+ nplurals SEMI plural |
112 |
+ ; |
113 |
|
114 |
nplurals |
115 |
- : NPLURALS EQU INTEGER |
116 |
- { |
117 |
- nplurals = $3; |
118 |
- } |
119 |
- ; |
120 |
+ : NPLURALS EQU INTEGER |
121 |
+ { |
122 |
+ nplurals = $3; |
123 |
+ } |
124 |
+ ; |
125 |
|
126 |
plural |
127 |
- : PLURAL EQU expr |
128 |
- { |
129 |
- plural = $3; |
130 |
- } |
131 |
- ; |
132 |
+ : PLURAL EQU expr |
133 |
+ { |
134 |
+ plural = $3; |
135 |
+ } |
136 |
+ ; |
137 |
|
138 |
expr |
139 |
- : LP expr RP |
140 |
- { |
141 |
- $$ = $2; |
142 |
- trace(("$$ = %u;\n", $$)); |
143 |
- } |
144 |
- | NUMBER |
145 |
- { |
146 |
- $$ = number; |
147 |
- trace(("$$ = %u;\n", $$)); |
148 |
- } |
149 |
- | INTEGER |
150 |
- { |
151 |
- $$ = $1; |
152 |
- trace(("$$ = %u;\n", $$)); |
153 |
- } |
154 |
- | MINUS expr |
155 |
- %prec UNARY |
156 |
- { |
157 |
- $$ = -$2; |
158 |
- trace(("$$ = %u;\n", $$)); |
159 |
- } |
160 |
- | expr PLUS expr |
161 |
- { |
162 |
- $$ = $1 + $3; |
163 |
- trace(("$$ = %u;\n", $$)); |
164 |
- } |
165 |
- | expr MINUS expr |
166 |
- { |
167 |
- $$ = $1 - $3; |
168 |
- trace(("$$ = %u;\n", $$)); |
169 |
- } |
170 |
- | expr MUL expr |
171 |
- { |
172 |
- $$ = $1 * $3; |
173 |
- trace(("$$ = %u;\n", $$)); |
174 |
- } |
175 |
- | expr DIV expr |
176 |
- { |
177 |
- $$ = $3 ? $1 / $3 : 0; |
178 |
- trace(("$$ = %u;\n", $$)); |
179 |
- } |
180 |
- | expr MOD expr |
181 |
- { |
182 |
- $$ = $3 ? $1 % $3 : 0; |
183 |
- trace(("$$ = %u;\n", $$)); |
184 |
- } |
185 |
- | expr EQ expr |
186 |
- { |
187 |
- $$ = ($1 == $3); |
188 |
- trace(("$$ = %u;\n", $$)); |
189 |
- } |
190 |
- | expr NE expr |
191 |
- { |
192 |
- $$ = ($1 != $3); |
193 |
- trace(("$$ = %u;\n", $$)); |
194 |
- } |
195 |
- | expr LT expr |
196 |
- { |
197 |
- $$ = ($1 < $3); |
198 |
- trace(("$$ = %u;\n", $$)); |
199 |
- } |
200 |
- | expr LE expr |
201 |
- { |
202 |
- $$ = ($1 <= $3); |
203 |
- trace(("$$ = %u;\n", $$)); |
204 |
- } |
205 |
- | expr GT expr |
206 |
- { |
207 |
- $$ = ($1 > $3); |
208 |
- trace(("$$ = %u;\n", $$)); |
209 |
- } |
210 |
- | expr GE expr |
211 |
- { |
212 |
- $$ = ($1 >= $3); |
213 |
- trace(("$$ = %u;\n", $$)); |
214 |
- } |
215 |
- | NOT expr |
216 |
- { |
217 |
- $$ = (!$2); |
218 |
- trace(("$$ = %u;\n", $$)); |
219 |
- } |
220 |
- | BITNOT expr |
221 |
- { |
222 |
- $$ = ~$2; |
223 |
- trace(("$$ = %u;\n", $$)); |
224 |
- } |
225 |
- | expr ANDAND expr |
226 |
- { |
227 |
- $$ = $1 && $3; |
228 |
- trace(("$$ = %u;\n", $$)); |
229 |
- } |
230 |
- | expr BITAND expr |
231 |
- { |
232 |
- $$ = $1 & $3; |
233 |
- trace(("$$ = %u;\n", $$)); |
234 |
- } |
235 |
- | expr OROR expr |
236 |
- { |
237 |
- $$ = $1 || $3; |
238 |
- trace(("$$ = %u;\n", $$)); |
239 |
- } |
240 |
- | expr BITOR expr |
241 |
- { |
242 |
- $$ = $1 | $3; |
243 |
- trace(("$$ = %u;\n", $$)); |
244 |
- } |
245 |
- | expr BITXOR expr |
246 |
- { |
247 |
- $$ = $1 ^ $3; |
248 |
- trace(("$$ = %u;\n", $$)); |
249 |
- } |
250 |
- | expr QUEST expr COLON expr |
251 |
- { |
252 |
- $$ = $1 ? $3 : $5; |
253 |
- trace(("$$ = %u;\n", $$)); |
254 |
- } |
255 |
- ; |
256 |
+ : LP expr RP |
257 |
+ { |
258 |
+ $$ = $2; |
259 |
+ trace(("$$ = %u;\n", $$)); |
260 |
+ } |
261 |
+ | NUMBER |
262 |
+ { |
263 |
+ $$ = number; |
264 |
+ trace(("$$ = %u;\n", $$)); |
265 |
+ } |
266 |
+ | INTEGER |
267 |
+ { |
268 |
+ $$ = $1; |
269 |
+ trace(("$$ = %u;\n", $$)); |
270 |
+ } |
271 |
+ | MINUS expr |
272 |
+ %prec UNARY |
273 |
+ { |
274 |
+ $$ = -$2; |
275 |
+ trace(("$$ = %u;\n", $$)); |
276 |
+ } |
277 |
+ | expr PLUS expr |
278 |
+ { |
279 |
+ $$ = $1 + $3; |
280 |
+ trace(("$$ = %u;\n", $$)); |
281 |
+ } |
282 |
+ | expr MINUS expr |
283 |
+ { |
284 |
+ $$ = $1 - $3; |
285 |
+ trace(("$$ = %u;\n", $$)); |
286 |
+ } |
287 |
+ | expr MUL expr |
288 |
+ { |
289 |
+ $$ = $1 * $3; |
290 |
+ trace(("$$ = %u;\n", $$)); |
291 |
+ } |
292 |
+ | expr DIV expr |
293 |
+ { |
294 |
+ $$ = $3 ? $1 / $3 : 0; |
295 |
+ trace(("$$ = %u;\n", $$)); |
296 |
+ } |
297 |
+ | expr MOD expr |
298 |
+ { |
299 |
+ $$ = $3 ? $1 % $3 : 0; |
300 |
+ trace(("$$ = %u;\n", $$)); |
301 |
+ } |
302 |
+ | expr EQ expr |
303 |
+ { |
304 |
+ $$ = ($1 == $3); |
305 |
+ trace(("$$ = %u;\n", $$)); |
306 |
+ } |
307 |
+ | expr NE expr |
308 |
+ { |
309 |
+ $$ = ($1 != $3); |
310 |
+ trace(("$$ = %u;\n", $$)); |
311 |
+ } |
312 |
+ | expr LT expr |
313 |
+ { |
314 |
+ $$ = ($1 < $3); |
315 |
+ trace(("$$ = %u;\n", $$)); |
316 |
+ } |
317 |
+ | expr LE expr |
318 |
+ { |
319 |
+ $$ = ($1 <= $3); |
320 |
+ trace(("$$ = %u;\n", $$)); |
321 |
+ } |
322 |
+ | expr GT expr |
323 |
+ { |
324 |
+ $$ = ($1 > $3); |
325 |
+ trace(("$$ = %u;\n", $$)); |
326 |
+ } |
327 |
+ | expr GE expr |
328 |
+ { |
329 |
+ $$ = ($1 >= $3); |
330 |
+ trace(("$$ = %u;\n", $$)); |
331 |
+ } |
332 |
+ | NOT expr |
333 |
+ { |
334 |
+ $$ = (!$2); |
335 |
+ trace(("$$ = %u;\n", $$)); |
336 |
+ } |
337 |
+ | BITNOT expr |
338 |
+ { |
339 |
+ $$ = ~$2; |
340 |
+ trace(("$$ = %u;\n", $$)); |
341 |
+ } |
342 |
+ | expr ANDAND expr |
343 |
+ { |
344 |
+ $$ = $1 && $3; |
345 |
+ trace(("$$ = %u;\n", $$)); |
346 |
+ } |
347 |
+ | expr BITAND expr |
348 |
+ { |
349 |
+ $$ = $1 & $3; |
350 |
+ trace(("$$ = %u;\n", $$)); |
351 |
+ } |
352 |
+ | expr OROR expr |
353 |
+ { |
354 |
+ $$ = $1 || $3; |
355 |
+ trace(("$$ = %u;\n", $$)); |
356 |
+ } |
357 |
+ | expr BITOR expr |
358 |
+ { |
359 |
+ $$ = $1 | $3; |
360 |
+ trace(("$$ = %u;\n", $$)); |
361 |
+ } |
362 |
+ | expr BITXOR expr |
363 |
+ { |
364 |
+ $$ = $1 ^ $3; |
365 |
+ trace(("$$ = %u;\n", $$)); |
366 |
+ } |
367 |
+ | expr QUEST expr COLON expr |
368 |
+ { |
369 |
+ $$ = $1 ? $3 : $5; |
370 |
+ trace(("$$ = %u;\n", $$)); |
371 |
+ } |
372 |
+ ; |
373 |
+// vim: set ts=8 sw=4 et : |