multi-line expressions

This commit is contained in:
r4 2021-12-23 16:51:10 +01:00
parent 298883939b
commit 7ae9ddaee9
2 changed files with 13 additions and 1 deletions

View File

@ -5,7 +5,11 @@ iterations := 100
while k - iterations { while k - iterations {
k_f := float(k) k_f := float(k)
sum = sum + 1.0 / pow(16.0, k_f) * (4.0 / (8.0 * k_f + 1.0) - 2.0 / (8.0 * k_f + 4.0) - 1.0 / (8.0 * k_f + 5.0) - 1.0 / (8.0 * k_f + 6.0)) sum = sum + 1.0 / pow(16.0, k_f) *
(4.0 / (8.0 * k_f + 1.0) -
2.0 / (8.0 * k_f + 4.0) -
1.0 / (8.0 * k_f + 5.0) -
1.0 / (8.0 * k_f + 6.0))
k = k + 1 k = k + 1
} }

View File

@ -177,6 +177,14 @@ static ExprRet expr(IRToks *out_ir, TokList *toks, Map *funcs, Scope *parent_sc,
negate = true; negate = true;
} }
/* Delete newline if we're definitely expecting an operand. */
if (t->tok.kind == TokOp && t->tok.Op == OpNewLn) {
if (t == start)
start = t->next;
t = t->next;
toklist_del(toks, t->prev, t->prev);
}
/* Collapse parentheses. */ /* Collapse parentheses. */
if (t->tok.kind == TokOp && t->tok.Op == OpLParen) { if (t->tok.kind == TokOp && t->tok.Op == OpLParen) {
ExprRet r; ExprRet r;