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>
$*binode
Block -> Open Statementlist Close ${ $0 = $<2; }$
| Open SimpleStatements } ${ $0 = reorder_bilist($<2); }$
$*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); }$
Statementlist -> ComplexStatements ${ $0 = reorder_bilist($<1); }$
| Newlines ComplexStatements ${ $0 = reorder_bilist($<2); }$
$0->left = NULL;
$0->right = $<1;
}$
$0->left = NULL;
$0->right = $<1;
}$
- | SimpleStatements ; ${ $0 = $<1; }$
SimpleStatementLine -> SimpleStatements NEWLINE ${ $0 = $<1; }$
SimpleStatementLine -> SimpleStatements NEWLINE ${ $0 = $<1; }$
+ | SimpleStatements ; NEWLINE ${ $0 = $<1; }$
| SimpleStatementLine NEWLINE ${ $0 = $<1; }$
SimpleStatement -> pass ${ $0 = NULL; }$
| SimpleStatementLine NEWLINE ${ $0 = $<1; }$
SimpleStatement -> pass ${ $0 = NULL; }$
case Xcond_statement: free_cond_statement(cast(cond_statement, e)); break;
###### ComplexStatement Grammar
case Xcond_statement: free_cond_statement(cast(cond_statement, e)); break;
###### ComplexStatement Grammar
- | CondStatement ${ $0 = $<1; }$
+ | CondStatement $$NEWLINE ${ $0 = $<1; }$
$*exec
// These scopes are closed in CondSuffix
$*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 ${
$0 = reorder_bilist($<3);
}$
| for OpenScope Block ${
}$
| ForPart NEWLINE ${ $0 = $<1; }$
}$
| 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);
}$
$0 = reorder_bilist($<3);
var_block_close(c, CloseSequential);
}$
+ if 1 == 2: print "yes" else: print "no"
+
bob:fred
bob.name = "Hello"
bob.alive = (bob.name == "Hello")
bob:fred
bob.name = "Hello"
bob.alive = (bob.name == "Hello")