]> ocean-lang.org Git - ocean/commitdiff
oceani: change SimpleStatement to be $*exec, not $*binode
authorNeilBrown <neil@brown.name>
Sat, 20 Nov 2021 05:37:04 +0000 (16:37 +1100)
committerNeilBrown <neil@brown.name>
Tue, 23 Nov 2021 22:31:01 +0000 (09:31 +1100)
All current SimpleStatements are binode, but future ones may not be.
So change to $*exec.
Declare a binode '*b' in 'reduce' header so the variable is
always available.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani.mdc

index ca6f5d77d0296e6118146b27b51d6391b42f619f..a4110da2a970c1b60a6ad2e0f3be4f6243a2c1e0 100644 (file)
@@ -3789,6 +3789,12 @@ which does nothing and is represented as a `NULL` pointer in a `Block`
 list.  Other stand-alone statements will follow once the infrastructure
 is in-place.
 
 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,
 
 ###### Binode types
        Block,
 
@@ -3866,6 +3872,7 @@ is in-place.
                        }$
 
        $TERM pass
                        }$
 
        $TERM pass
+       $*exec
        SimpleStatement -> pass ${ $0 = NULL; }$
                | ERROR ${ tok_err(c, "Syntax error in statement", &$1); }$
                ## SimpleStatement Grammar
        SimpleStatement -> pass ${ $0 = NULL; }$
                | ERROR ${ tok_err(c, "Syntax error in statement", &$1); }$
                ## SimpleStatement Grammar
@@ -3955,22 +3962,22 @@ printed.
 ###### SimpleStatement Grammar
 
        | print ExpressionList ${
 ###### 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 , ${ {
        }$
        | 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 ${
        } }$
        | 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
        }$
 
 ###### print binode cases
@@ -4039,16 +4046,16 @@ it is declared, and error will be raised as the name is created as
 
 ###### SimpleStatement Grammar
        | Variable = Expression ${
 
 ###### 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 ${
                }$
        | 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 ${
                }$
 
        | VariableDecl ${
@@ -4058,10 +4065,10 @@ it is declared, and error will be raised as the name is created as
                                         $1, NULL, 0, NULL);
                                free_var($1);
                        } else {
                                         $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;
                        }
                }$
 
                        }
                }$
 
@@ -4173,11 +4180,11 @@ function which has a return type, and the "condition" code blocks in
 
 ###### SimpleStatement Grammar
        | use Expression ${
 
 ###### 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;
                        if (v->var->type == Tnone) {
                                /* Convert this to a label */
                                struct value *val;