From: Phil Sutter <phil@nwl.cc>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: [iproute PATCH] ssfilter: Eliminate shift/reduce conflicts
Date: Sat, 24 Mar 2018 18:45:14 +0100 [thread overview]
Message-ID: <20180324174514.17840-1-phil@nwl.cc> (raw)
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
next reply other threads:[~2018-03-24 17:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-24 17:45 Phil Sutter [this message]
2018-03-27 18:42 ` [iproute PATCH] ssfilter: Eliminate shift/reduce conflicts Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180324174514.17840-1-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox