Prepend do_begin
statements to do
statements, don't put them in a
separate block
This commit is contained in:
parent
982d67437f
commit
0f11502a7d
18
src/parse.c
18
src/parse.c
@ -1126,14 +1126,18 @@ PARSER(parse_do) {
|
|||||||
pos = tmp;
|
pos = tmp;
|
||||||
ast_t *body = expect(ctx, start, &pos, parse_block, "I expected a body for this 'do'");
|
ast_t *body = expect(ctx, start, &pos, parse_block, "I expected a body for this 'do'");
|
||||||
if (begin && end) {
|
if (begin && end) {
|
||||||
return NewAST(ctx->file, start, pos, Block,
|
ast_list_t *statements = Match(begin, Block)->statements;
|
||||||
.statements=new(ast_list_t, .ast=begin,
|
REVERSE_LIST(statements);
|
||||||
.next=new(ast_list_t, .ast=WrapAST(end, Defer, .body=end),
|
statements = new(ast_list_t, .ast=WrapAST(end, Defer, .body=end), .next=statements);
|
||||||
.next=new(ast_list_t, .ast=body))));
|
statements = new(ast_list_t, .ast=body, .next=statements);
|
||||||
|
REVERSE_LIST(statements);
|
||||||
|
return NewAST(ctx->file, start, pos, Block, .statements=statements);
|
||||||
} else if (begin) {
|
} else if (begin) {
|
||||||
return NewAST(ctx->file, start, pos, Block,
|
ast_list_t *statements = Match(begin, Block)->statements;
|
||||||
.statements=new(ast_list_t, .ast=begin,
|
REVERSE_LIST(statements);
|
||||||
.next=new(ast_list_t, .ast=body)));
|
statements = new(ast_list_t, .ast=body, .next=statements);
|
||||||
|
REVERSE_LIST(statements);
|
||||||
|
return NewAST(ctx->file, start, pos, Block, .statements=statements);
|
||||||
} else if (end) {
|
} else if (end) {
|
||||||
return NewAST(ctx->file, start, pos, Block,
|
return NewAST(ctx->file, start, pos, Block,
|
||||||
.statements=new(ast_list_t, .ast=WrapAST(end, Defer, .body=end),
|
.statements=new(ast_list_t, .ast=WrapAST(end, Defer, .body=end),
|
||||||
|
Loading…
Reference in New Issue
Block a user