[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
From: |
Piotr Grzybowski |
Subject: |
./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] |
Date: |
Wed, 27 Jun 2018 12:59:34 +0200 |
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.
- ./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr],
Piotr Grzybowski <=