1 /* $NetBSD: btyacc_destroy3.y,v 1.1.1.1 2015/01/03 22:58:23 christos Exp $ */
4 struct parser_param
*param
,
11 typedef
enum {cGLOBAL
, cLOCAL
} class
;
12 typedef
enum {tREAL
, tINTEGER
} type
;
15 struct symbol
{ class c
; type t
; name id
; };
16 typedef
struct symbol symbol
;
18 struct namelist
{ symbol
*s
; struct namelist
*next
; };
19 typedef
struct namelist namelist
;
26 extern symbol
*mksymbol
(type t
, class c
, name id
);
29 #define YYLEX_DECL() yylex(void)
30 #define YYERROR_DECL() yyerror(const char *s)
34 %token
<cval
> GLOBAL LOCAL
35 %token
<tval
> REAL INTEGER
38 %type
<nlist
> declaration
39 %type
<nlist
> locnamelist
42 %type
<nlist
> namelist
44 %destructor
{ if
(!param
->rtrn
) close
($$
); } <file
>
51 free
(pp
->s
); free
(pp
);
66 declaration: class type namelist
'(' class
',' type
')'
68 | type locnamelist
'(' class
')'
72 class
: GLOBAL
{ $$
= cGLOBAL
; }
73 | LOCAL
{ $$
= cLOCAL
; }
76 type
: REAL
{ $$
= tREAL
; }
77 | INTEGER
{ $$
= tINTEGER
; }
80 namelist: namelist NAME
81 { $$
->s
= mksymbol
($
<tval
>0, $
<cval
>0, $2);
85 { $$
->s
= mksymbol
(0, 0, $1);
90 locnamelist: namelist
'(' LOCAL
',' type
')'
95 extern
int YYLEX_DECL
();
96 extern
void YYERROR_DECL
();