X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Foceani.mdc;h=d1967562fdf6f1c94731f151f26c73ba3a1c47a0;hp=2a40ff203efa442fa148610521cb016070c13974;hb=875d537b75aadc54c94d41585248d0377c6816cc;hpb=6a546ea265d0ee30152298463e9e7b7c2f53b3b0 diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 2a40ff2..d196756 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -932,7 +932,6 @@ like "if" and the code following it. $void OpenScope -> ${ scope_push(c); }$ - ClosePara -> ${ var_block_close(c, CloseParallel); }$ Each variable records a scope depth and is in one of four states: @@ -3846,8 +3845,8 @@ defined. // may or may not end with EOL // WhilePart and IfPart include an appropriate Suffix - // Both ForPart and Whilepart open scopes, and CondSuffix only - // closes one - so in the first branch here we have another to close. + // ForPart, SwitchPart, and IfPart open scopes, o we have to close + // them. WhilePart opens and closes its own scope. CondStatement -> ForPart OptNL ThenPart OptNL WhilePart CondSuffix ${ $0 = $forpart = $ if UseBlock OptNL then OpenBlock ClosePara ${ + IfPart -> if UseBlock OptNL then OpenBlock ${ $0.condpart = $condpart && cs->condpart->type == Xbinode && cast(binode, cs->condpart)->op == Block) { - if (bracket) // UNTESTED - printf(" {\n"); // UNTESTED + if (bracket) + printf(" {\n"); else - printf(":\n"); // UNTESTED - print_exec(cs->condpart, indent+1, bracket); // UNTESTED - if (bracket) // UNTESTED - do_indent(indent, "}\n"); // UNTESTED - if (cs->thenpart) { // UNTESTED - do_indent(indent, "then:\n"); // UNTESTED - print_exec(cs->thenpart, indent+1, bracket); // UNTESTED + printf("\n"); + print_exec(cs->condpart, indent+1, bracket); + if (bracket) + do_indent(indent, "}\n"); + if (cs->thenpart) { + do_indent(indent, "then\n"); + print_exec(cs->thenpart, indent+1, bracket); } } else { printf(" ");