From a7824da1212a17d35281d7b426c8bc2d65f77f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Thu, 23 May 2024 12:47:02 +0200 Subject: [PATCH] cfg-grammar: fix the precedence of ';' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 6d74e60c4b2b51e9842ccab23902803b9ff8de2b, the precedence of ';' has implicitly changed for filter rules, changing the meaning of filter expressions: The expression `not program("a"); message("b");` should have the following interpretation: `(not program("a")) and message("b")`. Due to accidentally changed precedence of ';', currently it is interpreted as `not (message("a") and message("b"))`. This patch recovers the original precedence, but also introduces precedence and left associativity for other semicolon-separated rules. All the other (non-filter) uses of the ';' token are unambiguous, so this declaration won't interfere with those rules. Signed-off-by: László Várady Signed-off-by: Attila Szakacs --- lib/cfg-grammar.y | 3 +++ lib/filter/filter-expr-grammar.ym | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/cfg-grammar.y b/lib/cfg-grammar.y index fd178561d0..5bc4e6f41e 100644 --- a/lib/cfg-grammar.y +++ b/lib/cfg-grammar.y @@ -157,6 +157,9 @@ /* this is a placeholder for unit tests, must be the latest & largest */ %token LL_CONTEXT_MAX 27 + +%left ';' + /* operators in the filter language, the order of this determines precedence */ %right KW_ASSIGN 9000 %right '?' ':' diff --git a/lib/filter/filter-expr-grammar.ym b/lib/filter/filter-expr-grammar.ym index 2d1e55496e..9462617201 100644 --- a/lib/filter/filter-expr-grammar.ym +++ b/lib/filter/filter-expr-grammar.ym @@ -112,8 +112,6 @@ _translate_number_literals(CfgLexer *lexer, gint compare_mode, LogTemplate *expr %token KW_PROGRAM %token KW_IN_LIST -%left ';' - %type filter_expr %type filter_simple_expr %type filter_plugin