Skip to content

Commit

Permalink
cfg-grammar: fix the precedence of ';'
Browse files Browse the repository at this point in the history
In 6d74e60, 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 <laszlo.varady@anno.io>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
  • Loading branch information
MrAnno committed May 23, 2024
1 parent b7d4414 commit a7824da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/cfg-grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -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 '?' ':'
Expand Down
2 changes: 0 additions & 2 deletions lib/filter/filter-expr-grammar.ym
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ _translate_number_literals(CfgLexer *lexer, gint compare_mode, LogTemplate *expr
%token KW_PROGRAM
%token KW_IN_LIST

%left ';'

%type <node> filter_expr
%type <node> filter_simple_expr
%type <node> filter_plugin
Expand Down

0 comments on commit a7824da

Please sign in to comment.