From 0b2741f73f83174084fd72712a0c9f6719334ea9 Mon Sep 17 00:00:00 2001 From: r4 Date: Sun, 26 Dec 2021 19:23:42 +0100 Subject: [PATCH] allow newline-padding of one-line if and else bodies --- parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parse.c b/parse.c index 4e20a2d..5f2d6db 100644 --- a/parse.c +++ b/parse.c @@ -640,6 +640,7 @@ static void stmt(IRToks *out_ir, TokList *toks, Map *funcs, Scope *sc, TokListIt TRY_ELSE(cond = expr_into_irparam(&cond_ir, toks, funcs, sc, t->next), irtoks_term(&cond_ir)); /* parse loop body */ + skip_newlns(toks, t->next); TRY_ELSE(stmt(out_ir, toks, funcs, sc, t->next), irtoks_term(&cond_ir)); /* finally we know where the jmp from the beginning has to jump to */ @@ -686,16 +687,17 @@ static void stmt(IRToks *out_ir, TokList *toks, Map *funcs, Scope *sc, TokListIt }); /* parse if body */ + skip_newlns(toks, t->next); IRToks if_body; irtoks_init_short(&if_body); TRY_ELSE(stmt(&if_body, toks, funcs, sc, t->next), irtoks_term(&if_body)); skip_newlns(toks, t->next); - if (t->next->tok.kind == TokElse) { toklist_del(toks, t->next, t->next); /* parse and add else body */ + skip_newlns(toks, t->next); TRY_ELSE(stmt(out_ir, toks, funcs, sc, t->next), irtoks_term(&if_body)); }