X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Foceani.mdc;h=a4110da2a970c1b60a6ad2e0f3be4f6243a2c1e0;hp=87b9070937364794fa68416eb296c0c32060ab78;hb=2c2269f21afd52650025b7255c000d33929ed635;hpb=50d5f6884a6c99e771b4907a03062955e7edbab5 diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 87b9070..a4110da 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -3019,10 +3019,11 @@ there. ###### Binode types CondExpr, -###### Grammar +###### declare terminals $LEFT if $$ifelse - ## expr precedence + +###### Grammar $*exec Expression -> Expression if Expression else Expression $$ifelse ${ { @@ -3141,7 +3142,7 @@ evaluate the second expression if not necessary. OrElse, Not, -###### expr precedence +###### declare terminals $LEFT or $LEFT and $LEFT not @@ -3289,7 +3290,7 @@ expression operator, and the `CMPop` non-terminal will match one of them. Eql, NEql, -###### expr precedence +###### declare terminals $LEFT < > <= >= == != CMPop ###### expression grammar @@ -3406,7 +3407,7 @@ should only insert brackets were needed for precedence. StringConv, Bracket, -###### expr precedence +###### declare terminals $LEFT + - Eop $LEFT * / % ++ Top $LEFT Uop $ @@ -3788,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. +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, @@ -3865,6 +3872,7 @@ is in-place. }$ $TERM pass + $*exec SimpleStatement -> pass ${ $0 = NULL; }$ | ERROR ${ tok_err(c, "Syntax error in statement", &$1); }$ ## SimpleStatement Grammar @@ -3948,28 +3956,28 @@ printed. ###### Binode types Print, -##### expr precedence +##### declare terminals $TERM print ###### SimpleStatement Grammar | print ExpressionList ${ - $0 = new(binode); - $0->op = Print; - $0->right = NULL; - $0->left = reorder_bilist($op = Print; + b->right = NULL; + b->left = reorder_bilist($op = Print; - $0->right = reorder_bilist($left = NULL; + $0 = b = new(binode); + b->op = Print; + b->right = reorder_bilist($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 @@ -4038,16 +4046,16 @@ it is declared, and error will be raised as the name is created as ###### 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 ${ @@ -4057,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 { - $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; } }$ @@ -4167,16 +4175,16 @@ function which has a return type, and the "condition" code blocks in ###### Binode types Use, -###### expr precedence +###### declare terminals $TERM use ###### 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; @@ -4330,7 +4338,7 @@ casepart` to track a list of case parts. ###### ComplexStatement Grammar | CondStatement ${ $0 = $<1; }$ -###### expr precedence +###### declare terminals $TERM for then while do $TERM else $TERM switch case