v = t->previous;
free_value(t->val);
- if (t->min_depth == 0)
+ if (t->depth == 0)
// This is a global constant
free_exec(t->where_decl);
free(t);
$0->f.type = $<3;
$0->f.init = val_init($3);
}$
+ | ERROR ${ tok_err(c, "Syntax error in struct field", &$1); }$
###### forward decls
static void structure_print_type(struct type *t, FILE *f);
/* This might be a label - allocate a var just in case */
v = var_decl(c, $1.txt);
if (v) {
- v->val = val_prepare(Tlabel);
- v->val.label = &v->val;
+ v->val = val_prepare(Tnone);
+ v->where_decl = $0;
v->where_set = $0;
}
}
v->where_decl, NULL, 0, NULL);
return v->val.type;
}
+ if (v->val.type == Tnone && v->where_decl == prog)
+ type_err(c, "error: variable used but not declared: %v",
+ prog, NULL, 0, NULL);
if (v->val.type == NULL) {
if (type && *ok != 0) {
v->val = val_prepare(type);
| SimpleStatements ; ${ $0 = $<1; }$
SimpleStatement -> pass ${ $0 = NULL; }$
+ | ERROR ${ tok_err(c, "Syntax error in statement", &$1); }$
## SimpleStatement Grammar
###### print binode cases
$0 = new_pos(binode, $1);
$0->op = Use;
$0->right = $<2;
+ if ($0->right->type == Xvar) {
+ struct var *v = cast(var, $0->right);
+ if (v->var->val.type == Tnone) {
+ /* Convert this to a label */
+ v->var->val = val_prepare(Tlabel);
+ v->var->val.label = &v->var->val;
+ }
+ }
}$
###### print binode cases
| DeclareProgram
| DeclareStruct
| NEWLINE
+ | ERROR NEWLINE ${
+ tok_err(c,
+ "error: unhandled parse error", &$1);
+ }$
## top level grammar
v->val = interp_exec($5);
}
} }$
+ | ERROR NEWLINE ${ tok_err(c, "Syntax error in constant", &$1); }$
###### print const decls
{
$0->left = reorder_bilist($<3);
$0->right = $<4;
var_block_close(c, CloseSequential);
- if (c->scope_stack) abort();
+ if (c->scope_stack && !c->parse_error) abort();
}$
| ERROR ${
tok_err(c,