1 # Torturing Bison. -*- Autotest -*-
2 # Copyright 2001 Free Software Foundation, Inc.
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)
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.
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
19 AT_BANNER([[Torture Tests.]])
22 # AT_DATA_STACK_TORTURE(C-PROLOGUE)
23 # ---------------------------------
24 # A parser specialized in torturing the stack size.
25 m4_define([AT_DATA_STACK_TORTURE],
26 [# A grammar of parens growing the stack thanks to right recursion.
34 static int yylex (void);
35 static void yyerror (const char *msg);
36 #define YYPRINT(File, Type, Value) \
37 fprintf (File, " (%d, stack size = %d, max = %d)", \
38 Value, yyssp - yyss + 1, yystacksize);
44 exp: WAIT_FOR_EOF exp | ;
47 yyerror (const char *msg)
49 fprintf (stderr, "%s\n", msg);
53 /* There are YYLVAL_MAX of WAIT_FOR_EOFs. */
54 unsigned int yylval_max;
66 main (int argc, const char **argv)
69 yylval = atoi (argv[1]);
74 AT_CHECK([bison input.y -o input.c])
75 AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore])
79 ## -------------------------------------- ##
80 ## Exploding the Stack Size with Alloca. ##
81 ## -------------------------------------- ##
83 AT_SETUP([Exploding the Stack Size with Alloca])
87 # Below the limit of 200.
88 AT_CHECK([./input 20], 0, [], [ignore])
89 # Two enlargements: 2 * 2 * 200.
90 AT_CHECK([./input 900], 0, [], [ignore])
91 # Fails: beyond the limit of 10,000 (which we don't reach anyway since we
92 # multiply by two starting at 200 => 5120 is the last possible).
93 AT_CHECK([./input 10000], 1, [], [ignore])
100 ## -------------------------------------- ##
101 ## Exploding the Stack Size with Malloc. ##
102 ## -------------------------------------- ##
104 AT_SETUP([Exploding the Stack Size with Malloc])
106 AT_DATA_STACK_TORTURE([[#define YYSTACK_USE_ALLOCA 0]])
108 # Below the limit of 200.
109 AT_CHECK([./input 20], 0, [], [ignore])
110 # Two enlargements: 2 * 2 * 200.
111 AT_CHECK([./input 900], 0, [], [ignore])
112 # Fails: beyond the limit of 10,000 (which we don't reach anyway since we
113 # multiply by two starting at 200 => 5120 is the possible).
114 AT_CHECK([./input 10000], 1, [], [ignore])
119 ## ----------------- ##
120 ## GNU AWK Grammar. ##
121 ## ----------------- ##
123 AT_SETUP([GNU AWK Grammar])
125 # We have been careful to strip all the actions excepts the
126 # mid-rule actions. We rely on %expect to check that there are
127 # indeed 65 SR conflicts.
129 # Bison was once wrong, due to an incorrect computation of nullable.
130 # It reported 485 SR conflicts!
135 %token FUNC_CALL NAME REGEXP
137 %token YNUMBER YSTRING
138 %token RELOP APPEND_OP
139 %token ASSIGNOP MATCHOP NEWLINE CONCAT_OP
140 %token LEX_BEGIN LEX_END LEX_IF LEX_ELSE LEX_RETURN LEX_DELETE
141 %token LEX_WHILE LEX_DO LEX_FOR LEX_BREAK LEX_CONTINUE
142 %token LEX_PRINT LEX_PRINTF LEX_NEXT LEX_EXIT LEX_FUNCTION
143 %token LEX_GETLINE LEX_NEXTFILE
145 %token LEX_AND LEX_OR INCREMENT DECREMENT
146 %token LEX_BUILTIN LEX_LENGTH
148 /* Lowest to highest */
155 %left FUNC_CALL LEX_BUILTIN LEX_LENGTH
158 %nonassoc RELOP '<' '>' '|' APPEND_OP TWOWAYIO
160 %left YSTRING YNUMBER
165 %left INCREMENT DECREMENT
171 : opt_nls program opt_nls
183 : LEX_BEGIN {} action
185 | LEX_BEGIN statement_term
186 | LEX_END statement_term
189 | pattern statement_term
190 | function_prologue function_body
205 : LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls
209 : l_brace statements r_brace opt_semi opt_nls
210 | l_brace r_brace opt_semi opt_nls
221 * In this rule, want_regexp tells yylex that the next thing
222 * is a regexp so it should read up to the closing slash.
228 : l_brace statements r_brace opt_semi opt_nls
229 | l_brace r_brace opt_semi opt_nls
234 | statements statement
247 | l_brace statements r_brace
249 | LEX_WHILE '(' exp r_paren opt_nls statement
250 | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls
251 | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement
252 | LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement
253 | LEX_FOR '(' opt_exp semi opt_nls semi opt_nls opt_exp r_paren opt_nls statement
254 | LEX_BREAK statement_term
255 | LEX_CONTINUE statement_term
256 | print '(' expression_list r_paren output_redir statement_term
257 | print opt_rexpression_list output_redir statement_term
258 | LEX_NEXT statement_term
259 | LEX_NEXTFILE statement_term
260 | LEX_EXIT opt_exp statement_term
261 | LEX_RETURN {} opt_exp statement_term
262 | LEX_DELETE NAME '[' expression_list ']' statement_term
263 | LEX_DELETE NAME statement_term
273 : LEX_IF '(' exp r_paren opt_nls statement
274 | LEX_IF '(' exp r_paren opt_nls statement
275 LEX_ELSE opt_nls statement
308 | param_list comma NAME
311 | param_list comma error
314 /* optional expression, as in for loop */
327 | rexpression_list comma rexp
329 | rexpression_list error
330 | rexpression_list error rexp
331 | rexpression_list comma error
341 | expression_list comma exp
343 | expression_list error
344 | expression_list error exp
345 | expression_list comma error
348 /* Expressions, not including the comma operator. */
349 exp : variable ASSIGNOP {} exp
350 | '(' expression_list r_paren LEX_IN NAME
351 | exp '|' LEX_GETLINE opt_variable
352 | exp TWOWAYIO LEX_GETLINE opt_variable
353 | LEX_GETLINE opt_variable input_redir
358 | '!' regexp %prec UNARY
363 | exp '?' exp ':' exp
365 | exp simp_exp %prec CONCAT_OP
369 : variable ASSIGNOP {} rexp
372 | LEX_GETLINE opt_variable input_redir
374 | '!' regexp %prec UNARY
378 | rexp '?' rexp ':' rexp
380 | rexp simp_exp %prec CONCAT_OP
385 /* Binary operators in order of decreasing precedence. */
386 | simp_exp '^' simp_exp
387 | simp_exp '*' simp_exp
388 | simp_exp '/' simp_exp
389 | simp_exp '%' simp_exp
390 | simp_exp '+' simp_exp
391 | simp_exp '-' simp_exp
397 : '!' simp_exp %prec UNARY
400 '(' opt_expression_list r_paren
401 | LEX_LENGTH '(' opt_expression_list r_paren
403 | FUNC_CALL '(' opt_expression_list r_paren
409 | '-' simp_exp %prec UNARY
410 | '+' simp_exp %prec UNARY
420 | NAME '[' expression_list ']'
421 | '$' non_post_simp_exp
451 # Pass plenty of options, to exercise plenty of code, even if we
452 # don't actually check the output. But SEGV is watching us, and
453 # so might do dmalloc.
454 AT_CHECK([[bison --verbose --defines input.y]])
459 ## ----------------- ##
460 ## GNU Cim Grammar. ##
461 ## ----------------- ##
463 AT_SETUP([GNU Cim Grammar])
465 # GNU Cim, the GNU Simula 87 Compiler.
467 # Bison was once wrong, due to an incorrect computation of the RR conflicts.
468 # It reported 80 SR && 99 RR conflicts instead of 78/10!!!
482 HACTIVATE HAFTER /*HAND*/ HARRAY HAT
483 HBEFORE HBEGIN HBOOLEAN
484 HCHARACTER HCLASS /*HCOMMENT*/ HCONC
486 HELSE HEND HEQ /*HEQV*/ HEXTERNAL
490 HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS
492 HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT
494 HPRIOR HPROCEDURE HPROTECTED
496 HREACTIVATE HREAL HREF
498 HTEXT HTHEN HTHIS HTO
503 HASSIGNVALUE HASSIGNREF
504 /*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR
507 HADD HSUB HMUL HDIV HINTDIV HEXP
510 %token <ident> HIDENTIFIER
511 %token <ival> HBOOLEANKONST HINTEGERKONST HCHARACTERKONST
512 %token <rval> HREALKONST
513 %token <tval> HTEXTKONST
515 %type <tval> EXT_IDENT
516 %type <stat_decl> DECLSTATEMENT MODULSTATEMENT MBEE_DECLSTMS MBEE_DECLSTMSU
517 %type <stat_decl> MODULS
518 %type <ident> EXPRESSION_SIMP MBEE_ARG_R_PT
519 %type <arrdim> BAUND_PAIR_LIST
521 %right <token> HASSIGN
531 %left <token> HVALRELOPERATOR HREFRELOPERATOR HOBJRELOPERATOR
535 %left <token> HTERMOPERATOR
537 %left <token> HFACTOROPERATOR
538 %left HPRIMARYOPERATOR
546 /* GRAMATIKK FOR PROGRAM MODULES */
547 MAIN_MODULE : { categ=CLOCAL; mout(MBLOCK);
548 beginBlock(KBLOKK);separat_comp=FALSE;}
549 MODULS { endBlock(NULL,CCNO); mout(MENDBLOCK);}
550 | error HSTATEMENTSEPARATOR MBEE_DECLSTMS
552 EXT_DECLARATION : HEXTERNAL
565 if($2==Ckind)categ=CCPROC;else
567 ysensitive=sensitive;
569 HIDENTIFIER { $<ident>$=$5;
570 sensitive=ysensitive;}
580 EXTERNAL_KIND_ITEM: EXT_IDENT
582 { if($2!=HIS)yerror (2);}
585 { regDecl($6, type, KPROC, CCPROC);
589 endBlock($1==NULL?$<ident>0:tag($1),CCCPROC);}
592 { if($1!=NULL)yerror (3);
593 regDecl($0, type, kind, categ);}
595 { endBlock(NULL,CCNO);}
597 MBEE_REST_EXT_LIST: /* EMPTY
598 | HPAREXPSEPARATOR EXT_KIND_LIST
600 EXT_KIND_LIST : EXT_KIND_ITEM
601 | EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM
603 EXT_KIND_ITEM : HIDENTIFIER
605 { if($2!=NULL)yerror (3);
606 regDecl($1, type, kind, categ);}*/
608 EMPTY_BLOCK : /*EMPT*/
612 | EXT_LIST HPAREXPSEPARATOR EXT_ITEM
614 EXT_ITEM : HIDENTIFIER
616 { lesinn_external_spec($1,$2, kind);}
618 EXT_IDENT : /* EMPTY */ { $$=NULL;}
619 | HVALRELOPERATOR { if($1!=HEQ)yerror (9);
621 HTEXTKONST { $$=$3;external=FALSE;}
623 /* GRAMATIKK FOR TYPER */
624 NO_TYPE : /*EMPT*/ { type=TNOTY;}
634 | HTEXT { type=TTEXT;}
635 | HBOOLEAN { type=TBOOL;}
636 | HCHARACTER { type=TCHAR;}
637 | HSHORT HINTEGER { type=TSHORT;}
638 | HINTEGER { type=TINTG;}
639 | HREAL { type=TREAL;}
640 | HLONG HREAL { type=TLONG;}
643 /* GRAMATIKK FOR DEL AV SETNINGER */
644 MBEE_ELSE_PART : /*EMPT*/
651 BLOCK { MBEEENDBLOCK();}
652 MBEE_ELSE_PART { mout(MENDIF);}*/
653 | HELSE { OBSBLOCK(); mout(MELSE);}
654 BLOCK { MBEEENDBLOCK();}
656 FOR_LIST : FOR_LIST_ELEMENT { mout(MENDSEP);
660 FOR_LIST { mout(MLISTSEP);}
662 FOR_LIST_ELEMENT: EXPRESSION
665 MBEE_F_L_EL_R_PT: /*EMPT*/
667 EXPRESSION { mout(MFORWHILE);}
671 EXPRESSION { mout(MUNTIL);
678 CONN_STATE_R_PT : WHEN_CLAUSE_LIST
679 | HDO { beginBlock(KCON); mout(MDO);
681 BLOCK { endBlock(NULL,CCNO);
682 MBEEENDBLOCK(); mout(MENDDO);}
684 WHEN_CLAUSE_LIST: HWHEN
686 HDO { beginBlock(KCON); mout(MIDENTIFIER);
687 OBSBLOCK(); moutId($2);
689 BLOCK { endBlock(NULL,CCNO);
690 MBEEENDBLOCK(); mout(MENDWHEN);}
694 HDO { beginBlock(KCON); mout(MIDENTIFIER);
695 OBSBLOCK(); moutId($3);
697 BLOCK { endBlock(NULL,CCNO);
698 MBEEENDBLOCK(); mout(MENDWHEN);}
700 MBEE_OTWI_CLAUS : /*EMPT*/
701 | HOTHERWISE {OBSBLOCK(); mout(MOTHERWISE);}
703 BLOCK {MBEEENDBLOCK();mout(MENDOTHERWISE);}
705 ACTIVATOR : HACTIVATE { mout(MBOOLEANKONST);
707 | HREACTIVATE { mout(MBOOLEANKONST);
710 SCHEDULE : /*EMPT*/ { mout(MCHARACTERKONST);
717 | ATDELAY EXPRESSION { mout(MNONE);}
719 | BEFOREAFTER { mout(MINTEGERKONST);
721 EXPRESSION { mout(MBOOLEANKONST);
724 ATDELAY : HAT { mout(MCHARACTERKONST);
726 | HDELAY { mout(MCHARACTERKONST);
729 BEFOREAFTER : HBEFORE { mout(MCHARACTERKONST);
731 | HAFTER { mout(MCHARACTERKONST);
734 PRIOR : /*EMPT*/ { mout(MBOOLEANKONST);
736 | HPRIOR { mout(MBOOLEANKONST);
739 /* GRAMATIKK FOR SETNINGER OG DEKLARASJONER */
740 MODULSTATEMENT : HWHILE
742 HDO { STOPOBSBLOCK(); mout(MWHILE);
744 BLOCK { MBEEENDBLOCK(); mout(MENDWHILE);
748 HTHEN { STOPOBSBLOCK(); mout(MIF);
750 BLOCK { MBEEENDBLOCK();}
751 MBEE_ELSE_PART { mout(MENDIF);
755 HASSIGN { STOPOBSBLOCK(); mout(MIDENTIFIER);
758 HDO { beginBlock(KFOR);
759 if($3==HASSIGNVALUE) mout(MFOR);
761 OBSBLOCK(); mout(MFORDO);}
762 BLOCK { MBEEENDBLOCK();
763 endBlock(NULL,CCNO); mout(MENDFOR);
766 EXPRESSION { mout(MGOTO);
767 STOPOBSBLOCK(); $$=STATEMENT;}
769 EXPRESSION { mout(MINSPECT);
773 { endBlock(NULL,CCNO);}
774 MBEE_OTWI_CLAUS { mout(MENDINSPECT);
776 | HINNER { STOPOBSBLOCK(); mout(MINNER);
777 regInner(); $$=STATEMENT;}
781 regDecl($1, TLABEL, KSIMPLE, categ); mout(MLABEL);
784 DECLSTATEMENT { if($4<=DECLARATION)
796 HEND { endBlock(NULL,CCNO); mout(MENDPRBLOCK);
798 | EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR
799 MBEE_DECLSTMS HEND { $$=STATEMENT;
800 endBlock(NULL,CCNO); mout(MENDPRBLOCK);}
801 | EXPRESSION_SIMP HBEGIN error HEND
803 endBlock(NULL,CCNO); mout(MENDPRBLOCK);}
806 { STOPOBSBLOCK(); $$=STATEMENT;
808 | ACTIVATOR EXPRESSION SCHEDULE
824 HEND { MBEEENDBLOCK(); $$=STATEMENT;}
825 | MBEE_TYPE HPROCEDURE
827 { MBEENEWBLOCK(); mout(MPROCEDURE);
828 regDecl($3, type, KPROC, categ);
830 HEADING BLOCK { endBlock(NULL,CCNO); $$=DECLARATION;
831 mout(MENDPROCEDURE);}
840 regDecl($6, TNOTY, KCLASS, categ);
843 BLOCK { endBlock(NULL,CCNO); $$=DECLARATION;
849 MBEENEWBLOCK(); mout(MCLASS);
850 regDecl($3, TNOTY, KCLASS, categ);
853 BLOCK { endBlock(NULL,CCNO); $$=DECLARATION;
855 | EXT_DECLARATION { $$=EXTDECLARATION;}
856 | /*EMPT*/{ STOPOBSBLOCK(); $$=EMPTYSTATEMENT;}
858 IMPORT_SPEC_MODULE: { MBEENEWBLOCK();
860 if($<ident>0==simsetident &&
861 findDecl(simsetident,cblock,FALSE)==NULL)
862 lesinn_external_spec(simsetident,
863 SIMSETATRFILE, kind);
864 if($<ident>0==simulationident && findDecl(
865 simulationident,cblock,FALSE)==NULL)
866 lesinn_external_spec(simulationident,
867 SIMULATIONATRFILE, kind);
868 if(($<ident>0==fileident && findDecl(
869 fileident,cblock,FALSE)==NULL) ||
870 ($<ident>0==outfileident && findDecl(
871 outfileident,cblock,FALSE)==NULL) ||
872 ($<ident>0==infileident && findDecl(
873 infileident,cblock,FALSE)==NULL) ||
874 ($<ident>0==directfileident && findDecl(
875 directfileident,cblock,FALSE)==NULL) ||
876 ($<ident>0==printfileident && findDecl(
877 printfileident,cblock,FALSE)==NULL) ||
878 ($<ident>0==bytefileident && findDecl(
879 bytefileident,cblock,FALSE)==NULL) ||
880 ($<ident>0==inbytefileident && findDecl(
881 inbytefileident,cblock,FALSE)==NULL) ||
882 ($<ident>0==outbytefileident && findDecl(
883 outbytefileident,cblock,FALSE)==NULL) ||
884 ($<ident>0==directbytefileident && findDecl(
885 directbytefileident,cblock,FALSE)==NULL))
886 lesinn_external_spec(fileident,
889 DECLSTATEMENT : MODULSTATEMENT
896 regDecl($2, type, KSIMPLE, categ);
898 IDENTIFIER_LISTC { $$=DECLARATION;}
903 regDecl($2, type, KSIMPLE, categ);
904 categ=CLOCAL; $$=DECLARATION;}
906 HARRAY { MBEENEWBLOCK();
908 ARR_SEGMENT_LIST { $$=DECLARATION;}
911 HASSIGN { MBEENEWBLOCK(); mout(MIDENTIFIER);
913 regDecl($2, TLABEL, KARRAY, categ);}
914 SWITCH_LIST { $$=DECLARATION;
918 BLOCK : DECLSTATEMENT { if($1<=DECLARATION)yerror (29);}
919 | HBEGIN MBEE_DECLSTMS HEND
920 | HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND
923 MBEE_DECLSTMS : MBEE_DECLSTMSU { if($1<=DECLARATION)yerror (28);
926 MBEE_DECLSTMSU : DECLSTATEMENT { $$=$1;}
929 DECLSTATEMENT { if($1>=STATEMENT && $3<=DECLARATION)
933 MODULS : MODULSTATEMENT { if($1==DECLARATION)
934 {separat_comp=TRUE;gettimestamp();}
936 | MODULS HSTATEMENTSEPARATOR MODULSTATEMENT
937 { if($1>=STATEMENT && $3<=DECLARATION)
940 && $3!=EMPTYSTATEMENT)yerror (25);
941 if(separat_comp && $3==STATEMENT)
943 if($3==DECLARATION && !separat_comp)
944 {separat_comp=TRUE;gettimestamp();}
947 /* GRAMATIKK FOR DEL AV DEKLARASJONER */
948 ARR_SEGMENT_LIST: ARR_SEGMENT
953 ARR_SEGMENT : ARRAY_SEGMENT
955 BAUND_PAIR_LIST HENDPAR { mout(MARRAY);
959 ARRAY_SEGMENT : ARRAY_SEGMENT_EL { mout(MENDSEP);
964 ARRAY_SEGMENT { mout(MARRAYSEP);}
966 ARRAY_SEGMENT_EL: HIDENTIFIER { mout(MIDENTIFIER);
968 regDecl($1, type, kind, categ);
970 lastArray=cblock->lastparloc;}
972 BAUND_PAIR_LIST : BAUND_PAIR { mout(MENDSEP);
977 BAUND_PAIR_LIST { mout(MBOUNDSEP);
980 BAUND_PAIR : EXPRESSION
982 EXPRESSION { mout(MBOUNDPARSEP);}
984 SWITCH_LIST : EXPRESSION { mout(MENDSEP);
988 SWITCH_LIST { mout(MSWITCHSEP);}
990 HEADING : MBEE_FMAL_PAR_P HSTATEMENTSEPARATOR { kind=KNOKD;}
991 MBEE_MODE_PART { categ=CSPEC;}
992 MBEE_SPEC_PART { kind=KNOKD;}
993 MBEE_PROT_PART { categ=CVIRT;}
997 MBEE_FMAL_PAR_P : /*EMPT*/
1000 FMAL_PAR_PART : HBEGPAR NO_TYPE
1003 MBEE_LISTV : /*EMPT*/
1006 LISTV : HIDENTIFIER { regDecl($1, type, KNOKD, CDEFLT);}
1007 | FPP_CATEG HDOTDOTDOT { regDecl(varargsid, TVARARGS, KNOKD, categ);}
1008 | HIDENTIFIER { regDecl($1, type, KNOKD, CDEFLT);}
1009 HPAREXPSEPARATOR LISTV
1012 HPAREXPSEPARATOR LISTV
1014 FPP_HEADING : HBEGPAR NO_TYPE
1015 FPP_MBEE_LISTV HENDPAR
1017 FPP_MBEE_LISTV : /*EMPT*/
1020 FPP_LISTV : FPP_CATEG HDOTDOTDOT { regDecl(varargsid, TVARARGS, KNOKD, categ);}
1023 HPAREXPSEPARATOR LISTV
1025 FPP_SPEC : FPP_CATEG SPECIFIER HIDENTIFIER
1026 { regDecl($3, type, kind, categ);}
1027 | FPP_CATEG FPP_PROC_DECL_IN_SPEC
1029 FPP_CATEG : HNAME HLABELSEPARATOR
1031 | HVALUE HLABELSEPARATOR
1033 | HVAR HLABELSEPARATOR
1035 | /*EMPT*/ { categ=CDEFLT;}
1037 FPP_PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE
1040 regDecl($3, type, KPROC, categ);
1043 { categ=$<ival>4; /* M} settes tilbake*/}
1044 { endBlock(NULL,CCNO);}
1046 IDENTIFIER_LISTV: HIDENTIFIER { regDecl($1, type, kind, categ);}
1047 | HDOTDOTDOT { regDecl(varargsid, TVARARGS, kind, categ);}
1048 | HIDENTIFIER { regDecl($1, type, kind, categ);}
1049 HPAREXPSEPARATOR IDENTIFIER_LISTV
1051 MBEE_MODE_PART : /*EMPT*/
1054 MODE_PART : NAME_PART
1057 | NAME_PART VALUE_PART
1058 | VALUE_PART NAME_PART
1059 | NAME_PART VAR_PART
1060 | VAR_PART NAME_PART
1061 | VALUE_PART VAR_PART
1062 | VAR_PART VALUE_PART
1063 | VAR_PART NAME_PART VALUE_PART
1064 | NAME_PART VAR_PART VALUE_PART
1065 | NAME_PART VALUE_PART VAR_PART
1066 | VAR_PART VALUE_PART NAME_PART
1067 | VALUE_PART VAR_PART NAME_PART
1068 | VALUE_PART NAME_PART VAR_PART
1070 NAME_PART : HNAME { categ=CNAME;}
1074 VAR_PART : HVAR { categ=CVAR;}
1078 VALUE_PART : HVALUE { categ=CVALUE;}
1079 IDENTIFIER_LISTV HSTATEMENTSEPARATOR
1081 MBEE_SPEC_PART : /*EMPT*/
1084 SPEC_PART : ONE_SPEC
1085 | SPEC_PART ONE_SPEC
1087 ONE_SPEC : SPECIFIER IDENTIFIER_LIST HSTATEMENTSEPARATOR
1088 | NO_TYPE HPROCEDURE HIDENTIFIER HOBJRELOPERATOR
1089 { if($4!=HIS) yerror (8);}
1090 PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR
1091 | FPP_PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR
1092 | MBEE_TYPE HPROCEDURE HIDENTIFIER HSTATEMENTSEPARATOR
1094 | MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR
1095 IDENTIFIER_LIST HSTATEMENTSEPARATOR
1098 SPECIFIER : TYPE { kind=KSIMPLE;}
1100 HARRAY { kind=KARRAY;}
1101 | HLABEL { type=TLABEL;
1103 | HSWITCH { type=TLABEL;
1106 PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE
1109 regDecl($3, type, KPROC, categ);
1112 { categ=$<ival>4; /* M} settes tilbake*/}
1114 { endBlock(NULL,CCNO);}
1116 MBEE_BEGIN_END : /* EMPTY */
1119 MBEE_PROT_PART : /*EMPT*/
1122 PROTECTION_PART : PROT_SPECIFIER IDENTIFIER_LIST
1124 | PROTECTION_PART PROT_SPECIFIER
1125 IDENTIFIER_LIST HSTATEMENTSEPARATOR
1127 PROT_SPECIFIER : HHIDDEN { categ=CHIDEN;}
1128 | HPROTECTED { categ=CPROT;}
1130 HPROTECTED { categ=CHIPRO;}
1132 HHIDDEN { categ=CHIPRO;}
1134 MBEE_VIRT_PART : /*EMPT*/
1137 VIRTUAL_PART : HVIRTUAL
1141 IDENTIFIER_LIST : HIDENTIFIER { regDecl($1, type, kind, categ);}
1142 | IDENTIFIER_LIST HPAREXPSEPARATOR
1143 HIDENTIFIER { regDecl($3, type, kind, categ);}
1145 IDENTIFIER_LISTC: HIDENTIFIER
1146 MBEE_CONSTANT { regDecl($1, type, kind, categ);
1148 | IDENTIFIER_LISTC HPAREXPSEPARATOR
1150 MBEE_CONSTANT { regDecl($3, type, kind, categ);
1153 MBEE_CONSTANT : /* EMPTY */
1156 if($1!=HEQ) yerror (8);
1157 if(type==TREF)yerror (7);
1161 EXPRESSION { mout(MASSIGN);
1165 /* GRAMATIKK FOR UTTRYKK */
1166 EXPRESSION : EXPRESSION_SIMP {}
1172 EXPRESSION { mout(MELSEE);
1175 EXPRESSION_SIMP : EXPRESSION_SIMP
1177 EXPRESSION { if($2==HASSIGNREF)mout(MASSIGNR);
1178 else mout(MASSIGN);$$=NULL;}
1183 EXPRESSION_SIMP { mout(MCONC);$$=NULL;}
1184 | EXPRESSION_SIMP HOR
1187 %prec HORELSE { mout(MORELSEE);$$=NULL;}
1188 | EXPRESSION_SIMP HAND
1191 %prec HANDTHEN { mout(MANDTHENE);$$=NULL;}
1193 HEQV EXPRESSION_SIMP { mout(MEQV);$$=NULL;}
1195 HIMP EXPRESSION_SIMP { mout(MIMP);$$=NULL;}
1197 HOR EXPRESSION_SIMP { mout(MOR);$$=NULL;}
1199 HAND EXPRESSION_SIMP { mout(MAND);$$=NULL;}
1200 | HNOT EXPRESSION_SIMP { mout(MNOT);$$=NULL;}
1205 { case HEQ: mout(MEQ);break;
1206 case HNE: mout(MNE);break;
1207 case HLT: mout(MLT);break;
1208 case HLE: mout(MLE);break;
1209 case HGT: mout(MGT);break;
1210 case HGE: mout(MGE);break;
1215 { if($2==HNER) mout(MNER);
1216 else mout(MEQR);$$=NULL;}
1220 { if($2==HIS) mout(MIS);
1221 else mout(MINS);$$=NULL;}
1223 EXPRESSION_SIMP %prec UNEAR
1224 { if($1==HADD) mout(MUADD);
1225 else mout(MUSUB);$$=NULL;}
1229 { if($2==HADD) mout(MADD);
1230 else mout(MSUB);$$=NULL;}
1234 { if($2==HMUL) mout(MMUL); else
1235 if($2==HDIV) mout(MDIV);
1236 else mout(MINTDIV);$$=NULL;}
1239 EXPRESSION_SIMP { mout(MPRIMARY);$$=NULL;}
1241 EXPRESSION HENDPAR { mout(MNOOP);$$=NULL;}
1242 | HTEXTKONST { mout(MTEXTKONST);
1243 moutTval($1);$$=NULL;}
1244 | HCHARACTERKONST { mout(MCHARACTERKONST);
1245 moutIval($1);$$=NULL;}
1246 | HREALKONST { mout(MREALKONST);
1247 moutRval($1);$$=NULL;}
1248 | HINTEGERKONST { mout(MINTEGERKONST);
1249 moutIval($1);$$=NULL;}
1250 | HBOOLEANKONST { mout(MBOOLEANKONST);
1251 moutIval($1);$$=NULL;}
1252 | HNONE { mout(MNONE);$$=NULL;}
1256 | HTHIS HIDENTIFIER { mout(MTHIS);
1257 moutId($2);$$=NULL;}
1260 ARG_R_PT { mout(MNEWARG);
1261 moutId($2);$$=NULL;}
1264 EXPRESSION_SIMP { mout(MDOT);$$=NULL;}
1266 HQUA HIDENTIFIER { mout(MQUA);
1267 moutId($3);$$=NULL;}
1269 ARG_R_PT : /*EMPTY*/ { mout(MENDSEP);}
1271 ARGUMENT_LIST HENDPAR
1273 MBEE_ARG_R_PT : /*EMPTY*/ { mout(MIDENTIFIER);
1277 ARGUMENT_LIST HENDPAR { mout(MARGUMENT);
1280 ARGUMENT_LIST : EXPRESSION { mout(MENDSEP);
1281 mout(MARGUMENTSEP);}
1284 ARGUMENT_LIST { mout(MARGUMENTSEP);}
1289 # Pass plenty of options, to exercise plenty of code, even if we
1290 # don't actually check the output. But SEGV is watching us, and
1291 # so might do dmalloc.
1292 AT_CHECK([[bison --verbose --defines input.y]], 0, [],
1293 [[input.y contains 78 shift/reduce conflicts and 10 reduce/reduce conflicts.
1296 AT_CHECK([[grep '^State.*contains' input.output]], 0,
1297 [[State 64 contains 14 shift/reduce conflicts.
1298 State 164 contains 1 shift/reduce conflict.
1299 State 201 contains 33 shift/reduce conflicts and 4 reduce/reduce conflicts.
1300 State 206 contains 1 shift/reduce conflict.
1301 State 240 contains 1 shift/reduce conflict.
1302 State 335 contains 9 shift/reduce conflicts and 2 reduce/reduce conflicts.
1303 State 356 contains 1 shift/reduce conflict.
1304 State 360 contains 9 shift/reduce conflicts and 2 reduce/reduce conflicts.
1305 State 427 contains 9 shift/reduce conflicts and 2 reduce/reduce conflicts.