]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani.mdc
oceani: fix up the while/do scope
[ocean] / csrc / oceani.mdc
index 364ee290ab54ca10d0e825d9d128edd5b15ea0b2..2a40ff203efa442fa148610521cb016070c13974 100644 (file)
@@ -3873,12 +3873,14 @@ defined.
                        $0->condpart = $<SP;
                        $CP->next = $0->casepart;
                        $0->casepart = $<CP;
+                       var_block_close(c, CloseSequential);
                        }$
                | SwitchPart : IN OptNL CasePart CondSuffix OUT Newlines ${
                        $0 = $<CS;
                        $0->condpart = $<SP;
                        $CP->next = $0->casepart;
                        $0->casepart = $<CP;
+                       var_block_close(c, CloseSequential);
                        }$
                | IfPart IfSuffix ${
                        $0 = $<IS;
@@ -3890,9 +3892,6 @@ defined.
 
        CondSuffix -> IfSuffix ${
                        $0 = $<1;
-                       // This is where we close scope of the whole
-                       // "for" or "while" statement
-                       var_block_close(c, CloseSequential);
                }$
                | Newlines CasePart CondSuffix ${
                        $0 = $<CS;
@@ -3929,7 +3928,7 @@ defined.
                }$
 
        $*exec
-       // These scopes are closed in CondSuffix
+       // These scopes are closed in CondStatement
        ForPart -> for OpenBlock ${
                        $0 = $<Bl;
                }$
@@ -3940,14 +3939,16 @@ defined.
                }$
 
        $cond_statement
-       // This scope is closed in CondSuffix
+       // This scope is closed in CondStatement
        WhilePart -> while UseBlock OptNL do Block ${
                        $0.condpart = $<UB;
                        $0.dopart = $<Bl;
+                       var_block_close(c, CloseSequential);
                }$
                | while OpenScope Expression ColonBlock ${
                        $0.condpart = $<Exp;
                        $0.dopart = $<Bl;
+                       var_block_close(c, CloseSequential);
                }$
 
        IfPart -> if UseBlock OptNL then OpenBlock ClosePara ${
@@ -3964,7 +3965,7 @@ defined.
                }$
 
        $*exec
-       // This scope is closed in CondSuffix
+       // This scope is closed in CondStatement
        SwitchPart -> switch OpenScope Expression ${
                        $0 = $<Ex;
                }$
@@ -4574,13 +4575,14 @@ things which will likely grow as the languages grows.
                        else
                                hi = mid
                        if hi - lo < 1:
+                               lo = mid
                                use GiveUp
                        use True
                do pass
                case Found:
                        print "Yay, I found", target
                case GiveUp:
-                       print "Closest I found was", mid
+                       print "Closest I found was", lo
 
                size::= 10
                list:[size]number