Somewhat better error reporting.

This commit is contained in:
Dianne Skoll
2024-06-03 20:14:11 -04:00
parent 8bdca0d684
commit f13f9e18bd
2 changed files with 25 additions and 3 deletions

View File

@@ -1825,8 +1825,8 @@ static expr_node * parse_function_call(char const **e, int *r, Var *locals, int
return free_expr_tree(node);
}
if (TOKEN_IS(")")) {
Eprint("%s `)'", ErrMsg[E_ILLEGAL_CHAR]);
*r = E_ILLEGAL_CHAR;
Eprint("%s `)'", ErrMsg[E_PARSE_ERR]);
*r = E_PARSE_ERR;
return free_expr_tree(node);
}
}
@@ -2461,7 +2461,7 @@ static expr_node *parse_expression_aux(char const **e, int *r, Var *locals, int
expr_node *parse_expression(char const **e, int *r, Var *locals)
{
char const *orig = *e;
char const *o2 = *e;
if (ExpressionEvaluationDisabled) {
*r = E_EXPR_DISABLED;
return NULL;
@@ -2486,6 +2486,23 @@ expr_node *parse_expression(char const **e, int *r, Var *locals)
fprintf(ErrFp, " Unparsed: %s\n", *e);
}
}
if (*r == E_EXPECT_COMMA ||
*r == E_PARSE_ERR ||
*r == E_MISS_RIGHT_PAREN ||
*r == E_EXPECTING_EOL ||
*r == E_ILLEGAL_CHAR) {
orig = o2;
while (*orig) {
fprintf(ErrFp, "%c", *orig++);
}
fprintf(ErrFp, "\n");
orig = o2;
while ((orig < *e) && *orig) {
orig++;
fprintf(ErrFp, " ");
}
fprintf(ErrFp, "^-- here\n");
}
return node;
}

View File

@@ -567,6 +567,11 @@ int DoSet (Parser *p)
ParseNonSpaceChar(p, &r, 0);
}
if (p->isnested) {
Eprint("%s", "Do not use [] around expression in SET command");
return E_CANTNEST_FDEF;
}
r = EvaluateExpr(p, &v);
if (r) {
DBufFree(&buf);