}
else if (matches(p, IF))
{
- assert("!not implemented");
+ expect(p, IF);
+ expression(p, item);
+ check_bool(p, item);
+ expect(p, THEN);
+ statement_seq(p, &(Item){0});
+ while (accept(p, ELSIF))
+ {
+ expression(p, item);
+ check_bool(p, item);
+ expect(p, THEN);
+ statement_seq(p, &(Item){0});
+ }
+ if (accept(p, ELSE))
+ {
+ statement_seq(p, &(Item){0});
+ }
+ expect(p, END);
}
else
{
error(p, "expected a statement");
}
- if (matches(p, END))
+ if (matches(p, END) || matches(p, ELSE) || matches(p, ELSIF))
{
break;
}