1 /* $NetBSD: inherit0.y,v 1.1.1.3 2016/01/09 21:59:45 christos Exp $ */ 2 3 %{ 4 extern void mksymbol(int t, int c, int id); 5 6 #ifdef YYBISON 7 #define YYLEX_DECL() yylex(void) 8 #define YYERROR_DECL() yyerror(const char *s) 9 extern int YYLEX_DECL(); 10 extern void YYERROR_DECL(); 11 #endif 12 %} 13 14 %token GLOBAL LOCAL 15 %token REAL INTEGER 16 %token NAME 17 18 %start declaration 19 20 %% 21 declaration: class type namelist 22 { $$ = $3; } 23 | type locnamelist 24 { $$ = $2; } 25 ; 26 27 class : GLOBAL { $$ = 1; } 28 | LOCAL { $$ = 2; } 29 ; 30 31 type : REAL { $$ = 1; } 32 | INTEGER { $$ = 2; } 33 ; 34 35 namelist: namelist NAME 36 { mksymbol($0, $-1, $2); } 37 | NAME 38 { mksymbol($0, $-1, $1); } 39 ; 40 41 locnamelist: 42 { $$ = 2; } /* set up semantic stack for <class>: LOCAL */ 43 { $$ = $-1; } /* copy <type> to where <namelist> expects it */ 44 namelist 45 { $$ = $3; } 46 ; 47 %% 48 49 extern int YYLEX_DECL(); 50 extern void YYERROR_DECL(); 51