From: NeilBrown Date: Sun, 23 Jun 2019 04:41:47 +0000 (+1000) Subject: oceani: change parsing for ; at end X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=7b1280e4a50fee191043436ebc8b2f8c482ccdaf oceani: change parsing for ; at end 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 --- diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 06f71be..e02057f 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -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")