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