[expr parser] Disallow non-postfix set-like operators (note 1b).

This commit is contained in:
Miguel Lechon
2021-10-04 07:57:45 +02:00
parent d1745050dd
commit 94cd3ced02
2 changed files with 22 additions and 4 deletions
+10 -3
View File
@@ -3377,11 +3377,18 @@ MD_ExprBakeOperatorTableFromList(MD_Arena *arena, MD_ExprOprList *list)
{
error_str = MD_S8Fmt(arena, "Invalid operator kind.");
}
else if(op_kind != MD_ExprOprKind_Postfix &&
(MD_S8Match(op_s, MD_S8Lit("[]"), 0) || MD_S8Match(op_s, MD_S8Lit("()"), 0))){
error_str =
MD_S8Fmt(arena, "Ignored operator \"%.*s\". \"%.*s\" is only allowed as unary postfix",
MD_S8VArg(op_s), MD_S8VArg(op_s));
}
else if(MD_S8Match(op_s, MD_S8Lit("[)"), 0) || MD_S8Match(op_s, MD_S8Lit("(]"), 0) ||
MD_S8Match(op_s, MD_S8Lit("{}"), 0)){
error_str = MD_S8Fmt(arena, "Ignored forbidden operator \"%.*s\".", MD_S8VArg(op_s));
}
else
{
// TODO(mal): Allow "[]" and "()" only as unary postfix
// TODO(mal): Disallow all other set types ("[)", "(]", "{}") from becoming operators
for(MD_ExprOpr *op2 = list->first;
op2 != op;
op2 = op2->next)