Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14279 > unrolled thread

./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]

Started byPiotr Grzybowski <narsil.pl@gmail.com>
First post2018-06-27 12:59 +0200
Last post2018-06-27 12:59 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

  ./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] Piotr Grzybowski <narsil.pl@gmail.com> - 2018-06-27 12:59 +0200

#14279 — ./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]

FromPiotr Grzybowski <narsil.pl@gmail.com>
Date2018-06-27 12:59 +0200
Subject./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Message-ID<mailman.2610.1530097184.1292.bug-bash@gnu.org>
Hey,

 I case anyone noticed, in the current devel there is shift/reduce conflict reported by bison. Those usually are a symptom of not fully controlled grammar, and I would like to think that we are in full control over parse.y.
 It is caused by function_def rule, namely the combination of '(' and newline_list.
 A quick fix:

diff --git a/parse.y b/parse.y
index 6457782..f7d84ff 100644
--- a/parse.y
+++ b/parse.y
@@ -913,16 +913,15 @@ case_command:     CASE WORD newline_list IN newline_list ESAC
                        }
        ;
 
-function_def:  WORD '(' ')' newline_list function_body
-                       { $$ = make_function_def ($1, $5, function_dstart, function_bstart); }
-
-       |       FUNCTION WORD '(' ')' newline_list function_body
-                       { $$ = make_function_def ($2, $6, function_dstart, function_bstart); }
-
-       |       FUNCTION WORD newline_list function_body
+function_def:  WORD function_newline_list function_body
+                       { $$ = make_function_def ($1, $3, function_dstart, function_bstart); }
+       |       FUNCTION WORD function_newline_list function_body
                        { $$ = make_function_def ($2, $4, function_dstart, function_bstart); }
        ;
 
+function_newline_list: '(' ')' | function_newline_list '\n'
+       ;
+
 function_body: shell_command
                        { $$ = $1; }
        |       shell_command redirection_list

cheers,
pg

P.S.
 the last rule maybe does not give justice to the syntax, but tokenizer will not let anything stray go through.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web