| NEWLINE Close
Block -> Open Statementlist Close ${ $0 = $<2; }$
| Open SimpleStatements } ${ $0 = $<2; }$
- | : SimpleStatements $$NEWLINE ${ $0 = $<2; }$
+ | : SimpleStatements ${ $0 = $<2; }$
| : StatementBlock ${ $0 = $<2; }$
StatementBlock -> Statementlist $$OUT ${ $0 = $<1; }$
$0->expr->right = $<3;
}$
SSline -> SimpleStatements NEWLINE ${ $0 = $<1; }$
- | SSline NEWLINE ${ $0 = $<1; }$
Statement -> SSline ${ $0 = $<1; }$
- | IfStatement ${ $0 = $<1; }$
+ | IfStatement $$NEWLINE ${ $0 = $<1; }$
+ | Statement NEWLINE ${ $0 = $<1; }$
$RIGHT else
$0->thenpart = $<3;
}$
| IfHead NEWLINE ${ $0 = $<1; }$
- IfTail -> else Block ${ $0 = $<2; }$
- | IfTail NEWLINE ${ $0 = $<1; }$
IfStatement -> IfHead $$else ${ $0 = $<1; }$
- | IfHead IfTail ${
+ | IfHead else Block ${
$0 = $<1;
- $0->elsepart = $<2;
+ $0->elsepart = $<3;
}$
| IfHead else IfStatement ${
$0 = $<1;
$0->elsepart = $<3;
}$
- | IfStatement NEWLINE ${ $0 = $<1; }$
-
$*expression
Expression -> Expression + Term ${
all = y;
if true {yes=x;} else : no=x
if true: yes = no; no = yes;
+ if false: yes=ok; else: no=ok
if false {
print = OK
if true:
(yes=no);
(no=yes);
+ if false:
+ (yes=ok);
+ else:
+ (no=ok);
if false:
(print=OK);
else:
force_reduce:
if (states[tos->state].reduce_prod >= 0 &&
states[tos->state].newline_only &&
- tk->num != TK_newline && tk->num != TK_eof && tk->num != TK_out) {
- /* Anything other than newline in an error as this
- * production must end at EOL
+ !(tk->num == TK_newline ||
+ tk->num == TK_eof ||
+ tk->num == TK_out ||
+ (tos->indents == 0 && tos->since_newline == 0))) {
+ /* Anything other than newline or out or eof
+ * in an error unless we are already at start
+ * of line, as this production must end at EOL.
*/
} else if (states[tos->state].reduce_prod >= 0) {
void **body;