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