+ v->where_decl, Tnone, 0, Tnone);
+ }
+ } }$
+ | IDENTIFIER : Type = ${ {
+ struct variable *v = var_decl(config2context(config), $1.txt);
+ $0 = new_pos(var, $1);
+ $0->var = v;
+ if (v) {
+ v->where_decl = $0;
+ v->where_set = $0;
+ v->val = val_init($<3);
+ } else {
+ v = var_ref(config2context(config), $1.txt);
+ $0->var = v;
+ type_err(config2context(config), "error: variable '%v' redeclared",
+ $0, Tnone, 0, Tnone);
+ type_err(config2context(config), "info: this is where '%v' was first declared",
+ v->where_decl, Tnone, 0, Tnone);
+ }
+ } }$
+ | IDENTIFIER :: Type = ${ {
+ struct variable *v = var_decl(config2context(config), $1.txt);
+ $0 = new_pos(var, $1);
+ $0->var = v;
+ if (v) {
+ v->where_decl = $0;
+ v->where_set = $0;
+ v->val = val_init($<3);
+ v->constant = 1;
+ } else {
+ v = var_ref(config2context(config), $1.txt);
+ $0->var = v;
+ type_err(config2context(config), "error: variable '%v' redeclared",
+ $0, Tnone, 0, Tnone);
+ type_err(config2context(config), "info: this is where '%v' was first declared",
+ v->where_decl, Tnone, 0, Tnone);