From patchwork Sat Mar 24 17:45:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 890474 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 407nqr1z6zz9s33 for ; Sun, 25 Mar 2018 04:45:28 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752670AbeCXRp0 (ORCPT ); Sat, 24 Mar 2018 13:45:26 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:36552 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752527AbeCXRpZ (ORCPT ); Sat, 24 Mar 2018 13:45:25 -0400 Received: from localhost ([::1]:51828 helo=xsao) by orbyte.nwl.cc with esmtp (Exim 4.90_1) (envelope-from ) id 1eznEK-0001XA-16; Sat, 24 Mar 2018 18:45:24 +0100 From: Phil Sutter To: Stephen Hemminger Cc: netdev@vger.kernel.org Subject: [iproute PATCH] ssfilter: Eliminate shift/reduce conflicts Date: Sat, 24 Mar 2018 18:45:14 +0100 Message-Id: <20180324174514.17840-1-phil@nwl.cc> X-Mailer: git-send-email 2.16.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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; - } ; %%