From 793a6c6f6f2fc3c522ee386ffcbd04a60053dbbe Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 30 Oct 2020 19:55:19 +0100 Subject: [PATCH] evalexpr: parse: reorder operator table This change, by not breaking anything, shows that the order of the table *probably* does not matter to the parsing code. This also enables a future refactoring to only use the parts of the tables that are *actually* needed, such as isolating the prefix, infix, or postfix operators when using the table to check a subset of them --- src/parse/climbing_parse.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/parse/climbing_parse.c b/src/parse/climbing_parse.c index 09af8be..4d75db5 100644 --- a/src/parse/climbing_parse.c +++ b/src/parse/climbing_parse.c @@ -17,9 +17,12 @@ static const struct { const enum { ASSOC_LEFT, ASSOC_RIGHT, ASSOC_NONE } assoc; const enum { OP_INFIX, OP_PREFIX, OP_POSTFIX } fix; } ops[] = { -# define BINOP(Op, Kind, Prio, Assoc, Fix) { #Op, Kind, Prio, Assoc, Fix }, -# define PREOP(Op, Kind, Prio, Assoc, Fix) { #Op, Kind, Prio, Assoc, Fix }, -# define POSTOP(Op, Kind, Prio, Assoc, Fix) { #Op, Kind, Prio, Assoc, Fix }, +# define BINOP(Op, Kind, Prio, Assoc, Fix) \ + [Kind] = { #Op, Kind, Prio, Assoc, Fix }, +# define PREOP(Op, Kind, Prio, Assoc, Fix) \ + [Kind] = { #Op, Kind, Prio, Assoc, Fix }, +# define POSTOP(Op, Kind, Prio, Assoc, Fix) \ + [Kind] = { #Op, Kind, Prio, Assoc, Fix }, #include "operators.inc" };