This commit is contained in:
bronku 2025-11-28 12:47:57 +01:00
parent 415dfb6a0e
commit 9b4db724f1
2 changed files with 7 additions and 0 deletions

View file

@ -66,6 +66,7 @@ struct Pass : Stmt
}
};
// #todo elif
struct If : Stmt
{
ptr<Expr> condition;

View file

@ -71,6 +71,12 @@ stmt_list:
stmt:
expr NEWLINE { $$ = std::make_unique<ExprStmt>(std::move($1)); }
| expr ASSIGN expr NEWLINE { $$ = std::make_unique<Assign>(std::move($1), std::move($3));}
| KW_IF expr COLON NEWLINE INDENT stmt_list DEDENT {
$$ = std::make_unique<If>(std::move($2), std::move($6), std::vector<std::unique_ptr<Stmt>>());
}
| KW_IF expr COLON NEWLINE INDENT stmt_list DEDENT KW_ELSE COLON NEWLINE INDENT stmt_list DEDENT{
$$ = std::make_unique<If>(std::move($2), std::move($6), std::move($12));
}
;
expr: