]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Fix grammar conflicts instead of accepting them.
authorAkim Demaille <akim.demaille@gmail.com>
Fri, 1 May 2020 10:40:42 +0000 (12:40 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 1 May 2020 19:39:51 +0000 (21:39 +0200)
The seven conflicts are related to "a ? b : c <op> d".  In all the
cases we left the S/R conflict be resolved as a shift, i.e., "a ? b
: (c <op> 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.

gettext-runtime/intl/plural.y

index a712255af4f2f739c93336d4ff6556d932a426a5..8de8afdcf462a5eaf7f3bb3b60cd2530772accb5 100644 (file)
 #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 <op> EQUOP2 CMPOP2 ADDOP2 MULOP2
 %token <num> NUMBER