Rearrange expression/statement compilation code
This commit is contained in:
parent
d5d3f564bb
commit
ecf425fb9a
4
ast.c
4
ast.c
@ -128,8 +128,8 @@ CORD ast_to_cord(ast_t *ast)
|
||||
T(If, "(condition=%r, body=%r, else=%r)", ast_to_cord(data.condition), ast_to_cord(data.body), ast_to_cord(data.else_body))
|
||||
T(When, "(subject=%r, clauses=%r, else=%r)", ast_to_cord(data.subject), when_clauses_to_cord(data.clauses), ast_to_cord(data.else_body))
|
||||
T(Reduction, "(iter=%r, combination=%r, fallback=%r)", ast_to_cord(data.iter), ast_to_cord(data.combination), ast_to_cord(data.fallback))
|
||||
T(Skip, "(%s)", data.target)
|
||||
T(Stop, "(%s)", data.target)
|
||||
T(Skip, "(%s)", data.target ? data.target : "NULL")
|
||||
T(Stop, "(%s)", data.target ? data.target : "NULL")
|
||||
T(Pass, "")
|
||||
T(Return, "(%r)", ast_to_cord(data.value))
|
||||
T(Extern, "(name=%s, type=%r)", data.name, type_ast_to_cord(data.type))
|
||||
|
2
parse.c
2
parse.c
@ -815,7 +815,7 @@ ast_t *parse_for_suffix(parse_ctx_t *ctx, ast_t *lhs) {
|
||||
if (match_word(&pos, "if")) {
|
||||
ast_t *condition = expect(ctx, pos-2, &pos, parse_expr, "I expected a condition for this 'if'");
|
||||
body = NewAST(ctx->file, body->start, condition->end, Block,
|
||||
.statements=new(ast_list_t, .ast=WrapAST(condition, If, .condition=condition, .else_body=FakeAST(Skip)),
|
||||
.statements=new(ast_list_t, .ast=WrapAST(condition, If, .condition=FakeAST(Not, condition), .body=FakeAST(Skip)),
|
||||
.next=new(ast_list_t, .ast=body)));
|
||||
}
|
||||
return NewAST(ctx->file, start, pos, For, .index=index, .value=value, .iter=iter, .body=body);
|
||||
|
Loading…
Reference in New Issue
Block a user