inherit0.y revision 268899
1%{ 2extern 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) 7extern int YYLEX_DECL(); 8extern void YYERROR_DECL(); 9#endif 10%} 11 12%token GLOBAL LOCAL 13%token REAL INTEGER 14%token NAME 15 16%start declaration 17 18%% 19declaration: class type namelist 20 { $$ = $3; } 21 | type locnamelist 22 { $$ = $2; } 23 ; 24 25class : GLOBAL { $$ = 1; } 26 | LOCAL { $$ = 2; } 27 ; 28 29type : REAL { $$ = 1; } 30 | INTEGER { $$ = 2; } 31 ; 32 33namelist: namelist NAME 34 { mksymbol($0, $-1, $2); } 35 | NAME 36 { mksymbol($0, $-1, $1); } 37 ; 38 39locnamelist: 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 47extern int YYLEX_DECL(); 48extern void YYERROR_DECL(); 49