* [iproute PATCH] ssfilter: Eliminate shift/reduce conflicts
@ 2018-03-24 17:45 Phil Sutter
2018-03-27 18:42 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2018-03-24 17:45 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
The problematic bit was the 'expr: expr expr' rule. Fix this by making
'expr' token represent a single filter only and introduce a new token
'exprlist' to represent a combination of filters.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ssfilter.y | 52 +++++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/misc/ssfilter.y b/misc/ssfilter.y
index 4db3c95faa3cc..88d4229a9b241 100644
--- a/misc/ssfilter.y
+++ b/misc/ssfilter.y
@@ -42,7 +42,7 @@ static void yyerror(char *s)
%nonassoc '!'
%%
-applet: null expr
+applet: null exprlist
{
*yy_ret = $2;
$$ = $2;
@@ -51,6 +51,32 @@ applet: null expr
;
null: /* NOTHING */ { $$ = NULL; }
;
+exprlist: expr
+ | '!' expr
+ {
+ $$ = alloc_node(SSF_NOT, $2);
+ }
+ | '(' exprlist ')'
+ {
+ $$ = $2;
+ }
+ | exprlist '|' expr
+ {
+ $$ = alloc_node(SSF_OR, $1);
+ $$->post = $3;
+ }
+ | exprlist '&' expr
+ {
+ $$ = alloc_node(SSF_AND, $1);
+ $$->post = $3;
+ }
+ | exprlist expr
+ {
+ $$ = alloc_node(SSF_AND, $1);
+ $$->post = $2;
+ }
+ ;
+
expr: DCOND HOSTCOND
{
$$ = alloc_node(SSF_DCOND, $2);
@@ -128,30 +154,6 @@ expr: DCOND HOSTCOND
{
$$ = alloc_node(SSF_S_AUTO, NULL);
}
- | expr '|' expr
- {
- $$ = alloc_node(SSF_OR, $1);
- $$->post = $3;
- }
- | expr expr
- {
- $$ = alloc_node(SSF_AND, $1);
- $$->post = $2;
- }
- | expr '&' expr
-
- {
- $$ = alloc_node(SSF_AND, $1);
- $$->post = $3;
- }
- | '!' expr
- {
- $$ = alloc_node(SSF_NOT, $2);
- }
- | '(' expr ')'
- {
- $$ = $2;
- }
;
%%
--
2.16.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-27 18:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-24 17:45 [iproute PATCH] ssfilter: Eliminate shift/reduce conflicts Phil Sutter
2018-03-27 18:42 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox