1 # Exercising Bison on actual grammars. -*- Autotest -*-
2 # Copyright (C) 2002 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([[Existing Grammars.]])
20 ## ----------------- ##
21 ## GNU AWK Grammar. ##
22 ## ----------------- ##
24 AT_SETUP([GNU AWK Grammar])
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.
30 # Bison was once wrong, due to an incorrect computation of nullable.
31 # It reported 485 SR conflicts!
36 %token FUNC_CALL NAME REGEXP
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
46 %token LEX_AND LEX_OR INCREMENT DECREMENT
47 %token LEX_BUILTIN LEX_LENGTH
49 /* Lowest to highest */
56 %left FUNC_CALL LEX_BUILTIN LEX_LENGTH
59 %nonassoc RELOP '<' '>' '|' APPEND_OP TWOWAYIO
66 %left INCREMENT DECREMENT
72 : opt_nls program opt_nls
86 | LEX_BEGIN statement_term
87 | LEX_END statement_term
90 | pattern statement_term
91 | function_prologue function_body
106 : LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls
110 : l_brace statements r_brace opt_semi opt_nls
111 | l_brace r_brace opt_semi opt_nls
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.
129 : l_brace statements r_brace opt_semi opt_nls
130 | l_brace r_brace opt_semi opt_nls
135 | statements statement
148 | l_brace statements r_brace
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
174 : LEX_IF '(' exp r_paren opt_nls statement
175 | LEX_IF '(' exp r_paren opt_nls statement
176 LEX_ELSE opt_nls statement
209 | param_list comma NAME
212 | param_list comma error
215 /* optional expression, as in for loop */
228 | rexpression_list comma rexp
230 | rexpression_list error
231 | rexpression_list error rexp
232 | rexpression_list comma error
242 | expression_list comma exp
244 | expression_list error
245 | expression_list error exp
246 | expression_list comma error
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
259 | '!' regexp %prec UNARY
264 | exp '?' exp ':' exp
266 | exp simp_exp %prec CONCAT_OP
270 : variable ASSIGNOP {} rexp
273 | LEX_GETLINE opt_variable input_redir
275 | '!' regexp %prec UNARY
279 | rexp '?' rexp ':' rexp
281 | rexp simp_exp %prec CONCAT_OP
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
298 : '!' simp_exp %prec UNARY
301 '(' opt_expression_list r_paren
302 | LEX_LENGTH '(' opt_expression_list r_paren
304 | FUNC_CALL '(' opt_expression_list r_paren
310 | '-' simp_exp %prec UNARY
311 | '+' simp_exp %prec UNARY
321 | NAME '[' expression_list ']'
322 | '$' non_post_simp_exp
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]])
360 ## ----------------- ##
361 ## GNU Cim Grammar. ##
362 ## ----------------- ##
364 AT_SETUP([GNU Cim Grammar])
366 # GNU Cim, the GNU Simula 87 Compiler.
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!!!
383 HACTIVATE HAFTER /*HAND*/ HARRAY HAT
384 HBEFORE HBEGIN HBOOLEAN
385 HCHARACTER HCLASS /*HCOMMENT*/ HCONC
387 HELSE HEND HEQ /*HEQV*/ HEXTERNAL
391 HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS
393 HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT
395 HPRIOR HPROCEDURE HPROTECTED
397 HREACTIVATE HREAL HREF
399 HTEXT HTHEN HTHIS HTO
404 HASSIGNVALUE HASSIGNREF
405 /*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR
408 HADD HSUB HMUL HDIV HINTDIV HEXP
411 %token <ident> HIDENTIFIER
412 %token <ival> HBOOLEANKONST HINTEGERKONST HCHARACTERKONST
413 %token <rval> HREALKONST
414 %token <tval> HTEXTKONST
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
422 %right <token> HASSIGN
432 %left <token> HVALRELOPERATOR HREFRELOPERATOR HOBJRELOPERATOR
436 %left <token> HTERMOPERATOR
438 %left <token> HFACTOROPERATOR
439 %left HPRIMARYOPERATOR
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
453 EXT_DECLARATION : HEXTERNAL
466 if($2==Ckind)categ=CCPROC;else
468 ysensitive=sensitive;
470 HIDENTIFIER { $<ident>$=$5;
471 sensitive=ysensitive;}
481 EXTERNAL_KIND_ITEM: EXT_IDENT
483 { if($2!=HIS)yerror (2);}
486 { regDecl($6, type, KPROC, CCPROC);
490 endBlock($1==NULL?$<ident>0:tag($1),CCCPROC);}
493 { if($1!=NULL)yerror (3);
494 regDecl($0, type, kind, categ);}
496 { endBlock(NULL,CCNO);}
498 MBEE_REST_EXT_LIST: /* EMPTY
499 | HPAREXPSEPARATOR EXT_KIND_LIST
501 EXT_KIND_LIST : EXT_KIND_ITEM
502 | EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM
504 EXT_KIND_ITEM : HIDENTIFIER
506 { if($2!=NULL)yerror (3);
507 regDecl($1, type, kind, categ);}*/
509 EMPTY_BLOCK : /*EMPT*/
513 | EXT_LIST HPAREXPSEPARATOR EXT_ITEM
515 EXT_ITEM : HIDENTIFIER
517 { lesinn_external_spec($1,$2, kind);}
519 EXT_IDENT : /* EMPTY */ { $$=NULL;}
520 | HVALRELOPERATOR { if($1!=HEQ)yerror (9);
522 HTEXTKONST { $$=$3;external=FALSE;}
524 /* GRAMATIKK FOR TYPER */
525 NO_TYPE : /*EMPT*/ { type=TNOTY;}
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;}
544 /* GRAMATIKK FOR DEL AV SETNINGER */
545 MBEE_ELSE_PART : /*EMPT*/
552 BLOCK { MBEEENDBLOCK();}
553 MBEE_ELSE_PART { mout(MENDIF);}*/
554 | HELSE { OBSBLOCK(); mout(MELSE);}
555 BLOCK { MBEEENDBLOCK();}
557 FOR_LIST : FOR_LIST_ELEMENT { mout(MENDSEP);
561 FOR_LIST { mout(MLISTSEP);}
563 FOR_LIST_ELEMENT: EXPRESSION
566 MBEE_F_L_EL_R_PT: /*EMPT*/
568 EXPRESSION { mout(MFORWHILE);}
572 EXPRESSION { mout(MUNTIL);
579 CONN_STATE_R_PT : WHEN_CLAUSE_LIST
580 | HDO { beginBlock(KCON); mout(MDO);
582 BLOCK { endBlock(NULL,CCNO);
583 MBEEENDBLOCK(); mout(MENDDO);}
585 WHEN_CLAUSE_LIST: HWHEN
587 HDO { beginBlock(KCON); mout(MIDENTIFIER);
588 OBSBLOCK(); moutId($2);
590 BLOCK { endBlock(NULL,CCNO);
591 MBEEENDBLOCK(); mout(MENDWHEN);}
595 HDO { beginBlock(KCON); mout(MIDENTIFIER);
596 OBSBLOCK(); moutId($3);
598 BLOCK { endBlock(NULL,CCNO);
599 MBEEENDBLOCK(); mout(MENDWHEN);}
601 MBEE_OTWI_CLAUS : /*EMPT*/
602 | HOTHERWISE {OBSBLOCK(); mout(MOTHERWISE);}
604 BLOCK {MBEEENDBLOCK();mout(MENDOTHERWISE);}
606 ACTIVATOR : HACTIVATE { mout(MBOOLEANKONST);
608 | HREACTIVATE { mout(MBOOLEANKONST);
611 SCHEDULE : /*EMPT*/ { mout(MCHARACTERKONST);
618 | ATDELAY EXPRESSION { mout(MNONE);}
620 | BEFOREAFTER { mout(MINTEGERKONST);
622 EXPRESSION { mout(MBOOLEANKONST);
625 ATDELAY : HAT { mout(MCHARACTERKONST);
627 | HDELAY { mout(MCHARACTERKONST);
630 BEFOREAFTER : HBEFORE { mout(MCHARACTERKONST);
632 | HAFTER { mout(MCHARACTERKONST);
635 PRIOR : /*EMPT*/ { mout(MBOOLEANKONST);
637 | HPRIOR { mout(MBOOLEANKONST);
640 /* GRAMATIKK FOR SETNINGER OG DEKLARASJONER */
641 MODULSTATEMENT : HWHILE
643 HDO { STOPOBSBLOCK(); mout(MWHILE);
645 BLOCK { MBEEENDBLOCK(); mout(MENDWHILE);
649 HTHEN { STOPOBSBLOCK(); mout(MIF);
651 BLOCK { MBEEENDBLOCK();}
652 MBEE_ELSE_PART { mout(MENDIF);
656 HASSIGN { STOPOBSBLOCK(); mout(MIDENTIFIER);
659 HDO { beginBlock(KFOR);
660 if($3==HASSIGNVALUE) mout(MFOR);
662 OBSBLOCK(); mout(MFORDO);}
663 BLOCK { MBEEENDBLOCK();
664 endBlock(NULL,CCNO); mout(MENDFOR);
667 EXPRESSION { mout(MGOTO);
668 STOPOBSBLOCK(); $$=STATEMENT;}
670 EXPRESSION { mout(MINSPECT);
674 { endBlock(NULL,CCNO);}
675 MBEE_OTWI_CLAUS { mout(MENDINSPECT);
677 | HINNER { STOPOBSBLOCK(); mout(MINNER);
678 regInner(); $$=STATEMENT;}
682 regDecl($1, TLABEL, KSIMPLE, categ); mout(MLABEL);
685 DECLSTATEMENT { if($4<=DECLARATION)
697 HEND { endBlock(NULL,CCNO); mout(MENDPRBLOCK);
699 | EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR
700 MBEE_DECLSTMS HEND { $$=STATEMENT;
701 endBlock(NULL,CCNO); mout(MENDPRBLOCK);}
702 | EXPRESSION_SIMP HBEGIN error HEND
704 endBlock(NULL,CCNO); mout(MENDPRBLOCK);}
707 { STOPOBSBLOCK(); $$=STATEMENT;
709 | ACTIVATOR EXPRESSION SCHEDULE
725 HEND { MBEEENDBLOCK(); $$=STATEMENT;}
726 | MBEE_TYPE HPROCEDURE
728 { MBEENEWBLOCK(); mout(MPROCEDURE);
729 regDecl($3, type, KPROC, categ);
731 HEADING BLOCK { endBlock(NULL,CCNO); $$=DECLARATION;
732 mout(MENDPROCEDURE);}
741 regDecl($6, TNOTY, KCLASS, categ);
744 BLOCK { endBlock(NULL,CCNO); $$=DECLARATION;
750 MBEENEWBLOCK(); mout(MCLASS);
751 regDecl($3, TNOTY, KCLASS, categ);
754 BLOCK { endBlock(NULL,CCNO); $$=DECLARATION;
756 | EXT_DECLARATION { $$=EXTDECLARATION;}
757 | /*EMPT*/{ STOPOBSBLOCK(); $$=EMPTYSTATEMENT;}
759 IMPORT_SPEC_MODULE: { MBEENEWBLOCK();
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,
790 DECLSTATEMENT : MODULSTATEMENT
797 regDecl($2, type, KSIMPLE, categ);
799 IDENTIFIER_LISTC { $$=DECLARATION;}
804 regDecl($2, type, KSIMPLE, categ);
805 categ=CLOCAL; $$=DECLARATION;}
807 HARRAY { MBEENEWBLOCK();
809 ARR_SEGMENT_LIST { $$=DECLARATION;}
812 HASSIGN { MBEENEWBLOCK(); mout(MIDENTIFIER);
814 regDecl($2, TLABEL, KARRAY, categ);}
815 SWITCH_LIST { $$=DECLARATION;
819 BLOCK : DECLSTATEMENT { if($1<=DECLARATION)yerror (29);}
820 | HBEGIN MBEE_DECLSTMS HEND
821 | HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND
824 MBEE_DECLSTMS : MBEE_DECLSTMSU { if($1<=DECLARATION)yerror (28);
827 MBEE_DECLSTMSU : DECLSTATEMENT { $$=$1;}
830 DECLSTATEMENT { if($1>=STATEMENT && $3<=DECLARATION)
834 MODULS : MODULSTATEMENT { if($1==DECLARATION)
835 {separat_comp=TRUE;gettimestamp();}
837 | MODULS HSTATEMENTSEPARATOR MODULSTATEMENT
838 { if($1>=STATEMENT && $3<=DECLARATION)
841 && $3!=EMPTYSTATEMENT)yerror (25);
842 if(separat_comp && $3==STATEMENT)
844 if($3==DECLARATION && !separat_comp)
845 {separat_comp=TRUE;gettimestamp();}
848 /* GRAMATIKK FOR DEL AV DEKLARASJONER */
849 ARR_SEGMENT_LIST: ARR_SEGMENT
854 ARR_SEGMENT : ARRAY_SEGMENT
856 BAUND_PAIR_LIST HENDPAR { mout(MARRAY);
860 ARRAY_SEGMENT : ARRAY_SEGMENT_EL { mout(MENDSEP);
865 ARRAY_SEGMENT { mout(MARRAYSEP);}
867 ARRAY_SEGMENT_EL: HIDENTIFIER { mout(MIDENTIFIER);
869 regDecl($1, type, kind, categ);
871 lastArray=cblock->lastparloc;}
873 BAUND_PAIR_LIST : BAUND_PAIR { mout(MENDSEP);
878 BAUND_PAIR_LIST { mout(MBOUNDSEP);
881 BAUND_PAIR : EXPRESSION
883 EXPRESSION { mout(MBOUNDPARSEP);}
885 SWITCH_LIST : EXPRESSION { mout(MENDSEP);
889 SWITCH_LIST { mout(MSWITCHSEP);}
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;}
898 MBEE_FMAL_PAR_P : /*EMPT*/
901 FMAL_PAR_PART : HBEGPAR NO_TYPE
904 MBEE_LISTV : /*EMPT*/
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 {}
913 HPAREXPSEPARATOR LISTV
915 FPP_HEADING : HBEGPAR NO_TYPE
916 FPP_MBEE_LISTV HENDPAR
918 FPP_MBEE_LISTV : /*EMPT*/
921 FPP_LISTV : FPP_CATEG HDOTDOTDOT { regDecl(varargsid, TVARARGS, KNOKD, categ);}
924 HPAREXPSEPARATOR LISTV
926 FPP_SPEC : FPP_CATEG SPECIFIER HIDENTIFIER
927 { regDecl($3, type, kind, categ);}
928 | FPP_CATEG FPP_PROC_DECL_IN_SPEC
930 FPP_CATEG : HNAME HLABELSEPARATOR
932 | HVALUE HLABELSEPARATOR
934 | HVAR HLABELSEPARATOR
936 | /*EMPT*/ { categ=CDEFLT;}
938 FPP_PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE
941 regDecl($3, type, KPROC, categ);
944 { categ=$<ival>4; /* M} settes tilbake*/}
945 { endBlock(NULL,CCNO);}
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 {}
952 MBEE_MODE_PART : /*EMPT*/
955 MODE_PART : NAME_PART
958 | NAME_PART VALUE_PART
959 | VALUE_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
971 NAME_PART : HNAME { categ=CNAME;}
975 VAR_PART : HVAR { categ=CVAR;}
979 VALUE_PART : HVALUE { categ=CVALUE;}
980 IDENTIFIER_LISTV HSTATEMENTSEPARATOR
982 MBEE_SPEC_PART : /*EMPT*/
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
995 | MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR
996 IDENTIFIER_LIST HSTATEMENTSEPARATOR
999 SPECIFIER : TYPE { kind=KSIMPLE;}
1001 HARRAY { kind=KARRAY;}
1002 | HLABEL { type=TLABEL;
1004 | HSWITCH { type=TLABEL;
1007 PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE
1010 regDecl($3, type, KPROC, categ);
1013 { categ=$<ival>4; /* M} settes tilbake*/}
1015 { endBlock(NULL,CCNO);}
1017 MBEE_BEGIN_END : /* EMPTY */
1020 MBEE_PROT_PART : /*EMPT*/
1023 PROTECTION_PART : PROT_SPECIFIER IDENTIFIER_LIST
1025 | PROTECTION_PART PROT_SPECIFIER
1026 IDENTIFIER_LIST HSTATEMENTSEPARATOR
1028 PROT_SPECIFIER : HHIDDEN { categ=CHIDEN;}
1029 | HPROTECTED { categ=CPROT;}
1031 HPROTECTED { categ=CHIPRO;}
1033 HHIDDEN { categ=CHIPRO;}
1035 MBEE_VIRT_PART : /*EMPT*/
1038 VIRTUAL_PART : HVIRTUAL
1042 IDENTIFIER_LIST : HIDENTIFIER { regDecl($1, type, kind, categ);}
1043 | IDENTIFIER_LIST HPAREXPSEPARATOR
1044 HIDENTIFIER { regDecl($3, type, kind, categ);}
1046 IDENTIFIER_LISTC: HIDENTIFIER
1047 MBEE_CONSTANT { regDecl($1, type, kind, categ);
1049 | IDENTIFIER_LISTC HPAREXPSEPARATOR
1051 MBEE_CONSTANT { regDecl($3, type, kind, categ);
1054 MBEE_CONSTANT : /* EMPTY */
1057 if($1!=HEQ) yerror (8);
1058 if(type==TREF)yerror (7);
1062 EXPRESSION { mout(MASSIGN);
1066 /* GRAMATIKK FOR UTTRYKK */
1067 EXPRESSION : EXPRESSION_SIMP {}
1073 EXPRESSION { mout(MELSEE);
1076 EXPRESSION_SIMP : EXPRESSION_SIMP
1078 EXPRESSION { if($2==HASSIGNREF)mout(MASSIGNR);
1079 else mout(MASSIGN);$$=NULL;}
1084 EXPRESSION_SIMP { mout(MCONC);$$=NULL;}
1085 | EXPRESSION_SIMP HOR
1088 %prec HORELSE { mout(MORELSEE);$$=NULL;}
1089 | EXPRESSION_SIMP HAND
1092 %prec HANDTHEN { mout(MANDTHENE);$$=NULL;}
1094 HEQV EXPRESSION_SIMP { mout(MEQV);$$=NULL;}
1096 HIMP EXPRESSION_SIMP { mout(MIMP);$$=NULL;}
1098 HOR EXPRESSION_SIMP { mout(MOR);$$=NULL;}
1100 HAND EXPRESSION_SIMP { mout(MAND);$$=NULL;}
1101 | HNOT EXPRESSION_SIMP { mout(MNOT);$$=NULL;}
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;
1116 { if($2==HNER) mout(MNER);
1117 else mout(MEQR);$$=NULL;}
1121 { if($2==HIS) mout(MIS);
1122 else mout(MINS);$$=NULL;}
1124 EXPRESSION_SIMP %prec UNEAR
1125 { if($1==HADD) mout(MUADD);
1126 else mout(MUSUB);$$=NULL;}
1130 { if($2==HADD) mout(MADD);
1131 else mout(MSUB);$$=NULL;}
1135 { if($2==HMUL) mout(MMUL); else
1136 if($2==HDIV) mout(MDIV);
1137 else mout(MINTDIV);$$=NULL;}
1140 EXPRESSION_SIMP { mout(MPRIMARY);$$=NULL;}
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;}
1157 | HTHIS HIDENTIFIER { mout(MTHIS);
1158 moutId($2);$$=NULL;}
1161 ARG_R_PT { mout(MNEWARG);
1162 moutId($2);$$=NULL;}
1165 EXPRESSION_SIMP { mout(MDOT);$$=NULL;}
1167 HQUA HIDENTIFIER { mout(MQUA);
1168 moutId($3);$$=NULL;}
1170 ARG_R_PT : /*EMPTY*/ { mout(MENDSEP);}
1172 ARGUMENT_LIST HENDPAR
1174 MBEE_ARG_R_PT : /*EMPTY*/ { mout(MIDENTIFIER);
1178 ARGUMENT_LIST HENDPAR { mout(MARGUMENT);
1181 ARGUMENT_LIST : EXPRESSION { mout(MENDSEP);
1182 mout(MARGUMENTSEP);}
1185 ARGUMENT_LIST { mout(MARGUMENTSEP);}
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: warning: 78 shift/reduce conflicts and 10 reduce/reduce conflicts
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.