]> ocean-lang.org Git - ocean/commitdiff
oceani: change parsing for ; at end
authorNeilBrown <neil@brown.name>
Sun, 23 Jun 2019 04:41:47 +0000 (14:41 +1000)
committerNeilBrown <neil@brown.name>
Sun, 23 Jun 2019 05:35:46 +0000 (15:35 +1000)
When we have 'for' and 'then' on the same line, I want to
require a ';' for the 'for' (and 'while').
So change SimpleStatemnts to never end with ';', and require
a ; or Newline after each instance of SimpleStatements.

Hmm... I guess that could be abstracted.

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

index 06f71be3268da0b30eb962be214eab1c4d23f558..e02057f31a27f9f01fdfa5d27ed2533d1cc9645f 100644 (file)
@@ -3059,8 +3059,8 @@ is in-place.
        $*binode
        Block -> Open Statementlist Close ${ $0 = $<2; }$
                | Open SimpleStatements } ${ $0 = reorder_bilist($<2); }$
-               | : SimpleStatements $$NEWLINE ${ $0 = reorder_bilist($<2); }$
-               | : Statementlist $$NEWLINE ${ $0 = $<2; }$
+               | : SimpleStatements ${ $0 = reorder_bilist($<2); }$
+               | : Statementlist $$OUT ${ $0 = $<2; }$
 
        Statementlist -> ComplexStatements ${ $0 = reorder_bilist($<1); }$
                | Newlines ComplexStatements ${ $0 = reorder_bilist($<2); }$
@@ -3106,9 +3106,9 @@ is in-place.
                        $0->left = NULL;
                        $0->right = $<1;
                        }$
-               | SimpleStatements ; ${ $0 = $<1; }$
 
        SimpleStatementLine -> SimpleStatements NEWLINE ${ $0 = $<1; }$
+               | SimpleStatements ; NEWLINE ${ $0 = $<1; }$
                | SimpleStatementLine NEWLINE ${ $0 = $<1; }$
 
        SimpleStatement -> pass ${ $0 = NULL; }$
@@ -3565,7 +3565,7 @@ defined.
        case Xcond_statement: free_cond_statement(cast(cond_statement, e)); break;
 
 ###### ComplexStatement Grammar
-       | CondStatement ${ $0 = $<1; }$
+       | CondStatement $$NEWLINE ${ $0 = $<1; }$
 
 ###### Grammar
 
@@ -3644,7 +3644,10 @@ defined.
 
        $*exec
        // These scopes are closed in CondSuffix
-       ForPart -> for OpenScope SimpleStatements ${
+       ForPart -> for OpenScope SimpleStatements ; ${
+                       $0 = reorder_bilist($<3);
+               }$
+               | for OpenScope SimpleStatements NEWLINE ${
                        $0 = reorder_bilist($<3);
                }$
                |  for OpenScope Block ${
@@ -3652,7 +3655,11 @@ defined.
                }$
                |  ForPart NEWLINE ${ $0 = $<1; }$
 
-       ThenPart -> then OpenScope SimpleStatements ${
+       ThenPart -> then OpenScope SimpleStatements ; ${
+                       $0 = reorder_bilist($<3);
+                       var_block_close(c, CloseSequential);
+               }$
+               | then OpenScope SimpleStatements NEWLINE ${
                        $0 = reorder_bilist($<3);
                        var_block_close(c, CloseSequential);
                }$
@@ -4326,6 +4333,8 @@ things which will likely grow as the languages grows.
                        print "", list[i],
                print
 
+               if 1 == 2: print "yes" else: print "no"
+
                bob:fred
                bob.name = "Hello"
                bob.alive = (bob.name == "Hello")