1 /* $NetBSD: btyacc_destroy2.y,v 1.1.1.1 2015/01/03 22:58:23 christos Exp $ */
3 %parse
-param
{ struct parser_param
*param
} { int flag
}
8 typedef
enum {cGLOBAL
, cLOCAL
} class
;
9 typedef
enum {tREAL
, tINTEGER
} type
;
12 struct symbol
{ class c
; type t
; name id
; };
13 typedef
struct symbol symbol
;
15 struct namelist
{ symbol
*s
; struct namelist
*next
; };
16 typedef
struct namelist namelist
;
23 extern symbol
*mksymbol
(type t
, class c
, name id
);
26 #define YYLEX_DECL() yylex(void)
27 #define YYERROR_DECL() yyerror(const char *s)
31 %token
<cval
> GLOBAL LOCAL
32 %token
<tval
> REAL INTEGER
35 %type
<nlist
> declaration
36 %type
<nlist
> locnamelist
39 %type
<nlist
> namelist
41 %destructor
{ if
(!param
->rtrn
) close
($$
); } <file
>
48 free
(pp
->s
); free
(pp
);
63 declaration: class type namelist
'(' class
',' type
')'
65 | type locnamelist
'(' class
')'
69 class
: GLOBAL
{ $$
= cGLOBAL
; }
70 | LOCAL
{ $$
= cLOCAL
; }
73 type
: REAL
{ $$
= tREAL
; }
74 | INTEGER
{ $$
= tINTEGER
; }
77 namelist: namelist NAME
78 { $$
->s
= mksymbol
($
<tval
>0, $
<cval
>0, $2);
82 { $$
->s
= mksymbol
(0, 0, $1);
87 locnamelist: namelist
'(' LOCAL
',' type
')'
92 extern
int YYLEX_DECL
();
93 extern
void YYERROR_DECL
();