1 /* $NetBSD: err_inherit4.y,v 1.1.1.1 2015/01/03 22:58:23 christos Exp $ */
7 typedef
enum {cGLOBAL
, cLOCAL
} class
;
8 typedef
enum {tREAL
, tINTEGER
} type
;
11 struct symbol
{ class c
; type t
; name id
; };
12 typedef
struct symbol symbol
;
14 struct namelist
{ symbol
*s
; struct namelist
*next
; };
15 typedef
struct namelist namelist
;
17 extern symbol
*mksymbol
(type t
, class c
, name id
);
20 #define YYLEX_DECL() yylex(void)
21 #define YYERROR_DECL() yyerror(const char *s)
25 %token
<cval
> GLOBAL LOCAL
26 %token
<tval
> REAL INTEGER
29 %type
<nlist
> declaration namelist
(<cval
>, <tval
>) locnamelist
(<tval
>)
30 %destructor
{ } <nlist
>
39 free
(pp
->s
); free
(pp
);
54 declaration: class type namelist
($1, $2)
56 | type locnamelist
($1)
60 class
: GLOBAL
{ $$
= cGLOBAL
; }
61 | LOCAL
{ $$
= cLOCAL
; }
64 type
: REAL
{ $$
= tREAL
; }
65 | INTEGER
{ $$
= tINTEGER
; }
68 namelist
($c, $t): namelist NAME
69 { $$
->s
= mksymbol
($t, $c, $2);
73 { $$
->s
= mksymbol
($t, $c, $1);
78 locnamelist
($t): namelist
83 extern
int YYLEX_DECL
();
84 extern
void YYERROR_DECL
();