]>
Commit | Line | Data |
---|---|---|
817e9f41 | 1 | # Exercising Bison on actual grammars. -*- Autotest -*- |
2740f169 | 2 | |
affac613 | 3 | # Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004, 2005 |
2740f169 | 4 | # Free Software Foundation, Inc. |
817e9f41 AD |
5 | |
6 | # This program is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 2, or (at your option) | |
9 | # any later version. | |
10 | ||
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | ||
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program; if not, write to the Free Software | |
0fb669f9 PE |
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
19 | # 02110-1301, USA. | |
817e9f41 AD |
20 | |
21 | AT_BANNER([[Existing Grammars.]]) | |
22 | ## ----------------- ## | |
23 | ## GNU AWK Grammar. ## | |
24 | ## ----------------- ## | |
25 | ||
26 | AT_SETUP([GNU AWK Grammar]) | |
27 | ||
28 | # We have been careful to strip all the actions excepts the | |
29 | # mid-rule actions. We rely on %expect to check that there are | |
30 | # indeed 65 SR conflicts. | |
31 | # | |
32 | # Bison was once wrong, due to an incorrect computation of nullable. | |
33 | # It reported 485 SR conflicts! | |
34 | ||
35 | AT_DATA([[input.y]], | |
36 | [[%expect 65 | |
37 | ||
38 | %token FUNC_CALL NAME REGEXP | |
39 | %token ERROR | |
40 | %token YNUMBER YSTRING | |
41 | %token RELOP APPEND_OP | |
42 | %token ASSIGNOP MATCHOP NEWLINE CONCAT_OP | |
43 | %token LEX_BEGIN LEX_END LEX_IF LEX_ELSE LEX_RETURN LEX_DELETE | |
44 | %token LEX_WHILE LEX_DO LEX_FOR LEX_BREAK LEX_CONTINUE | |
45 | %token LEX_PRINT LEX_PRINTF LEX_NEXT LEX_EXIT LEX_FUNCTION | |
46 | %token LEX_GETLINE LEX_NEXTFILE | |
47 | %token LEX_IN | |
48 | %token LEX_AND LEX_OR INCREMENT DECREMENT | |
49 | %token LEX_BUILTIN LEX_LENGTH | |
50 | ||
51 | /* Lowest to highest */ | |
52 | %right ASSIGNOP | |
53 | %right '?' ':' | |
54 | %left LEX_OR | |
55 | %left LEX_AND | |
56 | %left LEX_GETLINE | |
57 | %nonassoc LEX_IN | |
58 | %left FUNC_CALL LEX_BUILTIN LEX_LENGTH | |
59 | %nonassoc ',' | |
60 | %nonassoc MATCHOP | |
61 | %nonassoc RELOP '<' '>' '|' APPEND_OP TWOWAYIO | |
62 | %left CONCAT_OP | |
63 | %left YSTRING YNUMBER | |
64 | %left '+' '-' | |
65 | %left '*' '/' '%' | |
66 | %right '!' UNARY | |
67 | %right '^' | |
68 | %left INCREMENT DECREMENT | |
69 | %left '$' | |
70 | %left '(' ')' | |
71 | %% | |
72 | ||
73 | start | |
74 | : opt_nls program opt_nls | |
75 | ; | |
76 | ||
77 | program | |
78 | : rule | |
79 | | program rule | |
80 | | error | |
81 | | program error | |
82 | | /* empty */ | |
83 | ; | |
84 | ||
85 | rule | |
86 | : LEX_BEGIN {} action | |
87 | | LEX_END {} action | |
88 | | LEX_BEGIN statement_term | |
89 | | LEX_END statement_term | |
90 | | pattern action | |
91 | | action | |
92 | | pattern statement_term | |
93 | | function_prologue function_body | |
94 | ; | |
95 | ||
96 | func_name | |
97 | : NAME | |
98 | | FUNC_CALL | |
99 | | lex_builtin | |
100 | ; | |
101 | ||
102 | lex_builtin | |
103 | : LEX_BUILTIN | |
104 | | LEX_LENGTH | |
105 | ; | |
106 | ||
107 | function_prologue | |
108 | : LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls | |
109 | ; | |
110 | ||
111 | function_body | |
112 | : l_brace statements r_brace opt_semi opt_nls | |
113 | | l_brace r_brace opt_semi opt_nls | |
114 | ; | |
115 | ||
817e9f41 AD |
116 | pattern |
117 | : exp | |
118 | | exp ',' exp | |
119 | ; | |
120 | ||
121 | regexp | |
122 | /* | |
123 | * In this rule, want_regexp tells yylex that the next thing | |
124 | * is a regexp so it should read up to the closing slash. | |
125 | */ | |
126 | : '/' {} REGEXP '/' | |
127 | ; | |
128 | ||
129 | action | |
130 | : l_brace statements r_brace opt_semi opt_nls | |
131 | | l_brace r_brace opt_semi opt_nls | |
132 | ; | |
133 | ||
134 | statements | |
135 | : statement | |
136 | | statements statement | |
137 | | error | |
138 | | statements error | |
139 | ; | |
140 | ||
141 | statement_term | |
142 | : nls | |
143 | | semi opt_nls | |
144 | ; | |
145 | ||
146 | statement | |
147 | : semi opt_nls | |
148 | | l_brace r_brace | |
149 | | l_brace statements r_brace | |
150 | | if_statement | |
151 | | LEX_WHILE '(' exp r_paren opt_nls statement | |
152 | | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls | |
153 | | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement | |
154 | | LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement | |
155 | | LEX_FOR '(' opt_exp semi opt_nls semi opt_nls opt_exp r_paren opt_nls statement | |
156 | | LEX_BREAK statement_term | |
157 | | LEX_CONTINUE statement_term | |
158 | | print '(' expression_list r_paren output_redir statement_term | |
159 | | print opt_rexpression_list output_redir statement_term | |
160 | | LEX_NEXT statement_term | |
161 | | LEX_NEXTFILE statement_term | |
162 | | LEX_EXIT opt_exp statement_term | |
163 | | LEX_RETURN {} opt_exp statement_term | |
164 | | LEX_DELETE NAME '[' expression_list ']' statement_term | |
165 | | LEX_DELETE NAME statement_term | |
166 | | exp statement_term | |
167 | ; | |
168 | ||
169 | ||
170 | : LEX_PRINT | |
171 | | LEX_PRINTF | |
172 | ; | |
173 | ||
174 | if_statement | |
175 | : LEX_IF '(' exp r_paren opt_nls statement | |
176 | | LEX_IF '(' exp r_paren opt_nls statement | |
177 | LEX_ELSE opt_nls statement | |
178 | ; | |
179 | ||
180 | nls | |
181 | : NEWLINE | |
182 | | nls NEWLINE | |
183 | ; | |
184 | ||
185 | opt_nls | |
186 | : /* empty */ | |
187 | | nls | |
188 | ; | |
189 | ||
190 | input_redir | |
191 | : /* empty */ | |
192 | | '<' simp_exp | |
193 | ; | |
194 | ||
195 | output_redir | |
196 | : /* empty */ | |
197 | | '>' exp | |
198 | | APPEND_OP exp | |
199 | | '|' exp | |
200 | | TWOWAYIO exp | |
201 | ; | |
202 | ||
203 | opt_param_list | |
204 | : /* empty */ | |
205 | | param_list | |
206 | ; | |
207 | ||
208 | param_list | |
209 | : NAME | |
210 | | param_list comma NAME | |
211 | | error | |
212 | | param_list error | |
213 | | param_list comma error | |
214 | ; | |
215 | ||
216 | /* optional expression, as in for loop */ | |
217 | opt_exp | |
218 | : /* empty */ | |
219 | | exp | |
220 | ; | |
221 | ||
222 | opt_rexpression_list | |
223 | : /* empty */ | |
224 | | rexpression_list | |
225 | ; | |
226 | ||
227 | rexpression_list | |
228 | : rexp | |
229 | | rexpression_list comma rexp | |
230 | | error | |
231 | | rexpression_list error | |
232 | | rexpression_list error rexp | |
233 | | rexpression_list comma error | |
234 | ; | |
235 | ||
236 | opt_expression_list | |
237 | : /* empty */ | |
238 | | expression_list | |
239 | ; | |
240 | ||
241 | expression_list | |
242 | : exp | |
243 | | expression_list comma exp | |
244 | | error | |
245 | | expression_list error | |
246 | | expression_list error exp | |
247 | | expression_list comma error | |
248 | ; | |
249 | ||
250 | /* Expressions, not including the comma operator. */ | |
251 | exp : variable ASSIGNOP {} exp | |
252 | | '(' expression_list r_paren LEX_IN NAME | |
253 | | exp '|' LEX_GETLINE opt_variable | |
254 | | exp TWOWAYIO LEX_GETLINE opt_variable | |
255 | | LEX_GETLINE opt_variable input_redir | |
256 | | exp LEX_AND exp | |
257 | | exp LEX_OR exp | |
258 | | exp MATCHOP exp | |
259 | | regexp | |
260 | | '!' regexp %prec UNARY | |
261 | | exp LEX_IN NAME | |
262 | | exp RELOP exp | |
263 | | exp '<' exp | |
264 | | exp '>' exp | |
265 | | exp '?' exp ':' exp | |
266 | | simp_exp | |
267 | | exp simp_exp %prec CONCAT_OP | |
268 | ; | |
269 | ||
270 | rexp | |
271 | : variable ASSIGNOP {} rexp | |
272 | | rexp LEX_AND rexp | |
273 | | rexp LEX_OR rexp | |
274 | | LEX_GETLINE opt_variable input_redir | |
275 | | regexp | |
276 | | '!' regexp %prec UNARY | |
277 | | rexp MATCHOP rexp | |
278 | | rexp LEX_IN NAME | |
279 | | rexp RELOP rexp | |
280 | | rexp '?' rexp ':' rexp | |
281 | | simp_exp | |
282 | | rexp simp_exp %prec CONCAT_OP | |
283 | ; | |
284 | ||
285 | simp_exp | |
286 | : non_post_simp_exp | |
287 | /* Binary operators in order of decreasing precedence. */ | |
288 | | simp_exp '^' simp_exp | |
289 | | simp_exp '*' simp_exp | |
290 | | simp_exp '/' simp_exp | |
291 | | simp_exp '%' simp_exp | |
292 | | simp_exp '+' simp_exp | |
293 | | simp_exp '-' simp_exp | |
294 | | variable INCREMENT | |
295 | | variable DECREMENT | |
296 | ; | |
297 | ||
298 | non_post_simp_exp | |
299 | : '!' simp_exp %prec UNARY | |
300 | | '(' exp r_paren | |
301 | | LEX_BUILTIN | |
302 | '(' opt_expression_list r_paren | |
303 | | LEX_LENGTH '(' opt_expression_list r_paren | |
304 | | LEX_LENGTH | |
305 | | FUNC_CALL '(' opt_expression_list r_paren | |
306 | | variable | |
307 | | INCREMENT variable | |
308 | | DECREMENT variable | |
309 | | YNUMBER | |
310 | | YSTRING | |
311 | | '-' simp_exp %prec UNARY | |
312 | | '+' simp_exp %prec UNARY | |
313 | ; | |
314 | ||
315 | opt_variable | |
316 | : /* empty */ | |
317 | | variable | |
318 | ; | |
319 | ||
320 | variable | |
321 | : NAME | |
322 | | NAME '[' expression_list ']' | |
323 | | '$' non_post_simp_exp | |
324 | ; | |
325 | ||
326 | l_brace | |
f0064700 PE |
327 | : '{' opt_nls |
328 | ; | |
817e9f41 AD |
329 | |
330 | r_brace | |
f0064700 | 331 | : '}' opt_nls |
817e9f41 AD |
332 | ; |
333 | ||
334 | r_paren | |
335 | : ')' | |
336 | ; | |
337 | ||
338 | opt_semi | |
339 | : /* empty */ | |
340 | | semi | |
341 | ; | |
342 | ||
343 | semi | |
344 | : ';' | |
345 | ; | |
346 | ||
347 | comma : ',' opt_nls | |
348 | ; | |
349 | ||
350 | %% | |
351 | ]]) | |
352 | ||
353 | # Pass plenty of options, to exercise plenty of code, even if we | |
354 | # don't actually check the output. But SEGV is watching us, and | |
355 | # so might do dmalloc. | |
356 | AT_CHECK([[bison --verbose --defines input.y]]) | |
357 | ||
358 | AT_CLEANUP | |
359 | ||
817e9f41 AD |
360 | ## ----------------- ## |
361 | ## GNU Cim Grammar. ## | |
362 | ## ----------------- ## | |
363 | ||
364 | AT_SETUP([GNU Cim Grammar]) | |
365 | ||
366 | # GNU Cim, the GNU Simula 87 Compiler. | |
367 | ||
368 | # Bison was once wrong, due to an incorrect computation of the RR conflicts. | |
369 | # It reported 80 SR && 99 RR conflicts instead of 78/10!!! | |
370 | ||
371 | AT_DATA([[input.y]], | |
affac613 | 372 | [[%union {} |
817e9f41 AD |
373 | |
374 | %token | |
f0064700 PE |
375 | HACTIVATE HAFTER /*HAND*/ HARRAY HAT |
376 | HBEFORE HBEGIN HBOOLEAN | |
377 | HCHARACTER HCLASS /*HCOMMENT*/ HCONC | |
378 | HDELAY HDO | |
379 | HELSE HEND HEQ /*HEQV*/ HEXTERNAL | |
380 | HFOR | |
381 | HGE HGO HGOTO HGT | |
382 | HHIDDEN | |
383 | HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS | |
384 | HLABEL HLE HLONG HLT | |
385 | HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT | |
386 | /*HOR*/ HOTHERWISE | |
387 | HPRIOR HPROCEDURE HPROTECTED | |
388 | HQUA | |
389 | HREACTIVATE HREAL HREF | |
390 | HSHORT HSTEP HSWITCH | |
391 | HTEXT HTHEN HTHIS HTO | |
392 | HUNTIL | |
393 | HVALUE HVAR HVIRTUAL | |
394 | HWHEN HWHILE | |
395 | ||
396 | HASSIGNVALUE HASSIGNREF | |
397 | /*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR | |
398 | HBEGPAR HENDPAR | |
399 | HEQR HNER | |
400 | HADD HSUB HMUL HDIV HINTDIV HEXP | |
04098407 | 401 | HDOTDOTDOT |
817e9f41 | 402 | |
affac613 AD |
403 | %token HIDENTIFIER |
404 | %token HBOOLEANKONST HINTEGERKONST HCHARACTERKONST | |
405 | %token HREALKONST | |
406 | %token HTEXTKONST | |
817e9f41 | 407 | |
817e9f41 | 408 | |
affac613 | 409 | %right HASSIGN |
817e9f41 AD |
410 | %left HORELSE |
411 | %left HANDTHEN | |
412 | %left HEQV | |
413 | %left HIMP | |
414 | %left HOR | |
415 | %left HAND | |
416 | ||
417 | %left HNOT | |
418 | ||
affac613 | 419 | %left HVALRELOPERATOR HREFRELOPERATOR HOBJRELOPERATOR |
817e9f41 AD |
420 | |
421 | %left HCONC | |
422 | ||
affac613 AD |
423 | %left HTERMOPERATOR |
424 | %left UNEAR | |
425 | %left HFACTOROPERATOR | |
817e9f41 AD |
426 | %left HPRIMARYOPERATOR |
427 | ||
428 | %left HQUA | |
429 | ||
430 | %left HDOT | |
431 | ||
432 | %start MAIN_MODULE | |
433 | %% | |
434 | /* GRAMATIKK FOR PROGRAM MODULES */ | |
affac613 AD |
435 | MAIN_MODULE : {} |
436 | MODULS | |
04098407 | 437 | | error HSTATEMENTSEPARATOR MBEE_DECLSTMS |
817e9f41 AD |
438 | ; |
439 | EXT_DECLARATION : HEXTERNAL | |
440 | MBEE_TYPE | |
441 | HPROCEDURE | |
affac613 | 442 | {} |
817e9f41 AD |
443 | EXT_LIST |
444 | | | |
445 | HEXTERNAL | |
446 | HIDENTIFIER | |
447 | HPROCEDURE | |
affac613 AD |
448 | {} |
449 | HIDENTIFIER {} | |
817e9f41 | 450 | EXTERNAL_KIND_ITEM |
817e9f41 AD |
451 | | HEXTERNAL |
452 | HCLASS | |
affac613 | 453 | {} |
817e9f41 AD |
454 | EXT_LIST |
455 | ||
456 | ; | |
457 | EXTERNAL_KIND_ITEM: EXT_IDENT | |
458 | HOBJRELOPERATOR | |
affac613 | 459 | {} |
f0064700 | 460 | MBEE_TYPE HPROCEDURE |
817e9f41 | 461 | HIDENTIFIER |
affac613 | 462 | {} |
f0064700 | 463 | HEADING EMPTY_BLOCK |
affac613 | 464 | {} |
817e9f41 AD |
465 | /* | |
466 | EXT_IDENT | |
affac613 | 467 | {} |
817e9f41 | 468 | MBEE_REST_EXT_LIST |
817e9f41 AD |
469 | ; |
470 | MBEE_REST_EXT_LIST: /* EMPTY | |
471 | | HPAREXPSEPARATOR EXT_KIND_LIST | |
472 | ; | |
473 | EXT_KIND_LIST : EXT_KIND_ITEM | |
474 | | EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM | |
475 | ; | |
476 | EXT_KIND_ITEM : HIDENTIFIER | |
477 | EXT_IDENT | |
affac613 | 478 | {}*/ |
817e9f41 AD |
479 | ; |
480 | EMPTY_BLOCK : /*EMPT*/ | |
481 | | HBEGIN HEND | |
482 | ; | |
483 | EXT_LIST : EXT_ITEM | |
484 | | EXT_LIST HPAREXPSEPARATOR EXT_ITEM | |
485 | ; | |
486 | EXT_ITEM : HIDENTIFIER | |
487 | EXT_IDENT | |
817e9f41 | 488 | ; |
affac613 AD |
489 | EXT_IDENT : /* EMPTY */ |
490 | | HVALRELOPERATOR {} | |
491 | HTEXTKONST | |
817e9f41 AD |
492 | ; |
493 | /* GRAMATIKK FOR TYPER */ | |
affac613 | 494 | NO_TYPE : /*EMPT*/ |
f0064700 | 495 | ; |
817e9f41 | 496 | MBEE_TYPE : NO_TYPE |
f0064700 PE |
497 | | TYPE |
498 | ; | |
817e9f41 | 499 | TYPE : HREF HBEGPAR |
f0064700 PE |
500 | HIDENTIFIER |
501 | {} | |
502 | HENDPAR | |
503 | | HTEXT | |
504 | | HBOOLEAN | |
505 | | HCHARACTER | |
506 | | HSHORT HINTEGER | |
507 | | HINTEGER | |
508 | | HREAL | |
509 | | HLONG HREAL | |
510 | ; | |
817e9f41 AD |
511 | |
512 | /* GRAMATIKK FOR DEL AV SETNINGER */ | |
513 | MBEE_ELSE_PART : /*EMPT*/ | |
514 | /* | HELSE | |
515 | HIF | |
f0064700 PE |
516 | EXPRESSION |
517 | HTHEN {} | |
518 | BLOCK {} | |
519 | MBEE_ELSE_PART {}*/ | |
520 | | HELSE {} | |
521 | BLOCK | |
522 | ; | |
affac613 | 523 | FOR_LIST : FOR_LIST_ELEMENT |
f0064700 PE |
524 | | FOR_LIST_ELEMENT |
525 | HPAREXPSEPARATOR | |
526 | FOR_LIST | |
527 | ; | |
817e9f41 | 528 | FOR_LIST_ELEMENT: EXPRESSION |
f0064700 PE |
529 | MBEE_F_L_EL_R_PT |
530 | ; | |
817e9f41 | 531 | MBEE_F_L_EL_R_PT: /*EMPT*/ |
f0064700 PE |
532 | | HWHILE |
533 | EXPRESSION | |
534 | | HSTEP | |
535 | EXPRESSION | |
536 | HUNTIL | |
537 | EXPRESSION | |
538 | ; | |
817e9f41 | 539 | GOTO : HGO |
f0064700 PE |
540 | HTO |
541 | | HGOTO | |
542 | ; | |
817e9f41 | 543 | CONN_STATE_R_PT : WHEN_CLAUSE_LIST |
f0064700 PE |
544 | | HDO {} |
545 | BLOCK | |
546 | ; | |
817e9f41 | 547 | WHEN_CLAUSE_LIST: HWHEN |
f0064700 PE |
548 | HIDENTIFIER |
549 | HDO {} | |
550 | BLOCK | |
551 | | WHEN_CLAUSE_LIST | |
552 | HWHEN | |
553 | HIDENTIFIER | |
554 | HDO {} | |
555 | BLOCK | |
556 | ; | |
817e9f41 | 557 | MBEE_OTWI_CLAUS : /*EMPT*/ |
f0064700 | 558 | | HOTHERWISE {} |
817e9f41 | 559 | |
f0064700 PE |
560 | BLOCK |
561 | ; | |
affac613 AD |
562 | ACTIVATOR : HACTIVATE |
563 | | HREACTIVATE | |
817e9f41 | 564 | ; |
affac613 AD |
565 | SCHEDULE : /*EMPT*/ |
566 | | ATDELAY EXPRESSION {} | |
817e9f41 | 567 | PRIOR |
affac613 AD |
568 | | BEFOREAFTER {} |
569 | EXPRESSION | |
817e9f41 | 570 | ; |
affac613 AD |
571 | ATDELAY : HAT |
572 | | HDELAY | |
817e9f41 | 573 | ; |
affac613 AD |
574 | BEFOREAFTER : HBEFORE |
575 | | HAFTER | |
817e9f41 | 576 | ; |
affac613 AD |
577 | PRIOR : /*EMPT*/ |
578 | | HPRIOR | |
817e9f41 AD |
579 | ; |
580 | /* GRAMATIKK FOR SETNINGER OG DEKLARASJONER */ | |
581 | MODULSTATEMENT : HWHILE | |
f0064700 PE |
582 | EXPRESSION |
583 | HDO {} | |
584 | BLOCK | |
04098407 | 585 | | HIF |
f0064700 PE |
586 | EXPRESSION |
587 | HTHEN {} | |
588 | BLOCK {} | |
589 | MBEE_ELSE_PART | |
817e9f41 | 590 | | HFOR |
f0064700 PE |
591 | HIDENTIFIER |
592 | HASSIGN {} | |
593 | FOR_LIST | |
594 | HDO {} | |
595 | BLOCK | |
817e9f41 | 596 | | GOTO |
f0064700 | 597 | EXPRESSION |
817e9f41 | 598 | | HINSPECT |
f0064700 PE |
599 | EXPRESSION {} |
600 | CONN_STATE_R_PT | |
601 | {} | |
602 | MBEE_OTWI_CLAUS | |
affac613 | 603 | | HINNER |
f0064700 PE |
604 | | HIDENTIFIER |
605 | HLABELSEPARATOR | |
606 | {} | |
607 | DECLSTATEMENT | |
608 | | EXPRESSION_SIMP | |
609 | HBEGIN | |
610 | {} | |
817e9f41 | 611 | IMPORT_SPEC_MODULE |
affac613 | 612 | {} |
f0064700 PE |
613 | MBEE_DECLSTMS |
614 | HEND | |
817e9f41 | 615 | | EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR |
f0064700 | 616 | MBEE_DECLSTMS HEND |
817e9f41 | 617 | | EXPRESSION_SIMP HBEGIN error HEND |
f0064700 | 618 | | EXPRESSION_SIMP |
817e9f41 | 619 | | ACTIVATOR EXPRESSION SCHEDULE |
f0064700 PE |
620 | | HBEGIN |
621 | {} | |
622 | MBEE_DECLSTMS | |
623 | HEND | |
817e9f41 | 624 | | MBEE_TYPE HPROCEDURE |
f0064700 PE |
625 | HIDENTIFIER |
626 | {} | |
627 | HEADING BLOCK | |
817e9f41 AD |
628 | | HIDENTIFIER |
629 | HCLASS | |
f0064700 | 630 | NO_TYPE |
affac613 | 631 | {} |
817e9f41 | 632 | IMPORT_SPEC_MODULE |
f0064700 | 633 | HIDENTIFIER |
affac613 | 634 | {} |
f0064700 PE |
635 | HEADING |
636 | BLOCK | |
637 | | HCLASS | |
638 | NO_TYPE | |
639 | HIDENTIFIER | |
640 | {} | |
641 | HEADING | |
642 | BLOCK | |
643 | | EXT_DECLARATION | |
affac613 | 644 | | /*EMPT*/ |
f0064700 | 645 | ; |
affac613 | 646 | IMPORT_SPEC_MODULE: |
817e9f41 AD |
647 | ; |
648 | DECLSTATEMENT : MODULSTATEMENT | |
649 | | TYPE | |
f0064700 | 650 | HIDENTIFIER |
817e9f41 | 651 | MBEE_CONSTANT |
f0064700 PE |
652 | HPAREXPSEPARATOR |
653 | {} | |
654 | IDENTIFIER_LISTC | |
655 | | TYPE | |
656 | HIDENTIFIER | |
817e9f41 | 657 | MBEE_CONSTANT |
f0064700 PE |
658 | | MBEE_TYPE |
659 | HARRAY {} | |
660 | ARR_SEGMENT_LIST | |
661 | | HSWITCH | |
662 | HIDENTIFIER | |
663 | HASSIGN {} | |
664 | SWITCH_LIST | |
665 | ; | |
affac613 | 666 | BLOCK : DECLSTATEMENT |
f0064700 | 667 | | HBEGIN MBEE_DECLSTMS HEND |
817e9f41 AD |
668 | | HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND |
669 | | HBEGIN error HEND | |
670 | ; | |
affac613 | 671 | MBEE_DECLSTMS : MBEE_DECLSTMSU |
f0064700 | 672 | ; |
affac613 | 673 | MBEE_DECLSTMSU : DECLSTATEMENT |
f0064700 PE |
674 | | MBEE_DECLSTMSU |
675 | HSTATEMENTSEPARATOR | |
676 | DECLSTATEMENT | |
677 | ; | |
affac613 | 678 | MODULS : MODULSTATEMENT |
04098407 | 679 | | MODULS HSTATEMENTSEPARATOR MODULSTATEMENT |
817e9f41 AD |
680 | ; |
681 | /* GRAMATIKK FOR DEL AV DEKLARASJONER */ | |
682 | ARR_SEGMENT_LIST: ARR_SEGMENT | |
f0064700 PE |
683 | | ARR_SEGMENT_LIST |
684 | HPAREXPSEPARATOR | |
685 | ARR_SEGMENT | |
686 | ; | |
817e9f41 | 687 | ARR_SEGMENT : ARRAY_SEGMENT |
f0064700 PE |
688 | HBEGPAR |
689 | BAUND_PAIR_LIST HENDPAR | |
690 | ; | |
affac613 | 691 | ARRAY_SEGMENT : ARRAY_SEGMENT_EL {} |
817e9f41 | 692 | |
f0064700 PE |
693 | | ARRAY_SEGMENT_EL |
694 | HPAREXPSEPARATOR | |
695 | ARRAY_SEGMENT | |
696 | ; | |
affac613 | 697 | ARRAY_SEGMENT_EL: HIDENTIFIER |
f0064700 | 698 | ; |
affac613 | 699 | BAUND_PAIR_LIST : BAUND_PAIR |
f0064700 PE |
700 | | BAUND_PAIR |
701 | HPAREXPSEPARATOR | |
702 | BAUND_PAIR_LIST | |
703 | ; | |
817e9f41 | 704 | BAUND_PAIR : EXPRESSION |
f0064700 PE |
705 | HLABELSEPARATOR |
706 | EXPRESSION | |
707 | ; | |
affac613 | 708 | SWITCH_LIST : EXPRESSION |
f0064700 PE |
709 | | EXPRESSION |
710 | HPAREXPSEPARATOR | |
711 | SWITCH_LIST | |
712 | ; | |
affac613 | 713 | HEADING : MBEE_FMAL_PAR_P HSTATEMENTSEPARATOR {} |
f0064700 PE |
714 | MBEE_MODE_PART {} |
715 | MBEE_SPEC_PART {} | |
716 | MBEE_PROT_PART {} | |
717 | MBEE_VIRT_PART | |
718 | ; | |
817e9f41 | 719 | MBEE_FMAL_PAR_P : /*EMPT*/ |
f0064700 PE |
720 | | FMAL_PAR_PART |
721 | ; | |
817e9f41 | 722 | FMAL_PAR_PART : HBEGPAR NO_TYPE |
f0064700 PE |
723 | MBEE_LISTV HENDPAR |
724 | ; | |
817e9f41 | 725 | MBEE_LISTV : /*EMPT*/ |
f0064700 PE |
726 | | LISTV |
727 | ; | |
affac613 | 728 | LISTV : HIDENTIFIER |
f0064700 PE |
729 | | FPP_CATEG HDOTDOTDOT |
730 | | HIDENTIFIER {} | |
731 | HPAREXPSEPARATOR LISTV | |
732 | | FPP_SPEC | |
733 | | FPP_SPEC | |
734 | HPAREXPSEPARATOR LISTV | |
735 | ; | |
817e9f41 | 736 | FPP_HEADING : HBEGPAR NO_TYPE |
f0064700 PE |
737 | FPP_MBEE_LISTV HENDPAR |
738 | ; | |
817e9f41 | 739 | FPP_MBEE_LISTV : /*EMPT*/ |
f0064700 PE |
740 | | FPP_LISTV |
741 | ; | |
affac613 | 742 | FPP_LISTV : FPP_CATEG HDOTDOTDOT |
f0064700 PE |
743 | | FPP_SPEC |
744 | | FPP_SPEC | |
745 | HPAREXPSEPARATOR LISTV | |
746 | ; | |
817e9f41 | 747 | FPP_SPEC : FPP_CATEG SPECIFIER HIDENTIFIER |
817e9f41 AD |
748 | | FPP_CATEG FPP_PROC_DECL_IN_SPEC |
749 | ; | |
750 | FPP_CATEG : HNAME HLABELSEPARATOR | |
f0064700 PE |
751 | | HVALUE HLABELSEPARATOR |
752 | | HVAR HLABELSEPARATOR | |
753 | | /*EMPT*/ | |
754 | ; | |
817e9f41 | 755 | FPP_PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE |
f0064700 | 756 | HIDENTIFIER |
affac613 | 757 | {} |
f0064700 | 758 | FPP_HEADING {} { /* Yes, two "final" actions. */ } |
817e9f41 | 759 | ; |
affac613 | 760 | IDENTIFIER_LISTV: HIDENTIFIER |
f0064700 PE |
761 | | HDOTDOTDOT |
762 | | HIDENTIFIER {} | |
763 | HPAREXPSEPARATOR IDENTIFIER_LISTV | |
764 | ; | |
817e9f41 | 765 | MBEE_MODE_PART : /*EMPT*/ |
f0064700 PE |
766 | | MODE_PART |
767 | ; | |
817e9f41 | 768 | MODE_PART : NAME_PART |
f0064700 PE |
769 | | VALUE_PART |
770 | | VAR_PART | |
771 | | NAME_PART VALUE_PART | |
772 | | VALUE_PART NAME_PART | |
773 | | NAME_PART VAR_PART | |
774 | | VAR_PART NAME_PART | |
775 | | VALUE_PART VAR_PART | |
776 | | VAR_PART VALUE_PART | |
777 | | VAR_PART NAME_PART VALUE_PART | |
778 | | NAME_PART VAR_PART VALUE_PART | |
779 | | NAME_PART VALUE_PART VAR_PART | |
780 | | VAR_PART VALUE_PART NAME_PART | |
781 | | VALUE_PART VAR_PART NAME_PART | |
782 | | VALUE_PART NAME_PART VAR_PART | |
783 | ; | |
affac613 | 784 | NAME_PART : HNAME {} |
f0064700 PE |
785 | IDENTIFIER_LISTV |
786 | HSTATEMENTSEPARATOR | |
787 | ; | |
affac613 | 788 | VAR_PART : HVAR {} |
f0064700 PE |
789 | IDENTIFIER_LISTV |
790 | HSTATEMENTSEPARATOR | |
791 | ; | |
affac613 | 792 | VALUE_PART : HVALUE {} |
f0064700 PE |
793 | IDENTIFIER_LISTV HSTATEMENTSEPARATOR |
794 | ; | |
817e9f41 | 795 | MBEE_SPEC_PART : /*EMPT*/ |
f0064700 PE |
796 | | SPEC_PART |
797 | ; | |
817e9f41 | 798 | SPEC_PART : ONE_SPEC |
f0064700 PE |
799 | | SPEC_PART ONE_SPEC |
800 | ; | |
817e9f41 AD |
801 | ONE_SPEC : SPECIFIER IDENTIFIER_LIST HSTATEMENTSEPARATOR |
802 | | NO_TYPE HPROCEDURE HIDENTIFIER HOBJRELOPERATOR | |
affac613 | 803 | {} |
817e9f41 | 804 | PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR |
f0064700 PE |
805 | | FPP_PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR |
806 | | MBEE_TYPE HPROCEDURE HIDENTIFIER HSTATEMENTSEPARATOR | |
807 | | MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR | |
808 | IDENTIFIER_LIST HSTATEMENTSEPARATOR | |
817e9f41 | 809 | ; |
affac613 | 810 | SPECIFIER : TYPE |
f0064700 PE |
811 | | MBEE_TYPE |
812 | HARRAY | |
813 | | HLABEL | |
814 | | HSWITCH | |
815 | ; | |
817e9f41 | 816 | PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE |
f0064700 | 817 | HIDENTIFIER |
affac613 | 818 | {} |
f0064700 | 819 | HEADING |
affac613 | 820 | {} |
817e9f41 | 821 | MBEE_BEGIN_END |
817e9f41 AD |
822 | ; |
823 | MBEE_BEGIN_END : /* EMPTY */ | |
824 | | HBEGIN HEND | |
825 | ; | |
826 | MBEE_PROT_PART : /*EMPT*/ | |
f0064700 PE |
827 | | PROTECTION_PART |
828 | ; | |
817e9f41 | 829 | PROTECTION_PART : PROT_SPECIFIER IDENTIFIER_LIST |
f0064700 PE |
830 | HSTATEMENTSEPARATOR |
831 | | PROTECTION_PART PROT_SPECIFIER | |
832 | IDENTIFIER_LIST HSTATEMENTSEPARATOR | |
833 | ; | |
affac613 | 834 | PROT_SPECIFIER : HHIDDEN |
f0064700 PE |
835 | | HPROTECTED |
836 | | HHIDDEN | |
837 | HPROTECTED | |
838 | | HPROTECTED | |
839 | HHIDDEN | |
840 | ; | |
817e9f41 | 841 | MBEE_VIRT_PART : /*EMPT*/ |
f0064700 PE |
842 | | VIRTUAL_PART |
843 | ; | |
817e9f41 | 844 | VIRTUAL_PART : HVIRTUAL |
f0064700 PE |
845 | HLABELSEPARATOR |
846 | MBEE_SPEC_PART | |
847 | ; | |
affac613 | 848 | IDENTIFIER_LIST : HIDENTIFIER |
f0064700 PE |
849 | | IDENTIFIER_LIST HPAREXPSEPARATOR |
850 | HIDENTIFIER | |
851 | ; | |
817e9f41 | 852 | IDENTIFIER_LISTC: HIDENTIFIER |
affac613 | 853 | MBEE_CONSTANT |
f0064700 PE |
854 | | IDENTIFIER_LISTC HPAREXPSEPARATOR |
855 | HIDENTIFIER | |
affac613 | 856 | MBEE_CONSTANT |
f0064700 | 857 | ; |
817e9f41 AD |
858 | MBEE_CONSTANT : /* EMPTY */ |
859 | | HVALRELOPERATOR | |
affac613 AD |
860 | {} |
861 | EXPRESSION | |
817e9f41 AD |
862 | ; |
863 | ||
864 | /* GRAMATIKK FOR UTTRYKK */ | |
affac613 | 865 | EXPRESSION : EXPRESSION_SIMP |
f0064700 PE |
866 | | HIF |
867 | EXPRESSION | |
868 | HTHEN | |
869 | EXPRESSION | |
870 | HELSE | |
871 | EXPRESSION | |
872 | ; | |
817e9f41 AD |
873 | EXPRESSION_SIMP : EXPRESSION_SIMP |
874 | HASSIGN | |
affac613 | 875 | EXPRESSION |
817e9f41 AD |
876 | | |
877 | ||
878 | EXPRESSION_SIMP | |
f0064700 PE |
879 | HCONC |
880 | EXPRESSION_SIMP | |
881 | | EXPRESSION_SIMP HOR | |
882 | HELSE | |
883 | EXPRESSION_SIMP | |
884 | %prec HORELSE | |
885 | | EXPRESSION_SIMP HAND | |
886 | HTHEN | |
887 | EXPRESSION_SIMP | |
888 | %prec HANDTHEN | |
889 | | EXPRESSION_SIMP | |
890 | HEQV EXPRESSION_SIMP | |
891 | | EXPRESSION_SIMP | |
892 | HIMP EXPRESSION_SIMP | |
893 | | EXPRESSION_SIMP | |
894 | HOR EXPRESSION_SIMP | |
895 | | EXPRESSION_SIMP | |
896 | HAND EXPRESSION_SIMP | |
897 | | HNOT EXPRESSION_SIMP | |
898 | | EXPRESSION_SIMP | |
899 | HVALRELOPERATOR | |
900 | EXPRESSION_SIMP | |
901 | | EXPRESSION_SIMP | |
902 | HREFRELOPERATOR | |
903 | EXPRESSION_SIMP | |
904 | | EXPRESSION_SIMP | |
905 | HOBJRELOPERATOR | |
906 | EXPRESSION_SIMP | |
907 | | HTERMOPERATOR | |
908 | EXPRESSION_SIMP %prec UNEAR | |
909 | | EXPRESSION_SIMP | |
910 | HTERMOPERATOR | |
911 | EXPRESSION_SIMP | |
912 | | EXPRESSION_SIMP | |
913 | HFACTOROPERATOR | |
914 | EXPRESSION_SIMP | |
915 | | EXPRESSION_SIMP | |
916 | HPRIMARYOPERATOR | |
917 | EXPRESSION_SIMP | |
918 | | HBEGPAR | |
919 | EXPRESSION HENDPAR | |
920 | | HTEXTKONST | |
921 | | HCHARACTERKONST | |
922 | | HREALKONST | |
923 | | HINTEGERKONST | |
924 | | HBOOLEANKONST | |
925 | | HNONE | |
926 | | HIDENTIFIER | |
927 | {} | |
928 | MBEE_ARG_R_PT | |
929 | | HTHIS HIDENTIFIER | |
930 | | HNEW | |
931 | HIDENTIFIER | |
932 | ARG_R_PT | |
933 | | EXPRESSION_SIMP | |
934 | HDOT | |
935 | EXPRESSION_SIMP | |
936 | | EXPRESSION_SIMP | |
937 | HQUA HIDENTIFIER | |
938 | ; | |
affac613 | 939 | ARG_R_PT : /*EMPTY*/ |
f0064700 PE |
940 | | HBEGPAR |
941 | ARGUMENT_LIST HENDPAR | |
942 | ; | |
affac613 | 943 | MBEE_ARG_R_PT : /*EMPTY*/ |
f0064700 PE |
944 | | HBEGPAR |
945 | ARGUMENT_LIST HENDPAR | |
946 | ; | |
affac613 | 947 | ARGUMENT_LIST : EXPRESSION |
f0064700 PE |
948 | | EXPRESSION |
949 | HPAREXPSEPARATOR | |
950 | ARGUMENT_LIST | |
951 | ; | |
817e9f41 AD |
952 | %% |
953 | ]]) | |
954 | ||
955 | # Pass plenty of options, to exercise plenty of code, even if we | |
956 | # don't actually check the output. But SEGV is watching us, and | |
957 | # so might do dmalloc. | |
958 | AT_CHECK([[bison --verbose --defines input.y]], 0, [], | |
a4b746ea | 959 | [[input.y: conflicts: 78 shift/reduce, 10 reduce/reduce |
817e9f41 AD |
960 | ]]) |
961 | ||
a4b746ea PE |
962 | AT_CHECK([[grep '^State.*conflicts:' input.output]], 0, |
963 | [[State 64 conflicts: 14 shift/reduce | |
964 | State 164 conflicts: 1 shift/reduce | |
965 | State 201 conflicts: 33 shift/reduce, 4 reduce/reduce | |
966 | State 206 conflicts: 1 shift/reduce | |
967 | State 240 conflicts: 1 shift/reduce | |
968 | State 335 conflicts: 9 shift/reduce, 2 reduce/reduce | |
969 | State 356 conflicts: 1 shift/reduce | |
970 | State 360 conflicts: 9 shift/reduce, 2 reduce/reduce | |
971 | State 427 conflicts: 9 shift/reduce, 2 reduce/reduce | |
817e9f41 AD |
972 | ]]) |
973 | ||
974 | AT_CLEANUP | |
2740f169 | 975 | |
2740f169 PE |
976 | ## ----------------- ## |
977 | ## GNU pic Grammar. ## | |
978 | ## ----------------- ## | |
979 | ||
980 | AT_SETUP([GNU pic Grammar]) | |
981 | ||
982 | # GNU pic, part of groff. | |
983 | ||
984 | # Bison once reported shift/reduce conflicts that it shouldn't have. | |
985 | ||
986 | AT_DATA([[input.y]], | |
affac613 AD |
987 | [[%union {} |
988 | ||
989 | %token LABEL | |
990 | %token VARIABLE | |
991 | %token NUMBER | |
992 | %token TEXT | |
993 | %token COMMAND_LINE | |
994 | %token DELIMITED | |
995 | %token ORDINAL | |
2740f169 PE |
996 | %token TH |
997 | %token LEFT_ARROW_HEAD | |
998 | %token RIGHT_ARROW_HEAD | |
999 | %token DOUBLE_ARROW_HEAD | |
1000 | %token LAST | |
1001 | %token UP | |
1002 | %token DOWN | |
1003 | %token LEFT | |
1004 | %token RIGHT | |
1005 | %token BOX | |
1006 | %token CIRCLE | |
1007 | %token ELLIPSE | |
1008 | %token ARC | |
1009 | %token LINE | |
1010 | %token ARROW | |
1011 | %token MOVE | |
1012 | %token SPLINE | |
1013 | %token HEIGHT | |
1014 | %token RADIUS | |
1015 | %token WIDTH | |
1016 | %token DIAMETER | |
1017 | %token FROM | |
1018 | %token TO | |
1019 | %token AT | |
1020 | %token WITH | |
1021 | %token BY | |
1022 | %token THEN | |
1023 | %token SOLID | |
1024 | %token DOTTED | |
1025 | %token DASHED | |
1026 | %token CHOP | |
1027 | %token SAME | |
1028 | %token INVISIBLE | |
1029 | %token LJUST | |
1030 | %token RJUST | |
1031 | %token ABOVE | |
1032 | %token BELOW | |
1033 | %token OF | |
1034 | %token THE | |
1035 | %token WAY | |
1036 | %token BETWEEN | |
1037 | %token AND | |
1038 | %token HERE | |
1039 | %token DOT_N | |
04098407 | 1040 | %token DOT_E |
2740f169 PE |
1041 | %token DOT_W |
1042 | %token DOT_S | |
1043 | %token DOT_NE | |
1044 | %token DOT_SE | |
1045 | %token DOT_NW | |
1046 | %token DOT_SW | |
1047 | %token DOT_C | |
1048 | %token DOT_START | |
1049 | %token DOT_END | |
1050 | %token DOT_X | |
1051 | %token DOT_Y | |
1052 | %token DOT_HT | |
1053 | %token DOT_WID | |
1054 | %token DOT_RAD | |
1055 | %token SIN | |
1056 | %token COS | |
1057 | %token ATAN2 | |
1058 | %token LOG | |
1059 | %token EXP | |
1060 | %token SQRT | |
1061 | %token K_MAX | |
1062 | %token K_MIN | |
1063 | %token INT | |
1064 | %token RAND | |
1065 | %token SRAND | |
1066 | %token COPY | |
1067 | %token THRU | |
1068 | %token TOP | |
1069 | %token BOTTOM | |
1070 | %token UPPER | |
1071 | %token LOWER | |
1072 | %token SH | |
1073 | %token PRINT | |
1074 | %token CW | |
1075 | %token CCW | |
1076 | %token FOR | |
1077 | %token DO | |
1078 | %token IF | |
1079 | %token ELSE | |
1080 | %token ANDAND | |
1081 | %token OROR | |
1082 | %token NOTEQUAL | |
1083 | %token EQUALEQUAL | |
1084 | %token LESSEQUAL | |
1085 | %token GREATEREQUAL | |
1086 | %token LEFT_CORNER | |
1087 | %token RIGHT_CORNER | |
1088 | %token NORTH | |
1089 | %token SOUTH | |
1090 | %token EAST | |
1091 | %token WEST | |
1092 | %token CENTER | |
1093 | %token END | |
1094 | %token START | |
1095 | %token RESET | |
1096 | %token UNTIL | |
1097 | %token PLOT | |
1098 | %token THICKNESS | |
1099 | %token FILL | |
1100 | %token COLORED | |
1101 | %token OUTLINED | |
1102 | %token SHADED | |
1103 | %token ALIGNED | |
1104 | %token SPRINTF | |
1105 | %token COMMAND | |
1106 | ||
1107 | %left '.' | |
1108 | ||
1109 | /* this ensures that plot 17 "%g" parses as (plot 17 "%g") */ | |
1110 | %left PLOT | |
1111 | %left TEXT SPRINTF | |
1112 | ||
1113 | /* give text adjustments higher precedence than TEXT, so that | |
1114 | box "foo" above ljust == box ("foo" above ljust) | |
1115 | */ | |
1116 | ||
1117 | %left LJUST RJUST ABOVE BELOW | |
1118 | ||
1119 | %left LEFT RIGHT | |
1120 | /* Give attributes that take an optional expression a higher | |
1121 | precedence than left and right, so that eg `line chop left' | |
1122 | parses properly. */ | |
1123 | %left CHOP SOLID DASHED DOTTED UP DOWN FILL COLORED OUTLINED | |
1124 | %left LABEL | |
1125 | ||
04098407 | 1126 | %left VARIABLE NUMBER '(' SIN COS ATAN2 LOG EXP SQRT K_MAX K_MIN INT RAND SRAND LAST |
2740f169 PE |
1127 | %left ORDINAL HERE '`' |
1128 | ||
1129 | %left BOX CIRCLE ELLIPSE ARC LINE ARROW SPLINE '[' /* ] */ | |
1130 | ||
1131 | /* these need to be lower than '-' */ | |
1132 | %left HEIGHT RADIUS WIDTH DIAMETER FROM TO AT THICKNESS | |
1133 | ||
1134 | /* these must have higher precedence than CHOP so that `label %prec CHOP' | |
1135 | works */ | |
1136 | %left DOT_N DOT_E DOT_W DOT_S DOT_NE DOT_SE DOT_NW DOT_SW DOT_C | |
1137 | %left DOT_START DOT_END TOP BOTTOM LEFT_CORNER RIGHT_CORNER | |
1138 | %left UPPER LOWER NORTH SOUTH EAST WEST CENTER START END | |
1139 | ||
1140 | %left ',' | |
1141 | %left OROR | |
1142 | %left ANDAND | |
1143 | %left EQUALEQUAL NOTEQUAL | |
1144 | %left '<' '>' LESSEQUAL GREATEREQUAL | |
1145 | ||
1146 | %left BETWEEN OF | |
1147 | %left AND | |
1148 | ||
1149 | %left '+' '-' | |
1150 | %left '*' '/' '%' | |
1151 | %right '!' | |
1152 | %right '^' | |
1153 | ||
2740f169 PE |
1154 | %% |
1155 | ||
1156 | top: | |
1157 | optional_separator | |
1158 | | element_list | |
2740f169 PE |
1159 | ; |
1160 | ||
2740f169 PE |
1161 | element_list: |
1162 | optional_separator middle_element_list optional_separator | |
2740f169 PE |
1163 | ; |
1164 | ||
1165 | middle_element_list: | |
1166 | element | |
2740f169 | 1167 | | middle_element_list separator element |
2740f169 PE |
1168 | ; |
1169 | ||
1170 | optional_separator: | |
1171 | /* empty */ | |
1172 | | separator | |
1173 | ; | |
1174 | ||
1175 | separator: | |
1176 | ';' | |
1177 | | separator ';' | |
1178 | ; | |
1179 | ||
1180 | placeless_element: | |
1181 | VARIABLE '=' any_expr | |
2740f169 | 1182 | | VARIABLE ':' '=' any_expr |
2740f169 | 1183 | | UP |
2740f169 | 1184 | | DOWN |
2740f169 | 1185 | | LEFT |
2740f169 | 1186 | | RIGHT |
2740f169 | 1187 | | COMMAND_LINE |
2740f169 | 1188 | | COMMAND print_args |
2740f169 | 1189 | | PRINT print_args |
2740f169 | 1190 | | SH |
affac613 | 1191 | {} |
2740f169 | 1192 | DELIMITED |
2740f169 | 1193 | | COPY TEXT |
2740f169 | 1194 | | COPY TEXT THRU |
affac613 | 1195 | {} |
04098407 | 1196 | DELIMITED |
affac613 | 1197 | {} |
2740f169 | 1198 | until |
2740f169 | 1199 | | COPY THRU |
affac613 | 1200 | {} |
2740f169 | 1201 | DELIMITED |
affac613 | 1202 | {} |
2740f169 | 1203 | until |
2740f169 | 1204 | | FOR VARIABLE '=' expr TO expr optional_by DO |
affac613 | 1205 | {} |
2740f169 | 1206 | DELIMITED |
2740f169 | 1207 | | simple_if |
2740f169 | 1208 | | simple_if ELSE |
affac613 | 1209 | {} |
2740f169 | 1210 | DELIMITED |
2740f169 PE |
1211 | | reset_variables |
1212 | | RESET | |
2740f169 PE |
1213 | ; |
1214 | ||
1215 | reset_variables: | |
1216 | RESET VARIABLE | |
2740f169 | 1217 | | reset_variables VARIABLE |
2740f169 | 1218 | | reset_variables ',' VARIABLE |
2740f169 PE |
1219 | ; |
1220 | ||
1221 | print_args: | |
1222 | print_arg | |
2740f169 | 1223 | | print_args print_arg |
2740f169 PE |
1224 | ; |
1225 | ||
1226 | print_arg: | |
04098407 | 1227 | expr %prec ',' |
2740f169 | 1228 | | text |
2740f169 | 1229 | | position %prec ',' |
2740f169 PE |
1230 | ; |
1231 | ||
1232 | simple_if: | |
1233 | IF any_expr THEN | |
affac613 | 1234 | {} |
2740f169 | 1235 | DELIMITED |
2740f169 PE |
1236 | ; |
1237 | ||
1238 | until: | |
1239 | /* empty */ | |
2740f169 | 1240 | | UNTIL TEXT |
2740f169 | 1241 | ; |
04098407 | 1242 | |
2740f169 PE |
1243 | any_expr: |
1244 | expr | |
2740f169 | 1245 | | text_expr |
2740f169 | 1246 | ; |
04098407 | 1247 | |
2740f169 PE |
1248 | text_expr: |
1249 | text EQUALEQUAL text | |
2740f169 | 1250 | | text NOTEQUAL text |
2740f169 | 1251 | | text_expr ANDAND text_expr |
2740f169 | 1252 | | text_expr ANDAND expr |
2740f169 | 1253 | | expr ANDAND text_expr |
2740f169 | 1254 | | text_expr OROR text_expr |
2740f169 | 1255 | | text_expr OROR expr |
2740f169 | 1256 | | expr OROR text_expr |
2740f169 | 1257 | | '!' text_expr |
2740f169 PE |
1258 | ; |
1259 | ||
2740f169 PE |
1260 | optional_by: |
1261 | /* empty */ | |
2740f169 | 1262 | | BY expr |
2740f169 | 1263 | | BY '*' expr |
2740f169 PE |
1264 | ; |
1265 | ||
1266 | element: | |
1267 | object_spec | |
2740f169 | 1268 | | LABEL ':' optional_separator element |
2740f169 | 1269 | | LABEL ':' optional_separator position_not_place |
2740f169 | 1270 | | LABEL ':' optional_separator place |
affac613 AD |
1271 | | '{}' |
1272 | {} | |
2740f169 | 1273 | optional_element |
2740f169 | 1274 | | placeless_element |
2740f169 PE |
1275 | ; |
1276 | ||
1277 | optional_element: | |
1278 | /* empty */ | |
2740f169 | 1279 | | element |
2740f169 PE |
1280 | ; |
1281 | ||
1282 | object_spec: | |
1283 | BOX | |
2740f169 | 1284 | | CIRCLE |
2740f169 | 1285 | | ELLIPSE |
2740f169 | 1286 | | ARC |
2740f169 | 1287 | | LINE |
2740f169 | 1288 | | ARROW |
2740f169 | 1289 | | MOVE |
2740f169 | 1290 | | SPLINE |
2740f169 | 1291 | | text %prec TEXT |
2740f169 | 1292 | | PLOT expr |
2740f169 | 1293 | | PLOT expr text |
04098407 | 1294 | | '[' |
affac613 | 1295 | {} |
2740f169 | 1296 | element_list ']' |
2740f169 | 1297 | | object_spec HEIGHT expr |
2740f169 | 1298 | | object_spec RADIUS expr |
2740f169 | 1299 | | object_spec WIDTH expr |
2740f169 | 1300 | | object_spec DIAMETER expr |
2740f169 | 1301 | | object_spec expr %prec HEIGHT |
2740f169 | 1302 | | object_spec UP |
2740f169 | 1303 | | object_spec UP expr |
2740f169 | 1304 | | object_spec DOWN |
2740f169 | 1305 | | object_spec DOWN expr |
2740f169 | 1306 | | object_spec RIGHT |
2740f169 | 1307 | | object_spec RIGHT expr |
2740f169 | 1308 | | object_spec LEFT |
2740f169 | 1309 | | object_spec LEFT expr |
2740f169 | 1310 | | object_spec FROM position |
2740f169 | 1311 | | object_spec TO position |
2740f169 | 1312 | | object_spec AT position |
2740f169 | 1313 | | object_spec WITH path |
2740f169 | 1314 | | object_spec WITH position %prec ',' |
2740f169 | 1315 | | object_spec BY expr_pair |
2740f169 | 1316 | | object_spec THEN |
2740f169 | 1317 | | object_spec SOLID |
2740f169 | 1318 | | object_spec DOTTED |
2740f169 | 1319 | | object_spec DOTTED expr |
2740f169 | 1320 | | object_spec DASHED |
2740f169 | 1321 | | object_spec DASHED expr |
2740f169 | 1322 | | object_spec FILL |
2740f169 | 1323 | | object_spec FILL expr |
2740f169 | 1324 | | object_spec SHADED text |
2740f169 | 1325 | | object_spec COLORED text |
2740f169 | 1326 | | object_spec OUTLINED text |
2740f169 | 1327 | | object_spec CHOP |
2740f169 | 1328 | | object_spec CHOP expr |
2740f169 | 1329 | | object_spec SAME |
2740f169 | 1330 | | object_spec INVISIBLE |
2740f169 | 1331 | | object_spec LEFT_ARROW_HEAD |
2740f169 | 1332 | | object_spec RIGHT_ARROW_HEAD |
2740f169 | 1333 | | object_spec DOUBLE_ARROW_HEAD |
2740f169 | 1334 | | object_spec CW |
2740f169 | 1335 | | object_spec CCW |
2740f169 | 1336 | | object_spec text %prec TEXT |
2740f169 | 1337 | | object_spec LJUST |
2740f169 | 1338 | | object_spec RJUST |
2740f169 | 1339 | | object_spec ABOVE |
2740f169 | 1340 | | object_spec BELOW |
2740f169 | 1341 | | object_spec THICKNESS expr |
2740f169 | 1342 | | object_spec ALIGNED |
2740f169 PE |
1343 | ; |
1344 | ||
1345 | text: | |
1346 | TEXT | |
2740f169 | 1347 | | SPRINTF '(' TEXT sprintf_args ')' |
2740f169 PE |
1348 | ; |
1349 | ||
1350 | sprintf_args: | |
1351 | /* empty */ | |
2740f169 | 1352 | | sprintf_args ',' expr |
2740f169 PE |
1353 | ; |
1354 | ||
1355 | position: | |
04098407 | 1356 | position_not_place |
2740f169 | 1357 | | place |
2740f169 PE |
1358 | ; |
1359 | ||
1360 | position_not_place: | |
1361 | expr_pair | |
2740f169 | 1362 | | position '+' expr_pair |
2740f169 | 1363 | | position '-' expr_pair |
2740f169 | 1364 | | '(' position ',' position ')' |
2740f169 | 1365 | | expr between position AND position |
2740f169 | 1366 | | expr '<' position ',' position '>' |
2740f169 PE |
1367 | ; |
1368 | ||
1369 | between: | |
1370 | BETWEEN | |
1371 | | OF THE WAY BETWEEN | |
1372 | ; | |
1373 | ||
1374 | expr_pair: | |
1375 | expr ',' expr | |
2740f169 | 1376 | | '(' expr_pair ')' |
2740f169 PE |
1377 | ; |
1378 | ||
1379 | place: | |
1380 | /* line at A left == line (at A) left */ | |
1381 | label %prec CHOP | |
2740f169 | 1382 | | label corner |
2740f169 | 1383 | | corner label |
2740f169 | 1384 | | corner OF label |
2740f169 | 1385 | | HERE |
2740f169 PE |
1386 | ; |
1387 | ||
1388 | label: | |
1389 | LABEL | |
2740f169 | 1390 | | nth_primitive |
2740f169 | 1391 | | label '.' LABEL |
2740f169 PE |
1392 | ; |
1393 | ||
1394 | ordinal: | |
1395 | ORDINAL | |
2740f169 | 1396 | | '`' any_expr TH |
2740f169 PE |
1397 | ; |
1398 | ||
1399 | optional_ordinal_last: | |
1400 | LAST | |
04098407 | 1401 | | ordinal LAST |
2740f169 PE |
1402 | ; |
1403 | ||
1404 | nth_primitive: | |
1405 | ordinal object_type | |
2740f169 | 1406 | | optional_ordinal_last object_type |
2740f169 PE |
1407 | ; |
1408 | ||
1409 | object_type: | |
1410 | BOX | |
2740f169 | 1411 | | CIRCLE |
2740f169 | 1412 | | ELLIPSE |
2740f169 | 1413 | | ARC |
2740f169 | 1414 | | LINE |
2740f169 | 1415 | | ARROW |
2740f169 | 1416 | | SPLINE |
2740f169 | 1417 | | '[' ']' |
2740f169 | 1418 | | TEXT |
2740f169 PE |
1419 | ; |
1420 | ||
1421 | label_path: | |
04098407 | 1422 | '.' LABEL |
2740f169 | 1423 | | label_path '.' LABEL |
2740f169 PE |
1424 | ; |
1425 | ||
1426 | relative_path: | |
1427 | corner %prec CHOP | |
2740f169 PE |
1428 | /* give this a lower precedence than LEFT and RIGHT so that |
1429 | [A: box] with .A left == [A: box] with (.A left) */ | |
04098407 | 1430 | | label_path %prec TEXT |
2740f169 | 1431 | | label_path corner |
2740f169 PE |
1432 | ; |
1433 | ||
1434 | path: | |
1435 | relative_path | |
2740f169 | 1436 | | '(' relative_path ',' relative_path ')' |
affac613 | 1437 | {} |
2740f169 PE |
1438 | /* The rest of these rules are a compatibility sop. */ |
1439 | | ORDINAL LAST object_type relative_path | |
2740f169 | 1440 | | LAST object_type relative_path |
2740f169 | 1441 | | ORDINAL object_type relative_path |
2740f169 | 1442 | | LABEL relative_path |
2740f169 PE |
1443 | ; |
1444 | ||
1445 | corner: | |
1446 | DOT_N | |
04098407 | 1447 | | DOT_E |
2740f169 | 1448 | | DOT_W |
2740f169 | 1449 | | DOT_S |
2740f169 | 1450 | | DOT_NE |
2740f169 | 1451 | | DOT_SE |
2740f169 | 1452 | | DOT_NW |
2740f169 | 1453 | | DOT_SW |
2740f169 | 1454 | | DOT_C |
2740f169 | 1455 | | DOT_START |
2740f169 | 1456 | | DOT_END |
04098407 | 1457 | | TOP |
2740f169 | 1458 | | BOTTOM |
2740f169 | 1459 | | LEFT |
2740f169 | 1460 | | RIGHT |
2740f169 | 1461 | | UPPER LEFT |
2740f169 | 1462 | | LOWER LEFT |
2740f169 | 1463 | | UPPER RIGHT |
2740f169 | 1464 | | LOWER RIGHT |
2740f169 | 1465 | | LEFT_CORNER |
2740f169 | 1466 | | RIGHT_CORNER |
2740f169 | 1467 | | UPPER LEFT_CORNER |
2740f169 | 1468 | | LOWER LEFT_CORNER |
2740f169 | 1469 | | UPPER RIGHT_CORNER |
2740f169 | 1470 | | LOWER RIGHT_CORNER |
2740f169 | 1471 | | NORTH |
2740f169 | 1472 | | SOUTH |
2740f169 | 1473 | | EAST |
2740f169 | 1474 | | WEST |
2740f169 | 1475 | | CENTER |
2740f169 | 1476 | | START |
2740f169 | 1477 | | END |
2740f169 PE |
1478 | ; |
1479 | ||
1480 | expr: | |
1481 | VARIABLE | |
2740f169 | 1482 | | NUMBER |
2740f169 | 1483 | | place DOT_X |
2740f169 | 1484 | | place DOT_Y |
2740f169 | 1485 | | place DOT_HT |
2740f169 | 1486 | | place DOT_WID |
2740f169 | 1487 | | place DOT_RAD |
2740f169 | 1488 | | expr '+' expr |
2740f169 | 1489 | | expr '-' expr |
2740f169 | 1490 | | expr '*' expr |
2740f169 | 1491 | | expr '/' expr |
2740f169 | 1492 | | expr '%' expr |
2740f169 | 1493 | | expr '^' expr |
2740f169 | 1494 | | '-' expr %prec '!' |
2740f169 | 1495 | | '(' any_expr ')' |
2740f169 | 1496 | | SIN '(' any_expr ')' |
2740f169 | 1497 | | COS '(' any_expr ')' |
2740f169 | 1498 | | ATAN2 '(' any_expr ',' any_expr ')' |
2740f169 | 1499 | | LOG '(' any_expr ')' |
2740f169 | 1500 | | EXP '(' any_expr ')' |
2740f169 | 1501 | | SQRT '(' any_expr ')' |
2740f169 | 1502 | | K_MAX '(' any_expr ',' any_expr ')' |
2740f169 | 1503 | | K_MIN '(' any_expr ',' any_expr ')' |
2740f169 | 1504 | | INT '(' any_expr ')' |
2740f169 | 1505 | | RAND '(' any_expr ')' |
2740f169 | 1506 | | RAND '(' ')' |
2740f169 | 1507 | | SRAND '(' any_expr ')' |
2740f169 | 1508 | | expr '<' expr |
2740f169 | 1509 | | expr LESSEQUAL expr |
2740f169 | 1510 | | expr '>' expr |
2740f169 | 1511 | | expr GREATEREQUAL expr |
2740f169 | 1512 | | expr EQUALEQUAL expr |
2740f169 | 1513 | | expr NOTEQUAL expr |
2740f169 | 1514 | | expr ANDAND expr |
2740f169 | 1515 | | expr OROR expr |
2740f169 | 1516 | | '!' expr |
2740f169 PE |
1517 | ; |
1518 | ]]) | |
1519 | ||
1520 | # Pass plenty of options, to exercise plenty of code, even if we | |
1521 | # don't actually check the output. But SEGV is watching us, and | |
1522 | # so might do dmalloc. | |
5967f0cf JD |
1523 | AT_CHECK([[bison --verbose --defines input.y]], 0, [], |
1524 | [[input.y:453.11-48: warning: rule never reduced because of conflicts: path: ORDINAL LAST object_type relative_path | |
1525 | ]]) | |
2740f169 PE |
1526 | |
1527 | AT_CLEANUP |