if else
This commit is contained in:
parent
415dfb6a0e
commit
9b4db724f1
2 changed files with 7 additions and 0 deletions
|
|
@ -66,6 +66,7 @@ struct Pass : Stmt
|
|||
}
|
||||
};
|
||||
|
||||
// #todo elif
|
||||
struct If : Stmt
|
||||
{
|
||||
ptr<Expr> condition;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue