bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] intl: fix conflicts instead of accepting them


From: Akim Demaille
Subject: [PATCH 3/4] intl: fix conflicts instead of accepting them
Date: Fri, 1 May 2020 12:40:42 +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 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

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 <op> EQUOP2 CMPOP2 ADDOP2 MULOP2
 %token <num> NUMBER
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]