From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 7/8] parser_bison: add variable_expr rule
Date: Mon, 29 Aug 2016 20:21:18 +0200 [thread overview]
Message-ID: <1472494879-16442-7-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1472494879-16442-1-git-send-email-pablo@netfilter.org>
This patch adds a rule for variable expression so we can reuse it in a
follow up patch to allow set element initialization from variable.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/parser_bison.y | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index dc79465..a87468e 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -496,8 +496,8 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%type <stmt> flow_stmt flow_stmt_alloc
%destructor { stmt_free($$); } flow_stmt flow_stmt_alloc
-%type <expr> symbol_expr verdict_expr integer_expr
-%destructor { expr_free($$); } symbol_expr verdict_expr integer_expr
+%type <expr> symbol_expr verdict_expr integer_expr variable_expr
+%destructor { expr_free($$); } symbol_expr verdict_expr integer_expr variable_expr
%type <expr> primary_expr shift_expr and_expr
%destructor { expr_free($$); } primary_expr shift_expr and_expr
%type <expr> exclusive_or_expr inclusive_or_expr
@@ -1927,14 +1927,7 @@ match_stmt : relational_expr
}
;
-symbol_expr : string
- {
- $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE,
- current_scope(state),
- $1);
- xfree($1);
- }
- | '$' identifier
+variable_expr : '$' identifier
{
struct scope *scope = current_scope(state);
@@ -1948,6 +1941,16 @@ symbol_expr : string
scope, $2);
xfree($2);
}
+ ;
+
+symbol_expr : variable_expr
+ | string
+ {
+ $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE,
+ current_scope(state),
+ $1);
+ xfree($1);
+ }
| AT identifier
{
$$ = symbol_expr_alloc(&@$, SYMBOL_SET,
--
2.1.4
next prev parent reply other threads:[~2016-08-29 18:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-29 18:21 [PATCH nft 1/8] tests: py: adapt this to new add element command semantics Pablo Neira Ayuso
2016-08-29 18:21 ` [PATCH nft 2/8] src: add quota statement Pablo Neira Ayuso
2016-08-29 18:21 ` [PATCH nft 3/8] src: add numgen expression Pablo Neira Ayuso
2016-08-29 18:21 ` [PATCH nft 4/8] src: add hash expression Pablo Neira Ayuso
2016-08-29 18:21 ` [PATCH nft 5/8] evaluate: add expr_evaluate_integer() Pablo Neira Ayuso
2016-08-29 18:21 ` [PATCH nft 6/8] evaluate: validate maximum hash and numgen value Pablo Neira Ayuso
2016-08-29 18:21 ` Pablo Neira Ayuso [this message]
2016-08-29 18:21 ` [PATCH nft 8/8] parser_bison: allow variable references in set elements definition Pablo Neira Ayuso
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=1472494879-16442-7-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).