Signed-off-by: NeilBrown <neil@brown.name>
-Newlines -> NEWLINE
- | NEWLINE Newlines
-
- Statementlist -> SimpleStatements ${ $0 = $<1; }$
- | Statements ${ $0 = $<1; }$
+ Statementlist -> Statements ${ $0 = $<1; }$
Statements -> Statements Statement ${
{
Statements -> Statements Statement ${
{
+ | Statement ${ $0 = $<1; }$
| ERROR ${ printf("statement ERROR\n"); $0 = NULL; }$
| ERROR ${ printf("statement ERROR\n"); $0 = NULL; }$
- Block -> OptNL { Statementlist OptNL } ${ $0 = $<3; }$
+ Open -> {
+ | NEWLINE {
+ Close -> }
+ | NEWLINE }
+ Block -> Open Statementlist Close ${ $0 = $<2; }$
+ | Open SimpleStatements } ${ $0 = $<2; }$
| : Statementlist ${ $0 = $2; $2 = NULL; }$
SimpleStatements -> SimpleStatements ; SimpleStatement ${
| : Statementlist ${ $0 = $2; $2 = NULL; }$
SimpleStatements -> SimpleStatements ; SimpleStatement ${
}
}$
| SimpleStatement ${ $0 = $<1; }$
}
}$
| SimpleStatement ${ $0 = $<1; }$
+ | SimpleStatements ; ${ $0 = $<1; }$
SimpleStatement -> Factor = Expression ${
$0 = calloc(1, sizeof(struct statement));
SimpleStatement -> Factor = Expression ${
$0 = calloc(1, sizeof(struct statement));
$0->expr->op = $2.txt;
$0->expr->right = $<3;
}$
$0->expr->op = $2.txt;
$0->expr->right = $<3;
}$
- Statement -> SimpleStatements Newlines ${
- $0 = $<1;
- }$
- | SimpleStatements ; Newlines ${
+ Statement -> SimpleStatements NEWLINE ${
$0 = $<1;
}$
| IfStatement ${ $0 = $<1; }$
$0 = $<1;
}$
| IfStatement ${ $0 = $<1; }$
+ | Statement NEWLINE ${ $0 = $<1; }$
- IfStatement -> if Expression Block ${
+ IfStatement -> if Expression Block OptNL ${
$0 = calloc(1, sizeof(struct statement));
$0->expr = $<2;
$0->thenpart = $<3;
}$
$0 = calloc(1, sizeof(struct statement));
$0->expr = $<2;
$0->thenpart = $<3;
}$
- | if Expression SimpleStatement ${
+ | if Expression : SimpleStatements ${
$0 = calloc(1, sizeof(struct statement));
$0->expr = $<2;
$0 = calloc(1, sizeof(struct statement));
$0->expr = $<2;
- | if Expression Block Newlines else Block ${
+ | if Expression Block OptNL else Block ${
$0 = calloc(1, sizeof(struct statement));
$0->expr = $<2;
$0->thenpart = $<3;
$0->elsepart = $<6;
}$
$0 = calloc(1, sizeof(struct statement));
$0->expr = $<2;
$0->thenpart = $<3;
$0->elsepart = $<6;
}$
- | if Expression Block Newlines else IfStatement ${
+ | if Expression Block OptNL else : SimpleStatements ${
+ $0 = calloc(1, sizeof(struct statement));
+ $0->expr = $<2;
+ $0->thenpart = $<3;
+ $0->elsepart = $<7;
+ }$
+ | if Expression Block OptNL else IfStatement ${
$0 = calloc(1, sizeof(struct statement));
$0->expr = $<2;
$0->thenpart = $<3;
$0 = calloc(1, sizeof(struct statement));
$0->expr = $<2;
$0->thenpart = $<3;
there1 =x
there1a=x
there2=x
there3=x;
all = y;
there1 =x
there1a=x
there2=x
there3=x;
all = y;
- if true {yes=x;} else no=x;
+ if true {yes=x;} else : no=x
+ if true: yes = no; no = yes;
+
+ if false {
+ print = OK
+ } else {
+ print = not_OK
+ }
+
+ if a:
+ if b:
+ c= d
+ x = y