1 /* $NetBSD: inherit2.y,v 1.1.1.1 2015/01/03 22:58:23 christos Exp $ */
6 typedef
enum {cGLOBAL
, cLOCAL
} class
;
7 typedef
enum {tREAL
, tINTEGER
} type
;
10 struct symbol
{ class c
; type t
; name id
; };
11 typedef
struct symbol symbol
;
13 struct namelist
{ symbol
*s
; struct namelist
*next
; };
14 typedef
struct namelist namelist
;
16 extern symbol
*mksymbol
(type t
, class c
, name id
);
19 #define YYLEX_DECL() yylex(void)
20 #define YYERROR_DECL() yyerror(const char *s)
24 %token
<cval
> GLOBAL LOCAL
25 %token
<tval
> REAL INTEGER
28 %type
<nlist
> declaration namelist
(<cval
>, <tval
>) locnamelist
(<tval
>)
37 free
(pp
->s
); free
(pp
);
52 declaration: class type namelist
($1, $2)
54 | type locnamelist
($1)
58 class
: GLOBAL
{ $$
= cGLOBAL
; }
59 | LOCAL
{ $$
= cLOCAL
; }
62 type
: REAL
{ $$
= tREAL
; }
63 | INTEGER
{ $$
= tINTEGER
; }
66 namelist
($c, $t): namelist NAME
67 { $$
->s
= mksymbol
($
<tval
>t
, $
<cval
>c
, $2);
71 { $$
->s
= mksymbol
($t, $c, $1);
76 locnamelist
($t): namelist
(cLOCAL
, $t)
81 extern
int YYLEX_DECL
();
82 extern
void YYERROR_DECL
();