math: Report missing operators between the tokens

This affects the caret position. In an expression like

123 456

we previously reported:

123 456
      ^ missing operator

Now we do:

123 456
   ^ missing operator

We do it on the first space, which should be acceptable.

(no need for a changelog entry, we have already ignored #8511)
This commit is contained in:
Fabian Homborg
2021-12-30 13:26:44 +01:00
parent 2c03cfecba
commit 940f52d717
2 changed files with 11 additions and 1 deletions

View File

@@ -375,6 +375,8 @@ static te_expr *base(state *s) {
te_expr *ret;
int arity;
auto previous = s->start;
auto next = s->next;
switch (s->type) {
case TOK_NUMBER:
ret = new_expr(TE_CONSTANT, nullptr);
@@ -387,6 +389,12 @@ static te_expr *base(state *s) {
// (of course 3 pi could also be interpreted as 3 x pi)
s->type = TOK_ERROR;
s->error = TE_ERROR_MISSING_OPERATOR;
// The error should be given *between*
// the last two tokens.
// Since these are two separate numbers there is at least
// one space between.
s->start = previous;
s->next = next + 1;
}
break;