+ if (def->type->strct) {
+ P->structs = add_decl_struct(P->structs, def->type->strct);
+ }
+}
+block ::= constant(constant). {
+ P->consts = add_constant(P->consts, constant);
+}
+block ::= decl_struct(strct). {
+ P->structs = add_decl_struct(P->structs, strct);
+}
+
+%type decl_struct {decl_struct*}
+%destructor decl_struct {free_decl_struct($$);}
+decl_struct(strct) ::= STRUCT NAME(N) struct_size(size_) LBRACE struct_args(args) RBRACE. {
+ strct = init_decl_struct(N->text, args);
+ strct->size = size_;
+ free(N);
+}
+
+%type struct_size {size_t}
+struct_size(size) ::= . {
+ size = 0;
+}
+struct_size(size) ::= COLON COLON LPAREN NUMBER(SIZ) RPAREN. {
+ size = atol(SIZ->text);
+ free(SIZ);
+}
+
+%token_class const_type_token BOOL INT FLOAT STRING.
+%type const_type {const_type*}
+%destructor const_type {free_const_type($$);}
+const_type(type_) ::= const_type_token(T). {
+ type_ = init_const_type(T->type, T->text);
+ free(T);
+}
+%type constant {constant*}
+%destructor constant {free_constant($$);}
+constant(constant) ::= CONST const_type(type) NSNAME(T) EQUALS impl_def_val(val) EOS. {
+ constant = init_constant(type, T->text, val);
+ free(T);