list. Other stand-alone statements will follow once the infrastructure
is in-place.
+As many statements will use binodes, we declare a binode pointer 'b' in
+the common header for all reductions to use.
+
+###### Parser: reduce
+ struct binode *b;
+
###### Binode types
Block,
}$
$TERM pass
+ $*exec
SimpleStatement -> pass ${ $0 = NULL; }$
| ERROR ${ tok_err(c, "Syntax error in statement", &$1); }$
## SimpleStatement Grammar
###### SimpleStatement Grammar
| print ExpressionList ${
- $0 = new(binode);
- $0->op = Print;
- $0->right = NULL;
- $0->left = reorder_bilist($<EL);
+ $0 = b = new(binode);
+ b->op = Print;
+ b->right = NULL;
+ b->left = reorder_bilist($<EL);
}$
| print ExpressionList , ${ {
- $0 = new(binode);
- $0->op = Print;
- $0->right = reorder_bilist($<EL);
- $0->left = NULL;
+ $0 = b = new(binode);
+ b->op = Print;
+ b->right = reorder_bilist($<EL);
+ b->left = NULL;
} }$
| print ${
- $0 = new(binode);
- $0->op = Print;
- $0->left = NULL;
- $0->right = NULL;
+ $0 = b = new(binode);
+ b->op = Print;
+ b->left = NULL;
+ b->right = NULL;
}$
###### print binode cases
###### SimpleStatement Grammar
| Variable = Expression ${
- $0 = new(binode);
- $0->op = Assign;
- $0->left = $<1;
- $0->right = $<3;
+ $0 = b= new(binode);
+ b->op = Assign;
+ b->left = $<1;
+ b->right = $<3;
}$
| VariableDecl = Expression ${
- $0 = new(binode);
- $0->op = Declare;
- $0->left = $<1;
- $0->right =$<3;
+ $0 = b= new(binode);
+ b->op = Declare;
+ b->left = $<1;
+ b->right =$<3;
}$
| VariableDecl ${
$1, NULL, 0, NULL);
free_var($1);
} else {
- $0 = new(binode);
- $0->op = Declare;
- $0->left = $<1;
- $0->right = NULL;
+ $0 = b = new(binode);
+ b->op = Declare;
+ b->left = $<1;
+ b->right = NULL;
}
}$
###### SimpleStatement Grammar
| use Expression ${
- $0 = new_pos(binode, $1);
- $0->op = Use;
- $0->right = $<2;
- if ($0->right->type == Xvar) {
- struct var *v = cast(var, $0->right);
+ $0 = b = new_pos(binode, $1);
+ b->op = Use;
+ b->right = $<2;
+ if (b->right->type == Xvar) {
+ struct var *v = cast(var, b->right);
if (v->var->type == Tnone) {
/* Convert this to a label */
struct value *val;