]>
Commit | Line | Data |
---|---|---|
817e9f41 AD |
1 | # Exercising Bison on actual grammars. -*- Autotest -*- |
2 | # Copyright (C) 2002 Free Software Foundation, Inc. | |
3 | ||
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2, or (at your option) | |
7 | # any later version. | |
8 | ||
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | ||
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
17 | # 02111-1307, USA. | |
18 | ||
19 | AT_BANNER([[Existing Grammars.]]) | |
20 | ## ----------------- ## | |
21 | ## GNU AWK Grammar. ## | |
22 | ## ----------------- ## | |
23 | ||
24 | AT_SETUP([GNU AWK Grammar]) | |
25 | ||
26 | # We have been careful to strip all the actions excepts the | |
27 | # mid-rule actions. We rely on %expect to check that there are | |
28 | # indeed 65 SR conflicts. | |
29 | # | |
30 | # Bison was once wrong, due to an incorrect computation of nullable. | |
31 | # It reported 485 SR conflicts! | |
32 | ||
33 | AT_DATA([[input.y]], | |
34 | [[%expect 65 | |
35 | ||
36 | %token FUNC_CALL NAME REGEXP | |
37 | %token ERROR | |
38 | %token YNUMBER YSTRING | |
39 | %token RELOP APPEND_OP | |
40 | %token ASSIGNOP MATCHOP NEWLINE CONCAT_OP | |
41 | %token LEX_BEGIN LEX_END LEX_IF LEX_ELSE LEX_RETURN LEX_DELETE | |
42 | %token LEX_WHILE LEX_DO LEX_FOR LEX_BREAK LEX_CONTINUE | |
43 | %token LEX_PRINT LEX_PRINTF LEX_NEXT LEX_EXIT LEX_FUNCTION | |
44 | %token LEX_GETLINE LEX_NEXTFILE | |
45 | %token LEX_IN | |
46 | %token LEX_AND LEX_OR INCREMENT DECREMENT | |
47 | %token LEX_BUILTIN LEX_LENGTH | |
48 | ||
49 | /* Lowest to highest */ | |
50 | %right ASSIGNOP | |
51 | %right '?' ':' | |
52 | %left LEX_OR | |
53 | %left LEX_AND | |
54 | %left LEX_GETLINE | |
55 | %nonassoc LEX_IN | |
56 | %left FUNC_CALL LEX_BUILTIN LEX_LENGTH | |
57 | %nonassoc ',' | |
58 | %nonassoc MATCHOP | |
59 | %nonassoc RELOP '<' '>' '|' APPEND_OP TWOWAYIO | |
60 | %left CONCAT_OP | |
61 | %left YSTRING YNUMBER | |
62 | %left '+' '-' | |
63 | %left '*' '/' '%' | |
64 | %right '!' UNARY | |
65 | %right '^' | |
66 | %left INCREMENT DECREMENT | |
67 | %left '$' | |
68 | %left '(' ')' | |
69 | %% | |
70 | ||
71 | start | |
72 | : opt_nls program opt_nls | |
73 | ; | |
74 | ||
75 | program | |
76 | : rule | |
77 | | program rule | |
78 | | error | |
79 | | program error | |
80 | | /* empty */ | |
81 | ; | |
82 | ||
83 | rule | |
84 | : LEX_BEGIN {} action | |
85 | | LEX_END {} action | |
86 | | LEX_BEGIN statement_term | |
87 | | LEX_END statement_term | |
88 | | pattern action | |
89 | | action | |
90 | | pattern statement_term | |
91 | | function_prologue function_body | |
92 | ; | |
93 | ||
94 | func_name | |
95 | : NAME | |
96 | | FUNC_CALL | |
97 | | lex_builtin | |
98 | ; | |
99 | ||
100 | lex_builtin | |
101 | : LEX_BUILTIN | |
102 | | LEX_LENGTH | |
103 | ; | |
104 | ||
105 | function_prologue | |
106 | : LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls | |
107 | ; | |
108 | ||
109 | function_body | |
110 | : l_brace statements r_brace opt_semi opt_nls | |
111 | | l_brace r_brace opt_semi opt_nls | |
112 | ; | |
113 | ||
114 | ||
115 | pattern | |
116 | : exp | |
117 | | exp ',' exp | |
118 | ; | |
119 | ||
120 | regexp | |
121 | /* | |
122 | * In this rule, want_regexp tells yylex that the next thing | |
123 | * is a regexp so it should read up to the closing slash. | |
124 | */ | |
125 | : '/' {} REGEXP '/' | |
126 | ; | |
127 | ||
128 | action | |
129 | : l_brace statements r_brace opt_semi opt_nls | |
130 | | l_brace r_brace opt_semi opt_nls | |
131 | ; | |
132 | ||
133 | statements | |
134 | : statement | |
135 | | statements statement | |
136 | | error | |
137 | | statements error | |
138 | ; | |
139 | ||
140 | statement_term | |
141 | : nls | |
142 | | semi opt_nls | |
143 | ; | |
144 | ||
145 | statement | |
146 | : semi opt_nls | |
147 | | l_brace r_brace | |
148 | | l_brace statements r_brace | |
149 | | if_statement | |
150 | | LEX_WHILE '(' exp r_paren opt_nls statement | |
151 | | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls | |
152 | | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement | |
153 | | LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement | |
154 | | LEX_FOR '(' opt_exp semi opt_nls semi opt_nls opt_exp r_paren opt_nls statement | |
155 | | LEX_BREAK statement_term | |
156 | | LEX_CONTINUE statement_term | |
157 | | print '(' expression_list r_paren output_redir statement_term | |
158 | | print opt_rexpression_list output_redir statement_term | |
159 | | LEX_NEXT statement_term | |
160 | | LEX_NEXTFILE statement_term | |
161 | | LEX_EXIT opt_exp statement_term | |
162 | | LEX_RETURN {} opt_exp statement_term | |
163 | | LEX_DELETE NAME '[' expression_list ']' statement_term | |
164 | | LEX_DELETE NAME statement_term | |
165 | | exp statement_term | |
166 | ; | |
167 | ||
168 | ||
169 | : LEX_PRINT | |
170 | | LEX_PRINTF | |
171 | ; | |
172 | ||
173 | if_statement | |
174 | : LEX_IF '(' exp r_paren opt_nls statement | |
175 | | LEX_IF '(' exp r_paren opt_nls statement | |
176 | LEX_ELSE opt_nls statement | |
177 | ; | |
178 | ||
179 | nls | |
180 | : NEWLINE | |
181 | | nls NEWLINE | |
182 | ; | |
183 | ||
184 | opt_nls | |
185 | : /* empty */ | |
186 | | nls | |
187 | ; | |
188 | ||
189 | input_redir | |
190 | : /* empty */ | |
191 | | '<' simp_exp | |
192 | ; | |
193 | ||
194 | output_redir | |
195 | : /* empty */ | |
196 | | '>' exp | |
197 | | APPEND_OP exp | |
198 | | '|' exp | |
199 | | TWOWAYIO exp | |
200 | ; | |
201 | ||
202 | opt_param_list | |
203 | : /* empty */ | |
204 | | param_list | |
205 | ; | |
206 | ||
207 | param_list | |
208 | : NAME | |
209 | | param_list comma NAME | |
210 | | error | |
211 | | param_list error | |
212 | | param_list comma error | |
213 | ; | |
214 | ||
215 | /* optional expression, as in for loop */ | |
216 | opt_exp | |
217 | : /* empty */ | |
218 | | exp | |
219 | ; | |
220 | ||
221 | opt_rexpression_list | |
222 | : /* empty */ | |
223 | | rexpression_list | |
224 | ; | |
225 | ||
226 | rexpression_list | |
227 | : rexp | |
228 | | rexpression_list comma rexp | |
229 | | error | |
230 | | rexpression_list error | |
231 | | rexpression_list error rexp | |
232 | | rexpression_list comma error | |
233 | ; | |
234 | ||
235 | opt_expression_list | |
236 | : /* empty */ | |
237 | | expression_list | |
238 | ; | |
239 | ||
240 | expression_list | |
241 | : exp | |
242 | | expression_list comma exp | |
243 | | error | |
244 | | expression_list error | |
245 | | expression_list error exp | |
246 | | expression_list comma error | |
247 | ; | |
248 | ||
249 | /* Expressions, not including the comma operator. */ | |
250 | exp : variable ASSIGNOP {} exp | |
251 | | '(' expression_list r_paren LEX_IN NAME | |
252 | | exp '|' LEX_GETLINE opt_variable | |
253 | | exp TWOWAYIO LEX_GETLINE opt_variable | |
254 | | LEX_GETLINE opt_variable input_redir | |
255 | | exp LEX_AND exp | |
256 | | exp LEX_OR exp | |
257 | | exp MATCHOP exp | |
258 | | regexp | |
259 | | '!' regexp %prec UNARY | |
260 | | exp LEX_IN NAME | |
261 | | exp RELOP exp | |
262 | | exp '<' exp | |
263 | | exp '>' exp | |
264 | | exp '?' exp ':' exp | |
265 | | simp_exp | |
266 | | exp simp_exp %prec CONCAT_OP | |
267 | ; | |
268 | ||
269 | rexp | |
270 | : variable ASSIGNOP {} rexp | |
271 | | rexp LEX_AND rexp | |
272 | | rexp LEX_OR rexp | |
273 | | LEX_GETLINE opt_variable input_redir | |
274 | | regexp | |
275 | | '!' regexp %prec UNARY | |
276 | | rexp MATCHOP rexp | |
277 | | rexp LEX_IN NAME | |
278 | | rexp RELOP rexp | |
279 | | rexp '?' rexp ':' rexp | |
280 | | simp_exp | |
281 | | rexp simp_exp %prec CONCAT_OP | |
282 | ; | |
283 | ||
284 | simp_exp | |
285 | : non_post_simp_exp | |
286 | /* Binary operators in order of decreasing precedence. */ | |
287 | | simp_exp '^' simp_exp | |
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 | | variable INCREMENT | |
294 | | variable DECREMENT | |
295 | ; | |
296 | ||
297 | non_post_simp_exp | |
298 | : '!' simp_exp %prec UNARY | |
299 | | '(' exp r_paren | |
300 | | LEX_BUILTIN | |
301 | '(' opt_expression_list r_paren | |
302 | | LEX_LENGTH '(' opt_expression_list r_paren | |
303 | | LEX_LENGTH | |
304 | | FUNC_CALL '(' opt_expression_list r_paren | |
305 | | variable | |
306 | | INCREMENT variable | |
307 | | DECREMENT variable | |
308 | | YNUMBER | |
309 | | YSTRING | |
310 | | '-' simp_exp %prec UNARY | |
311 | | '+' simp_exp %prec UNARY | |
312 | ; | |
313 | ||
314 | opt_variable | |
315 | : /* empty */ | |
316 | | variable | |
317 | ; | |
318 | ||
319 | variable | |
320 | : NAME | |
321 | | NAME '[' expression_list ']' | |
322 | | '$' non_post_simp_exp | |
323 | ; | |
324 | ||
325 | l_brace | |
326 | : '{' opt_nls | |
327 | ; | |
328 | ||
329 | r_brace | |
330 | : '}' opt_nls | |
331 | ; | |
332 | ||
333 | r_paren | |
334 | : ')' | |
335 | ; | |
336 | ||
337 | opt_semi | |
338 | : /* empty */ | |
339 | | semi | |
340 | ; | |
341 | ||
342 | semi | |
343 | : ';' | |
344 | ; | |
345 | ||
346 | comma : ',' opt_nls | |
347 | ; | |
348 | ||
349 | %% | |
350 | ]]) | |
351 | ||
352 | # Pass plenty of options, to exercise plenty of code, even if we | |
353 | # don't actually check the output. But SEGV is watching us, and | |
354 | # so might do dmalloc. | |
355 | AT_CHECK([[bison --verbose --defines input.y]]) | |
356 | ||
357 | AT_CLEANUP | |
358 | ||
359 | ||
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]], | |
372 | [[%union { | |
373 | long token; | |
374 | long ival; | |
375 | long arrdim; | |
376 | double rval; | |
377 | char *ident; | |
378 | char *tval; | |
379 | char stat_decl; | |
380 | } | |
381 | ||
382 | %token | |
383 | HACTIVATE HAFTER /*HAND*/ HARRAY HAT | |
384 | HBEFORE HBEGIN HBOOLEAN | |
385 | HCHARACTER HCLASS /*HCOMMENT*/ HCONC | |
386 | HDELAY HDO | |
387 | HELSE HEND HEQ /*HEQV*/ HEXTERNAL | |
388 | HFOR | |
389 | HGE HGO HGOTO HGT | |
390 | HHIDDEN | |
391 | HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS | |
392 | HLABEL HLE HLONG HLT | |
393 | HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT | |
394 | /*HOR*/ HOTHERWISE | |
395 | HPRIOR HPROCEDURE HPROTECTED | |
396 | HQUA | |
397 | HREACTIVATE HREAL HREF | |
398 | HSHORT HSTEP HSWITCH | |
399 | HTEXT HTHEN HTHIS HTO | |
400 | HUNTIL | |
401 | HVALUE HVAR HVIRTUAL | |
402 | HWHEN HWHILE | |
403 | ||
404 | HASSIGNVALUE HASSIGNREF | |
405 | /*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR | |
406 | HBEGPAR HENDPAR | |
407 | HEQR HNER | |
408 | HADD HSUB HMUL HDIV HINTDIV HEXP | |
409 | HDOTDOTDOT | |
410 | ||
411 | %token <ident> HIDENTIFIER | |
412 | %token <ival> HBOOLEANKONST HINTEGERKONST HCHARACTERKONST | |
413 | %token <rval> HREALKONST | |
414 | %token <tval> HTEXTKONST | |
415 | ||
416 | %type <tval> EXT_IDENT | |
417 | %type <stat_decl> DECLSTATEMENT MODULSTATEMENT MBEE_DECLSTMS MBEE_DECLSTMSU | |
418 | %type <stat_decl> MODULS | |
419 | %type <ident> EXPRESSION_SIMP MBEE_ARG_R_PT | |
420 | %type <arrdim> BAUND_PAIR_LIST | |
421 | ||
422 | %right <token> HASSIGN | |
423 | %left HORELSE | |
424 | %left HANDTHEN | |
425 | %left HEQV | |
426 | %left HIMP | |
427 | %left HOR | |
428 | %left HAND | |
429 | ||
430 | %left HNOT | |
431 | ||
432 | %left <token> HVALRELOPERATOR HREFRELOPERATOR HOBJRELOPERATOR | |
433 | ||
434 | %left HCONC | |
435 | ||
436 | %left <token> HTERMOPERATOR | |
437 | %left <token> UNEAR | |
438 | %left <token> HFACTOROPERATOR | |
439 | %left HPRIMARYOPERATOR | |
440 | ||
441 | %left HQUA | |
442 | ||
443 | %left HDOT | |
444 | ||
445 | %start MAIN_MODULE | |
446 | %% | |
447 | /* GRAMATIKK FOR PROGRAM MODULES */ | |
448 | MAIN_MODULE : { categ=CLOCAL; mout(MBLOCK); | |
449 | beginBlock(KBLOKK);separat_comp=FALSE;} | |
450 | MODULS { endBlock(NULL,CCNO); mout(MENDBLOCK);} | |
451 | | error HSTATEMENTSEPARATOR MBEE_DECLSTMS | |
452 | ; | |
453 | EXT_DECLARATION : HEXTERNAL | |
454 | MBEE_TYPE | |
455 | HPROCEDURE | |
456 | { MBEENEWBLOCK(); | |
457 | kind=KPROC;} | |
458 | EXT_LIST | |
459 | | | |
460 | HEXTERNAL | |
461 | HIDENTIFIER | |
462 | HPROCEDURE | |
463 | { MBEENEWBLOCK(); | |
464 | type=TNOTY; | |
465 | kind=KPROC; | |
466 | if($2==Ckind)categ=CCPROC;else | |
467 | yerror (1); | |
468 | ysensitive=sensitive; | |
469 | sensitive=ON;} | |
470 | HIDENTIFIER { $<ident>$=$5; | |
471 | sensitive=ysensitive;} | |
472 | EXTERNAL_KIND_ITEM | |
473 | { categ=CLOCAL;} | |
474 | | HEXTERNAL | |
475 | HCLASS | |
476 | { MBEENEWBLOCK(); | |
477 | kind=KCLASS;} | |
478 | EXT_LIST | |
479 | ||
480 | ; | |
481 | EXTERNAL_KIND_ITEM: EXT_IDENT | |
482 | HOBJRELOPERATOR | |
483 | { if($2!=HIS)yerror (2);} | |
484 | MBEE_TYPE HPROCEDURE | |
485 | HIDENTIFIER | |
486 | { regDecl($6, type, KPROC, CCPROC); | |
487 | beginBlock(kind);} | |
488 | HEADING EMPTY_BLOCK | |
489 | { categ=CLOCAL; | |
490 | endBlock($1==NULL?$<ident>0:tag($1),CCCPROC);} | |
491 | /* | | |
492 | EXT_IDENT | |
493 | { if($1!=NULL)yerror (3); | |
494 | regDecl($0, type, kind, categ);} | |
495 | MBEE_REST_EXT_LIST | |
496 | { endBlock(NULL,CCNO);} | |
497 | ; | |
498 | MBEE_REST_EXT_LIST: /* EMPTY | |
499 | | HPAREXPSEPARATOR EXT_KIND_LIST | |
500 | ; | |
501 | EXT_KIND_LIST : EXT_KIND_ITEM | |
502 | | EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM | |
503 | ; | |
504 | EXT_KIND_ITEM : HIDENTIFIER | |
505 | EXT_IDENT | |
506 | { if($2!=NULL)yerror (3); | |
507 | regDecl($1, type, kind, categ);}*/ | |
508 | ; | |
509 | EMPTY_BLOCK : /*EMPT*/ | |
510 | | HBEGIN HEND | |
511 | ; | |
512 | EXT_LIST : EXT_ITEM | |
513 | | EXT_LIST HPAREXPSEPARATOR EXT_ITEM | |
514 | ; | |
515 | EXT_ITEM : HIDENTIFIER | |
516 | EXT_IDENT | |
517 | { lesinn_external_spec($1,$2, kind);} | |
518 | ; | |
519 | EXT_IDENT : /* EMPTY */ { $$=NULL;} | |
520 | | HVALRELOPERATOR { if($1!=HEQ)yerror (9); | |
521 | external=TRUE;} | |
522 | HTEXTKONST { $$=$3;external=FALSE;} | |
523 | ; | |
524 | /* GRAMATIKK FOR TYPER */ | |
525 | NO_TYPE : /*EMPT*/ { type=TNOTY;} | |
526 | ; | |
527 | MBEE_TYPE : NO_TYPE | |
528 | | TYPE | |
529 | ; | |
530 | TYPE : HREF HBEGPAR | |
531 | HIDENTIFIER | |
532 | { prefquantident=$3; | |
533 | type=TREF;} | |
534 | HENDPAR | |
535 | | HTEXT { type=TTEXT;} | |
536 | | HBOOLEAN { type=TBOOL;} | |
537 | | HCHARACTER { type=TCHAR;} | |
538 | | HSHORT HINTEGER { type=TSHORT;} | |
539 | | HINTEGER { type=TINTG;} | |
540 | | HREAL { type=TREAL;} | |
541 | | HLONG HREAL { type=TLONG;} | |
542 | ; | |
543 | ||
544 | /* GRAMATIKK FOR DEL AV SETNINGER */ | |
545 | MBEE_ELSE_PART : /*EMPT*/ | |
546 | /* | HELSE | |
547 | HIF | |
548 | EXPRESSION | |
549 | HTHEN { mout(MELSE); | |
550 | mout(MIF); | |
551 | OBSBLOCK();} | |
552 | BLOCK { MBEEENDBLOCK();} | |
553 | MBEE_ELSE_PART { mout(MENDIF);}*/ | |
554 | | HELSE { OBSBLOCK(); mout(MELSE);} | |
555 | BLOCK { MBEEENDBLOCK();} | |
556 | ; | |
557 | FOR_LIST : FOR_LIST_ELEMENT { mout(MENDSEP); | |
558 | mout(MLISTSEP);} | |
559 | | FOR_LIST_ELEMENT | |
560 | HPAREXPSEPARATOR | |
561 | FOR_LIST { mout(MLISTSEP);} | |
562 | ; | |
563 | FOR_LIST_ELEMENT: EXPRESSION | |
564 | MBEE_F_L_EL_R_PT | |
565 | ; | |
566 | MBEE_F_L_EL_R_PT: /*EMPT*/ | |
567 | | HWHILE | |
568 | EXPRESSION { mout(MFORWHILE);} | |
569 | | HSTEP | |
570 | EXPRESSION | |
571 | HUNTIL | |
572 | EXPRESSION { mout(MUNTIL); | |
573 | mout(MSTEP);} | |
574 | ; | |
575 | GOTO : HGO | |
576 | HTO | |
577 | | HGOTO | |
578 | ; | |
579 | CONN_STATE_R_PT : WHEN_CLAUSE_LIST | |
580 | | HDO { beginBlock(KCON); mout(MDO); | |
581 | OBSBLOCK(); } | |
582 | BLOCK { endBlock(NULL,CCNO); | |
583 | MBEEENDBLOCK(); mout(MENDDO);} | |
584 | ; | |
585 | WHEN_CLAUSE_LIST: HWHEN | |
586 | HIDENTIFIER | |
587 | HDO { beginBlock(KCON); mout(MIDENTIFIER); | |
588 | OBSBLOCK(); moutId($2); | |
589 | mout(MWHEN);} | |
590 | BLOCK { endBlock(NULL,CCNO); | |
591 | MBEEENDBLOCK(); mout(MENDWHEN);} | |
592 | | WHEN_CLAUSE_LIST | |
593 | HWHEN | |
594 | HIDENTIFIER | |
595 | HDO { beginBlock(KCON); mout(MIDENTIFIER); | |
596 | OBSBLOCK(); moutId($3); | |
597 | mout(MWHEN);} | |
598 | BLOCK { endBlock(NULL,CCNO); | |
599 | MBEEENDBLOCK(); mout(MENDWHEN);} | |
600 | ; | |
601 | MBEE_OTWI_CLAUS : /*EMPT*/ | |
602 | | HOTHERWISE {OBSBLOCK(); mout(MOTHERWISE);} | |
603 | ||
604 | BLOCK {MBEEENDBLOCK();mout(MENDOTHERWISE);} | |
605 | ; | |
606 | ACTIVATOR : HACTIVATE { mout(MBOOLEANKONST); | |
607 | moutIval(FALSE);} | |
608 | | HREACTIVATE { mout(MBOOLEANKONST); | |
609 | moutIval(TRUE);} | |
610 | ; | |
611 | SCHEDULE : /*EMPT*/ { mout(MCHARACTERKONST); | |
612 | moutIval(DIRECT); | |
613 | mout(MINTEGERKONST); | |
614 | moutIval(0); | |
615 | mout(MNONE); | |
616 | mout(MBOOLEANKONST); | |
617 | moutIval(FALSE);} | |
618 | | ATDELAY EXPRESSION { mout(MNONE);} | |
619 | PRIOR | |
620 | | BEFOREAFTER { mout(MINTEGERKONST); | |
621 | moutIval(0);} | |
622 | EXPRESSION { mout(MBOOLEANKONST); | |
623 | moutIval(FALSE);} | |
624 | ; | |
625 | ATDELAY : HAT { mout(MCHARACTERKONST); | |
626 | moutIval(AT);} | |
627 | | HDELAY { mout(MCHARACTERKONST); | |
628 | moutIval(DELAYS);} | |
629 | ; | |
630 | BEFOREAFTER : HBEFORE { mout(MCHARACTERKONST); | |
631 | moutIval(BEFORE);} | |
632 | | HAFTER { mout(MCHARACTERKONST); | |
633 | moutIval(AFTER);} | |
634 | ; | |
635 | PRIOR : /*EMPT*/ { mout(MBOOLEANKONST); | |
636 | moutIval(FALSE);} | |
637 | | HPRIOR { mout(MBOOLEANKONST); | |
638 | moutIval(TRUE);} | |
639 | ; | |
640 | /* GRAMATIKK FOR SETNINGER OG DEKLARASJONER */ | |
641 | MODULSTATEMENT : HWHILE | |
642 | EXPRESSION | |
643 | HDO { STOPOBSBLOCK(); mout(MWHILE); | |
644 | OBSBLOCK();} | |
645 | BLOCK { MBEEENDBLOCK(); mout(MENDWHILE); | |
646 | $$=STATEMENT;} | |
647 | | HIF | |
648 | EXPRESSION | |
649 | HTHEN { STOPOBSBLOCK(); mout(MIF); | |
650 | OBSBLOCK();} | |
651 | BLOCK { MBEEENDBLOCK();} | |
652 | MBEE_ELSE_PART { mout(MENDIF); | |
653 | $$=STATEMENT;} | |
654 | | HFOR | |
655 | HIDENTIFIER | |
656 | HASSIGN { STOPOBSBLOCK(); mout(MIDENTIFIER); | |
657 | moutId($2);} | |
658 | FOR_LIST | |
659 | HDO { beginBlock(KFOR); | |
660 | if($3==HASSIGNVALUE) mout(MFOR); | |
661 | else mout(MFORR); | |
662 | OBSBLOCK(); mout(MFORDO);} | |
663 | BLOCK { MBEEENDBLOCK(); | |
664 | endBlock(NULL,CCNO); mout(MENDFOR); | |
665 | $$=STATEMENT;} | |
666 | | GOTO | |
667 | EXPRESSION { mout(MGOTO); | |
668 | STOPOBSBLOCK(); $$=STATEMENT;} | |
669 | | HINSPECT | |
670 | EXPRESSION { mout(MINSPECT); | |
671 | STOPOBSBLOCK(); | |
672 | beginBlock(KINSP);} | |
673 | CONN_STATE_R_PT | |
674 | { endBlock(NULL,CCNO);} | |
675 | MBEE_OTWI_CLAUS { mout(MENDINSPECT); | |
676 | $$=STATEMENT;} | |
677 | | HINNER { STOPOBSBLOCK(); mout(MINNER); | |
678 | regInner(); $$=STATEMENT;} | |
679 | | HIDENTIFIER | |
680 | HLABELSEPARATOR | |
681 | { STOPOBSBLOCK(); | |
682 | regDecl($1, TLABEL, KSIMPLE, categ); mout(MLABEL); | |
683 | moutId($1); | |
684 | mout(MENDLABEL);} | |
685 | DECLSTATEMENT { if($4<=DECLARATION) | |
686 | { yerror (27); | |
687 | $$=DECLARATION;} | |
688 | else $$=$4;} | |
689 | | EXPRESSION_SIMP | |
690 | HBEGIN | |
691 | { $<ident>$=$1; } | |
692 | IMPORT_SPEC_MODULE | |
693 | { mout(MPRBLOCK); | |
694 | prefquantident=$1; | |
695 | beginBlock(KPRBLK);} | |
696 | MBEE_DECLSTMS | |
697 | HEND { endBlock(NULL,CCNO); mout(MENDPRBLOCK); | |
698 | $$=STATEMENT;} | |
699 | | EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR | |
700 | MBEE_DECLSTMS HEND { $$=STATEMENT; | |
701 | endBlock(NULL,CCNO); mout(MENDPRBLOCK);} | |
702 | | EXPRESSION_SIMP HBEGIN error HEND | |
703 | { $$=STATEMENT; | |
704 | endBlock(NULL,CCNO); mout(MENDPRBLOCK);} | |
705 | ||
706 | | EXPRESSION_SIMP | |
707 | { STOPOBSBLOCK(); $$=STATEMENT; | |
708 | mout(MENDASSIGN);} | |
709 | | ACTIVATOR EXPRESSION SCHEDULE | |
710 | { $$=STATEMENT; | |
711 | mout(MENDSEP); | |
712 | mout(MARGUMENTSEP); | |
713 | mout(MARGUMENTSEP); | |
714 | mout(MARGUMENTSEP); | |
715 | mout(MARGUMENTSEP); | |
716 | mout(MARGUMENTSEP); | |
717 | mout(MARGUMENTSEP); | |
718 | mout(MARGUMENT); | |
719 | moutId(activateid); | |
720 | mout(MENDASSIGN);} | |
721 | | HBEGIN | |
722 | { STOPOBSBLOCK(); | |
723 | OBSBLOCK();} | |
724 | MBEE_DECLSTMS | |
725 | HEND { MBEEENDBLOCK(); $$=STATEMENT;} | |
726 | | MBEE_TYPE HPROCEDURE | |
727 | HIDENTIFIER | |
728 | { MBEENEWBLOCK(); mout(MPROCEDURE); | |
729 | regDecl($3, type, KPROC, categ); | |
730 | beginBlock(KPROC);} | |
731 | HEADING BLOCK { endBlock(NULL,CCNO); $$=DECLARATION; | |
732 | mout(MENDPROCEDURE);} | |
733 | | HIDENTIFIER | |
734 | HCLASS | |
735 | NO_TYPE | |
736 | { $<ident>$=$1; } | |
737 | IMPORT_SPEC_MODULE | |
738 | HIDENTIFIER | |
739 | { prefquantident=$1; | |
740 | mout(MCLASS); | |
741 | regDecl($6, TNOTY, KCLASS, categ); | |
742 | beginBlock(KCLASS);} | |
743 | HEADING | |
744 | BLOCK { endBlock(NULL,CCNO); $$=DECLARATION; | |
745 | mout(MENDCLASS);} | |
746 | | HCLASS | |
747 | NO_TYPE | |
748 | HIDENTIFIER | |
749 | { prefquantident=0; | |
750 | MBEENEWBLOCK(); mout(MCLASS); | |
751 | regDecl($3, TNOTY, KCLASS, categ); | |
752 | beginBlock(KCLASS);} | |
753 | HEADING | |
754 | BLOCK { endBlock(NULL,CCNO); $$=DECLARATION; | |
755 | mout(MENDCLASS);} | |
756 | | EXT_DECLARATION { $$=EXTDECLARATION;} | |
757 | | /*EMPT*/{ STOPOBSBLOCK(); $$=EMPTYSTATEMENT;} | |
758 | ; | |
759 | IMPORT_SPEC_MODULE: { MBEENEWBLOCK(); | |
760 | kind=KCLASS; | |
761 | if($<ident>0==simsetident && | |
762 | findDecl(simsetident,cblock,FALSE)==NULL) | |
763 | lesinn_external_spec(simsetident, | |
764 | SIMSETATRFILE, kind); | |
765 | if($<ident>0==simulationident && findDecl( | |
766 | simulationident,cblock,FALSE)==NULL) | |
767 | lesinn_external_spec(simulationident, | |
768 | SIMULATIONATRFILE, kind); | |
769 | if(($<ident>0==fileident && findDecl( | |
770 | fileident,cblock,FALSE)==NULL) || | |
771 | ($<ident>0==outfileident && findDecl( | |
772 | outfileident,cblock,FALSE)==NULL) || | |
773 | ($<ident>0==infileident && findDecl( | |
774 | infileident,cblock,FALSE)==NULL) || | |
775 | ($<ident>0==directfileident && findDecl( | |
776 | directfileident,cblock,FALSE)==NULL) || | |
777 | ($<ident>0==printfileident && findDecl( | |
778 | printfileident,cblock,FALSE)==NULL) || | |
779 | ($<ident>0==bytefileident && findDecl( | |
780 | bytefileident,cblock,FALSE)==NULL) || | |
781 | ($<ident>0==inbytefileident && findDecl( | |
782 | inbytefileident,cblock,FALSE)==NULL) || | |
783 | ($<ident>0==outbytefileident && findDecl( | |
784 | outbytefileident,cblock,FALSE)==NULL) || | |
785 | ($<ident>0==directbytefileident && findDecl( | |
786 | directbytefileident,cblock,FALSE)==NULL)) | |
787 | lesinn_external_spec(fileident, | |
788 | FILEATRFILE, kind);} | |
789 | ; | |
790 | DECLSTATEMENT : MODULSTATEMENT | |
791 | | TYPE | |
792 | HIDENTIFIER | |
793 | MBEE_CONSTANT | |
794 | HPAREXPSEPARATOR | |
795 | { MBEENEWBLOCK(); | |
796 | kind=KSIMPLE; | |
797 | regDecl($2, type, KSIMPLE, categ); | |
798 | categ=CLOCAL;} | |
799 | IDENTIFIER_LISTC { $$=DECLARATION;} | |
800 | | TYPE | |
801 | HIDENTIFIER | |
802 | MBEE_CONSTANT | |
803 | { MBEENEWBLOCK(); | |
804 | regDecl($2, type, KSIMPLE, categ); | |
805 | categ=CLOCAL; $$=DECLARATION;} | |
806 | | MBEE_TYPE | |
807 | HARRAY { MBEENEWBLOCK(); | |
808 | kind=KARRAY;} | |
809 | ARR_SEGMENT_LIST { $$=DECLARATION;} | |
810 | | HSWITCH | |
811 | HIDENTIFIER | |
812 | HASSIGN { MBEENEWBLOCK(); mout(MIDENTIFIER); | |
813 | moutId($2); | |
814 | regDecl($2, TLABEL, KARRAY, categ);} | |
815 | SWITCH_LIST { $$=DECLARATION; | |
816 | mout(MSWITCH); | |
817 | mout(MENDSWITCH);} | |
818 | ; | |
819 | BLOCK : DECLSTATEMENT { if($1<=DECLARATION)yerror (29);} | |
820 | | HBEGIN MBEE_DECLSTMS HEND | |
821 | | HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND | |
822 | | HBEGIN error HEND | |
823 | ; | |
824 | MBEE_DECLSTMS : MBEE_DECLSTMSU { if($1<=DECLARATION)yerror (28); | |
825 | $$=$1;} | |
826 | ; | |
827 | MBEE_DECLSTMSU : DECLSTATEMENT { $$=$1;} | |
828 | | MBEE_DECLSTMSU | |
829 | HSTATEMENTSEPARATOR | |
830 | DECLSTATEMENT { if($1>=STATEMENT && $3<=DECLARATION) | |
831 | yerror (26); | |
832 | $$=$3;} | |
833 | ; | |
834 | MODULS : MODULSTATEMENT { if($1==DECLARATION) | |
835 | {separat_comp=TRUE;gettimestamp();} | |
836 | $$=$1;} | |
837 | | MODULS HSTATEMENTSEPARATOR MODULSTATEMENT | |
838 | { if($1>=STATEMENT && $3<=DECLARATION) | |
839 | yerror (26);else | |
840 | if($1>=STATEMENT | |
841 | && $3!=EMPTYSTATEMENT)yerror (25); | |
842 | if(separat_comp && $3==STATEMENT) | |
843 | yerror (25); | |
844 | if($3==DECLARATION && !separat_comp) | |
845 | {separat_comp=TRUE;gettimestamp();} | |
846 | $$=$3;} | |
847 | ; | |
848 | /* GRAMATIKK FOR DEL AV DEKLARASJONER */ | |
849 | ARR_SEGMENT_LIST: ARR_SEGMENT | |
850 | | ARR_SEGMENT_LIST | |
851 | HPAREXPSEPARATOR | |
852 | ARR_SEGMENT | |
853 | ; | |
854 | ARR_SEGMENT : ARRAY_SEGMENT | |
855 | HBEGPAR | |
856 | BAUND_PAIR_LIST HENDPAR { mout(MARRAY); | |
857 | mout(MENDARRAY); | |
858 | setArrayDim($3);} | |
859 | ; | |
860 | ARRAY_SEGMENT : ARRAY_SEGMENT_EL { mout(MENDSEP); | |
861 | mout(MARRAYSEP);} | |
862 | ||
863 | | ARRAY_SEGMENT_EL | |
864 | HPAREXPSEPARATOR | |
865 | ARRAY_SEGMENT { mout(MARRAYSEP);} | |
866 | ; | |
867 | ARRAY_SEGMENT_EL: HIDENTIFIER { mout(MIDENTIFIER); | |
868 | moutId($1); | |
869 | regDecl($1, type, kind, categ); | |
870 | if(lastArray==NULL) | |
871 | lastArray=cblock->lastparloc;} | |
872 | ; | |
873 | BAUND_PAIR_LIST : BAUND_PAIR { mout(MENDSEP); | |
874 | mout(MBOUNDSEP); | |
875 | $$=1;} | |
876 | | BAUND_PAIR | |
877 | HPAREXPSEPARATOR | |
878 | BAUND_PAIR_LIST { mout(MBOUNDSEP); | |
879 | $$=$3+1;} | |
880 | ; | |
881 | BAUND_PAIR : EXPRESSION | |
882 | HLABELSEPARATOR | |
883 | EXPRESSION { mout(MBOUNDPARSEP);} | |
884 | ; | |
885 | SWITCH_LIST : EXPRESSION { mout(MENDSEP); | |
886 | mout(MSWITCHSEP);} | |
887 | | EXPRESSION | |
888 | HPAREXPSEPARATOR | |
889 | SWITCH_LIST { mout(MSWITCHSEP);} | |
890 | ; | |
891 | HEADING : MBEE_FMAL_PAR_P HSTATEMENTSEPARATOR { kind=KNOKD;} | |
892 | MBEE_MODE_PART { categ=CSPEC;} | |
893 | MBEE_SPEC_PART { kind=KNOKD;} | |
894 | MBEE_PROT_PART { categ=CVIRT;} | |
895 | MBEE_VIRT_PART | |
896 | { categ=CLOCAL;} | |
897 | ; | |
898 | MBEE_FMAL_PAR_P : /*EMPT*/ | |
899 | | FMAL_PAR_PART | |
900 | ; | |
901 | FMAL_PAR_PART : HBEGPAR NO_TYPE | |
902 | MBEE_LISTV HENDPAR | |
903 | ; | |
904 | MBEE_LISTV : /*EMPT*/ | |
905 | | LISTV | |
906 | ; | |
907 | LISTV : HIDENTIFIER { regDecl($1, type, KNOKD, CDEFLT);} | |
908 | | FPP_CATEG HDOTDOTDOT { regDecl(varargsid, TVARARGS, KNOKD, categ);} | |
909 | | HIDENTIFIER { regDecl($1, type, KNOKD, CDEFLT);} | |
910 | HPAREXPSEPARATOR LISTV | |
911 | | FPP_SPEC | |
912 | | FPP_SPEC | |
913 | HPAREXPSEPARATOR LISTV | |
914 | ; | |
915 | FPP_HEADING : HBEGPAR NO_TYPE | |
916 | FPP_MBEE_LISTV HENDPAR | |
917 | ; | |
918 | FPP_MBEE_LISTV : /*EMPT*/ | |
919 | | FPP_LISTV | |
920 | ; | |
921 | FPP_LISTV : FPP_CATEG HDOTDOTDOT { regDecl(varargsid, TVARARGS, KNOKD, categ);} | |
922 | | FPP_SPEC | |
923 | | FPP_SPEC | |
924 | HPAREXPSEPARATOR LISTV | |
925 | ; | |
926 | FPP_SPEC : FPP_CATEG SPECIFIER HIDENTIFIER | |
927 | { regDecl($3, type, kind, categ);} | |
928 | | FPP_CATEG FPP_PROC_DECL_IN_SPEC | |
929 | ; | |
930 | FPP_CATEG : HNAME HLABELSEPARATOR | |
931 | { categ=CNAME;} | |
932 | | HVALUE HLABELSEPARATOR | |
933 | { categ=CVALUE;} | |
934 | | HVAR HLABELSEPARATOR | |
935 | { categ=CVAR;} | |
936 | | /*EMPT*/ { categ=CDEFLT;} | |
937 | ; | |
938 | FPP_PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE | |
939 | HIDENTIFIER | |
940 | { $<ival>$=categ; | |
941 | regDecl($3, type, KPROC, categ); | |
942 | beginBlock(KPROC);} | |
943 | FPP_HEADING | |
944 | { categ=$<ival>4; /* M} settes tilbake*/} | |
945 | { endBlock(NULL,CCNO);} | |
946 | ; | |
947 | IDENTIFIER_LISTV: HIDENTIFIER { regDecl($1, type, kind, categ);} | |
948 | | HDOTDOTDOT { regDecl(varargsid, TVARARGS, kind, categ);} | |
949 | | HIDENTIFIER { regDecl($1, type, kind, categ);} | |
950 | HPAREXPSEPARATOR IDENTIFIER_LISTV | |
951 | ; | |
952 | MBEE_MODE_PART : /*EMPT*/ | |
953 | | MODE_PART | |
954 | ; | |
955 | MODE_PART : NAME_PART | |
956 | | VALUE_PART | |
957 | | VAR_PART | |
958 | | NAME_PART VALUE_PART | |
959 | | VALUE_PART NAME_PART | |
960 | | NAME_PART VAR_PART | |
961 | | VAR_PART NAME_PART | |
962 | | VALUE_PART VAR_PART | |
963 | | VAR_PART VALUE_PART | |
964 | | VAR_PART NAME_PART VALUE_PART | |
965 | | NAME_PART VAR_PART VALUE_PART | |
966 | | NAME_PART VALUE_PART VAR_PART | |
967 | | VAR_PART VALUE_PART NAME_PART | |
968 | | VALUE_PART VAR_PART NAME_PART | |
969 | | VALUE_PART NAME_PART VAR_PART | |
970 | ; | |
971 | NAME_PART : HNAME { categ=CNAME;} | |
972 | IDENTIFIER_LISTV | |
973 | HSTATEMENTSEPARATOR | |
974 | ; | |
975 | VAR_PART : HVAR { categ=CVAR;} | |
976 | IDENTIFIER_LISTV | |
977 | HSTATEMENTSEPARATOR | |
978 | ; | |
979 | VALUE_PART : HVALUE { categ=CVALUE;} | |
980 | IDENTIFIER_LISTV HSTATEMENTSEPARATOR | |
981 | ; | |
982 | MBEE_SPEC_PART : /*EMPT*/ | |
983 | | SPEC_PART | |
984 | ; | |
985 | SPEC_PART : ONE_SPEC | |
986 | | SPEC_PART ONE_SPEC | |
987 | ; | |
988 | ONE_SPEC : SPECIFIER IDENTIFIER_LIST HSTATEMENTSEPARATOR | |
989 | | NO_TYPE HPROCEDURE HIDENTIFIER HOBJRELOPERATOR | |
990 | { if($4!=HIS) yerror (8);} | |
991 | PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR | |
992 | | FPP_PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR | |
993 | | MBEE_TYPE HPROCEDURE HIDENTIFIER HSTATEMENTSEPARATOR | |
994 | { yerror (45);} | |
995 | | MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR | |
996 | IDENTIFIER_LIST HSTATEMENTSEPARATOR | |
997 | { yerror (45);} | |
998 | ; | |
999 | SPECIFIER : TYPE { kind=KSIMPLE;} | |
1000 | | MBEE_TYPE | |
1001 | HARRAY { kind=KARRAY;} | |
1002 | | HLABEL { type=TLABEL; | |
1003 | kind=KSIMPLE;} | |
1004 | | HSWITCH { type=TLABEL; | |
1005 | kind=KARRAY;} | |
1006 | ; | |
1007 | PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE | |
1008 | HIDENTIFIER | |
1009 | { $<ival>$=categ; | |
1010 | regDecl($3, type, KPROC, categ); | |
1011 | beginBlock(KPROC);} | |
1012 | HEADING | |
1013 | { categ=$<ival>4; /* M} settes tilbake*/} | |
1014 | MBEE_BEGIN_END | |
1015 | { endBlock(NULL,CCNO);} | |
1016 | ; | |
1017 | MBEE_BEGIN_END : /* EMPTY */ | |
1018 | | HBEGIN HEND | |
1019 | ; | |
1020 | MBEE_PROT_PART : /*EMPT*/ | |
1021 | | PROTECTION_PART | |
1022 | ; | |
1023 | PROTECTION_PART : PROT_SPECIFIER IDENTIFIER_LIST | |
1024 | HSTATEMENTSEPARATOR | |
1025 | | PROTECTION_PART PROT_SPECIFIER | |
1026 | IDENTIFIER_LIST HSTATEMENTSEPARATOR | |
1027 | ; | |
1028 | PROT_SPECIFIER : HHIDDEN { categ=CHIDEN;} | |
1029 | | HPROTECTED { categ=CPROT;} | |
1030 | | HHIDDEN | |
1031 | HPROTECTED { categ=CHIPRO;} | |
1032 | | HPROTECTED | |
1033 | HHIDDEN { categ=CHIPRO;} | |
1034 | ; | |
1035 | MBEE_VIRT_PART : /*EMPT*/ | |
1036 | | VIRTUAL_PART | |
1037 | ; | |
1038 | VIRTUAL_PART : HVIRTUAL | |
1039 | HLABELSEPARATOR | |
1040 | MBEE_SPEC_PART | |
1041 | ; | |
1042 | IDENTIFIER_LIST : HIDENTIFIER { regDecl($1, type, kind, categ);} | |
1043 | | IDENTIFIER_LIST HPAREXPSEPARATOR | |
1044 | HIDENTIFIER { regDecl($3, type, kind, categ);} | |
1045 | ; | |
1046 | IDENTIFIER_LISTC: HIDENTIFIER | |
1047 | MBEE_CONSTANT { regDecl($1, type, kind, categ); | |
1048 | categ=CLOCAL;} | |
1049 | | IDENTIFIER_LISTC HPAREXPSEPARATOR | |
1050 | HIDENTIFIER | |
1051 | MBEE_CONSTANT { regDecl($3, type, kind, categ); | |
1052 | categ=CLOCAL;} | |
1053 | ; | |
1054 | MBEE_CONSTANT : /* EMPTY */ | |
1055 | | HVALRELOPERATOR | |
1056 | { MBEENEWBLOCK(); | |
1057 | if($1!=HEQ) yerror (8); | |
1058 | if(type==TREF)yerror (7); | |
1059 | categ=CCONSTU; | |
1060 | mout(MIDENTIFIER); | |
1061 | moutId($<token>0);} | |
1062 | EXPRESSION { mout(MASSIGN); | |
1063 | mout(MCONST);} | |
1064 | ; | |
1065 | ||
1066 | /* GRAMATIKK FOR UTTRYKK */ | |
1067 | EXPRESSION : EXPRESSION_SIMP {} | |
1068 | | HIF | |
1069 | EXPRESSION | |
1070 | HTHEN | |
1071 | EXPRESSION | |
1072 | HELSE | |
1073 | EXPRESSION { mout(MELSEE); | |
1074 | mout(MIFE);} | |
1075 | ; | |
1076 | EXPRESSION_SIMP : EXPRESSION_SIMP | |
1077 | HASSIGN | |
1078 | EXPRESSION { if($2==HASSIGNREF)mout(MASSIGNR); | |
1079 | else mout(MASSIGN);$$=NULL;} | |
1080 | | | |
1081 | ||
1082 | EXPRESSION_SIMP | |
1083 | HCONC | |
1084 | EXPRESSION_SIMP { mout(MCONC);$$=NULL;} | |
1085 | | EXPRESSION_SIMP HOR | |
1086 | HELSE | |
1087 | EXPRESSION_SIMP | |
1088 | %prec HORELSE { mout(MORELSEE);$$=NULL;} | |
1089 | | EXPRESSION_SIMP HAND | |
1090 | HTHEN | |
1091 | EXPRESSION_SIMP | |
1092 | %prec HANDTHEN { mout(MANDTHENE);$$=NULL;} | |
1093 | | EXPRESSION_SIMP | |
1094 | HEQV EXPRESSION_SIMP { mout(MEQV);$$=NULL;} | |
1095 | | EXPRESSION_SIMP | |
1096 | HIMP EXPRESSION_SIMP { mout(MIMP);$$=NULL;} | |
1097 | | EXPRESSION_SIMP | |
1098 | HOR EXPRESSION_SIMP { mout(MOR);$$=NULL;} | |
1099 | | EXPRESSION_SIMP | |
1100 | HAND EXPRESSION_SIMP { mout(MAND);$$=NULL;} | |
1101 | | HNOT EXPRESSION_SIMP { mout(MNOT);$$=NULL;} | |
1102 | | EXPRESSION_SIMP | |
1103 | HVALRELOPERATOR | |
1104 | EXPRESSION_SIMP | |
1105 | { switch($2) | |
1106 | { case HEQ: mout(MEQ);break; | |
1107 | case HNE: mout(MNE);break; | |
1108 | case HLT: mout(MLT);break; | |
1109 | case HLE: mout(MLE);break; | |
1110 | case HGT: mout(MGT);break; | |
1111 | case HGE: mout(MGE);break; | |
1112 | }$$=NULL;} | |
1113 | | EXPRESSION_SIMP | |
1114 | HREFRELOPERATOR | |
1115 | EXPRESSION_SIMP | |
1116 | { if($2==HNER) mout(MNER); | |
1117 | else mout(MEQR);$$=NULL;} | |
1118 | | EXPRESSION_SIMP | |
1119 | HOBJRELOPERATOR | |
1120 | EXPRESSION_SIMP | |
1121 | { if($2==HIS) mout(MIS); | |
1122 | else mout(MINS);$$=NULL;} | |
1123 | | HTERMOPERATOR | |
1124 | EXPRESSION_SIMP %prec UNEAR | |
1125 | { if($1==HADD) mout(MUADD); | |
1126 | else mout(MUSUB);$$=NULL;} | |
1127 | | EXPRESSION_SIMP | |
1128 | HTERMOPERATOR | |
1129 | EXPRESSION_SIMP | |
1130 | { if($2==HADD) mout(MADD); | |
1131 | else mout(MSUB);$$=NULL;} | |
1132 | | EXPRESSION_SIMP | |
1133 | HFACTOROPERATOR | |
1134 | EXPRESSION_SIMP | |
1135 | { if($2==HMUL) mout(MMUL); else | |
1136 | if($2==HDIV) mout(MDIV); | |
1137 | else mout(MINTDIV);$$=NULL;} | |
1138 | | EXPRESSION_SIMP | |
1139 | HPRIMARYOPERATOR | |
1140 | EXPRESSION_SIMP { mout(MPRIMARY);$$=NULL;} | |
1141 | | HBEGPAR | |
1142 | EXPRESSION HENDPAR { mout(MNOOP);$$=NULL;} | |
1143 | | HTEXTKONST { mout(MTEXTKONST); | |
1144 | moutTval($1);$$=NULL;} | |
1145 | | HCHARACTERKONST { mout(MCHARACTERKONST); | |
1146 | moutIval($1);$$=NULL;} | |
1147 | | HREALKONST { mout(MREALKONST); | |
1148 | moutRval($1);$$=NULL;} | |
1149 | | HINTEGERKONST { mout(MINTEGERKONST); | |
1150 | moutIval($1);$$=NULL;} | |
1151 | | HBOOLEANKONST { mout(MBOOLEANKONST); | |
1152 | moutIval($1);$$=NULL;} | |
1153 | | HNONE { mout(MNONE);$$=NULL;} | |
1154 | | HIDENTIFIER | |
1155 | { $<ident>$=$1;} | |
1156 | MBEE_ARG_R_PT | |
1157 | | HTHIS HIDENTIFIER { mout(MTHIS); | |
1158 | moutId($2);$$=NULL;} | |
1159 | | HNEW | |
1160 | HIDENTIFIER | |
1161 | ARG_R_PT { mout(MNEWARG); | |
1162 | moutId($2);$$=NULL;} | |
1163 | | EXPRESSION_SIMP | |
1164 | HDOT | |
1165 | EXPRESSION_SIMP { mout(MDOT);$$=NULL;} | |
1166 | | EXPRESSION_SIMP | |
1167 | HQUA HIDENTIFIER { mout(MQUA); | |
1168 | moutId($3);$$=NULL;} | |
1169 | ; | |
1170 | ARG_R_PT : /*EMPTY*/ { mout(MENDSEP);} | |
1171 | | HBEGPAR | |
1172 | ARGUMENT_LIST HENDPAR | |
1173 | ; | |
1174 | MBEE_ARG_R_PT : /*EMPTY*/ { mout(MIDENTIFIER); | |
1175 | moutId($<ident>0); | |
1176 | $$=$<ident>0;} | |
1177 | | HBEGPAR | |
1178 | ARGUMENT_LIST HENDPAR { mout(MARGUMENT); | |
1179 | moutId($<ident>0);} | |
1180 | ; | |
1181 | ARGUMENT_LIST : EXPRESSION { mout(MENDSEP); | |
1182 | mout(MARGUMENTSEP);} | |
1183 | | EXPRESSION | |
1184 | HPAREXPSEPARATOR | |
1185 | ARGUMENT_LIST { mout(MARGUMENTSEP);} | |
1186 | ; | |
1187 | %% | |
1188 | ]]) | |
1189 | ||
1190 | # Pass plenty of options, to exercise plenty of code, even if we | |
1191 | # don't actually check the output. But SEGV is watching us, and | |
1192 | # so might do dmalloc. | |
1193 | AT_CHECK([[bison --verbose --defines input.y]], 0, [], | |
1194 | [[input.y contains 78 shift/reduce conflicts and 10 reduce/reduce conflicts. | |
1195 | ]]) | |
1196 | ||
1197 | AT_CHECK([[grep '^State.*contains' input.output]], 0, | |
1198 | [[State 64 contains 14 shift/reduce conflicts. | |
1199 | State 164 contains 1 shift/reduce conflict. | |
1200 | State 201 contains 33 shift/reduce conflicts and 4 reduce/reduce conflicts. | |
1201 | State 206 contains 1 shift/reduce conflict. | |
1202 | State 240 contains 1 shift/reduce conflict. | |
1203 | State 335 contains 9 shift/reduce conflicts and 2 reduce/reduce conflicts. | |
1204 | State 356 contains 1 shift/reduce conflict. | |
1205 | State 360 contains 9 shift/reduce conflicts and 2 reduce/reduce conflicts. | |
1206 | State 427 contains 9 shift/reduce conflicts and 2 reduce/reduce conflicts. | |
1207 | ]]) | |
1208 | ||
1209 | AT_CLEANUP |