From: Akim Demaille Date: Fri, 1 May 2020 10:40:42 +0000 (+0200) Subject: intl: Fix grammar conflicts instead of accepting them. X-Git-Tag: v0.21~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34c426889e1c426d6f0b7063e325dfc706d3eb8d;p=thirdparty%2Fgettext.git intl: Fix grammar conflicts instead of accepting them. The seven conflicts are related to "a ? b : c d". In all the cases we left the S/R conflict be resolved as a shift, i.e., "a ? b : (c d)". To make this explicit, give the rule of the ternary operator a very low precedence. In fact give it the same precedence as "?". Now, to resolve the conflict in "a ? b : c ? d : e" be parsed as "a ? b : (c ? d : e)", make them right-associative. * gettext-runtime/intl/plural.y: Require Bison 3.0, to use %precedence instead of useless associativities such as %right. Make '?' and ':' of the same precedence, right associative. --- diff --git a/gettext-runtime/intl/plural.y b/gettext-runtime/intl/plural.y index a712255af..8de8afdcf 100644 --- a/gettext-runtime/intl/plural.y +++ b/gettext-runtime/intl/plural.y @@ -32,10 +32,11 @@ #endif %} +%require "3.0" %parse-param {struct parse_args *arg} %lex-param {struct parse_args *arg} %define api.pure full -%expect 7 +%expect 0 %union { unsigned long int num; @@ -125,14 +126,14 @@ new_exp_3 (enum expression_operator op, struct expression *bexp, There is no unary minus and no bitwise operators. Operators with the same syntactic behaviour have been merged into a single token, to save space in the array generated by bison. */ -%right '?' /* ? */ +%right '?' ':' /* ? */ %left '|' /* || */ %left '&' /* && */ %left EQUOP2 /* == != */ %left CMPOP2 /* < > <= >= */ %left ADDOP2 /* + - */ %left MULOP2 /* * / % */ -%right '!' /* ! */ +%precedence '!' /* ! */ %token EQUOP2 CMPOP2 ADDOP2 MULOP2 %token NUMBER