Make operand parsing error messages more helpful

and add a test that is supposed to exercise them all.
This commit is contained in:
Olaf Seibert
2021-03-14 20:08:31 +01:00
parent d4c0520ac1
commit 0e373a8570
8 changed files with 558 additions and 75 deletions

15
parse.c
View File

@@ -211,7 +211,7 @@ int get_mode(
mode->offset = parse_expr(cp, 0);
if (endp)
*endp = mode->offset->cp;
return TRUE;
return expr_ok(mode->offset);
}
/* Check for -(Rn) */
@@ -281,6 +281,9 @@ int get_mode(
mode->offset = parse_expr(cp, 0);
if (!expr_ok(mode->offset))
return FALSE;
cp = skipwhite(mode->offset->cp);
if (*cp == '(') {
@@ -1177,3 +1180,13 @@ EX_TREE *parse_unary_expr(
return value;
}
/*
* expr_ok Returns TRUE if there was a valid expression parsed.
*/
int expr_ok(
EX_TREE *expr)
{
return expr != NULL && expr->type != EX_ERR;
}