1 /* $NetBSD: inherit1.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)
21 extern
int YYLEX_DECL
();
22 extern
void YYERROR_DECL
();
26 %token
<cval
> GLOBAL LOCAL
27 %token
<tval
> REAL INTEGER
30 %type
<nlist
> declaration namelist locnamelist
45 declaration: class type namelist
51 class
: GLOBAL
{ $$
= cGLOBAL
; }
52 | LOCAL
{ $$
= cLOCAL
; }
55 type
: REAL
{ $$
= tREAL
; }
56 | INTEGER
{ $$
= tINTEGER
; }
59 namelist: namelist NAME
60 { $$
->s
= mksymbol
($
<tval
>0, $
<cval
>-1, $2);
64 { $$
->s
= mksymbol
($
<tval
>0, $
<cval
>-1, $1);
70 { $
<cval
>$
= cLOCAL
; } /* set up semantic stack for <class> = LOCAL */
71 { $
<tval
>$
= $
<tval
>-1; } /* copy <type> to where <namelist> expects it */
77 extern
int YYLEX_DECL
();
78 extern
void YYERROR_DECL
();