- | if Expression : SimpleStatements $$else ${
- $0 = calloc(1, sizeof(struct statement));
- $0->expr = $<2;
- $0->thenpart = $<4;
- }$
- | if Expression Block OptNL else Block ${
- $0 = calloc(1, sizeof(struct statement));
- $0->expr = $<2;
- $0->thenpart = $<3;
- $0->elsepart = $<6;
- }$
- | 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->elsepart = $<6;
- }$
+ | IfHead NEWLINE ${ $0 = $<1; }$
+
+ IfStatement -> IfHead $$else ${ $0 = $<1; }$
+ | IfHead else Block ${
+ $0 = $<1;
+ $0->elsepart = $<3;
+ }$
+ | IfHead else IfStatement ${
+ $0 = $<1;
+ $0->elsepart = $<3;
+ }$