Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/npf/npfctl Rename some tokens, use more accurate na...



details:   https://anonhg.NetBSD.org/src/rev/cd183128dc9a
branches:  trunk
changeset: 791450:cd183128dc9a
user:      rmind <rmind%NetBSD.org@localhost>
date:      Mon Nov 18 21:39:03 2013 +0000

description:
Rename some tokens, use more accurate names (the current ones are incorrect
or missleading) and add few comments in the parser code.

diffstat:

 usr.sbin/npf/npfctl/npf_parse.y |  63 ++++++++++++++++++++++++++++------------
 usr.sbin/npf/npfctl/npf_scan.l  |   4 +-
 2 files changed, 46 insertions(+), 21 deletions(-)

diffs (169 lines):

diff -r f5a5f38011e0 -r cd183128dc9a usr.sbin/npf/npfctl/npf_parse.y
--- a/usr.sbin/npf/npfctl/npf_parse.y   Mon Nov 18 20:51:03 2013 +0000
+++ b/usr.sbin/npf/npfctl/npf_parse.y   Mon Nov 18 21:39:03 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_parse.y,v 1.27 2013/11/08 00:38:26 rmind Exp $     */
+/*     $NetBSD: npf_parse.y,v 1.28 2013/11/18 21:39:03 rmind Exp $     */
 
 /*-
  * Copyright (c) 2011-2013 The NetBSD Foundation, Inc.
@@ -155,7 +155,7 @@
 %token <str>           TABLE_ID
 %token <str>           VAR_ID
 
-%type  <str>           addr, some_name, list_elem, table_store, string
+%type  <str>           addr, some_name, element, table_store, string
 %type  <str>           proc_param_val, opt_apply, ifname, on_ifname
 %type  <num>           port, opt_final, number, afamily, opt_family
 %type  <num>           block_or_pass, rule_dir, group_dir, block_opts
@@ -192,7 +192,7 @@
        ;
 
 line
-       : def
+       : vardef
        | table
        | map
        | group
@@ -201,33 +201,45 @@
        |
        ;
 
-def
+alg
+       : ALG STRING
+       {
+               npfctl_build_alg($2);
+       }
+       ;
+
+/*
+ * A value - an element or a list of elements.
+ * Can be assigned to a variable or used inline.
+ */
+
+vardef
        : VAR_ID
        {
                cvar = npfvar_create($1);
                npfvar_add(cvar);
        }
-         EQ definition
+         EQ value
        {
                cvar = NULL;
        }
        ;
 
-definition
-       : list_elem
-       | listdef
+value
+       : element
+       | list
        ;
 
-listdef
+list
        : CURLY_OPEN list_elems CURLY_CLOSE
        ;
 
 list_elems
-       : list_elem COMMA list_elems
-       | list_elem
+       : element COMMA list_elems
+       | element
        ;
 
-list_elem
+element
        : IDENTIFIER
        {
                npfvar_t *vp = npfvar_create(".identifier");
@@ -267,6 +279,10 @@
        }
        ;
 
+/*
+ * Table definition.
+ */
+
 table
        : TABLE TABLE_ID TYPE table_type table_store
        {
@@ -284,6 +300,10 @@
        | TFILE STRING  { $$ = $2; }
        ;
 
+/*
+ * Map definition.
+ */
+
 map_sd
        : TSTATIC       { $$ = NPFCTL_NAT_STATIC; }
        | TDYNAMIC      { $$ = NPFCTL_NAT_DYNAMIC; }
@@ -319,6 +339,10 @@
        }
        ;
 
+/*
+ * Rule procedure definition and its parameters.
+ */
+
 rproc
        : PROCEDURE STRING CURLY_OPEN procs CURLY_CLOSE
        {
@@ -326,13 +350,6 @@
        }
        ;
 
-alg
-       : ALG STRING
-       {
-               npfctl_build_alg($2);
-       }
-       ;
-
 procs
        : proc_call SEPLINE procs
        {
@@ -383,6 +400,10 @@
        |               { $$ = NULL; }
        ;
 
+/*
+ * Group and dynamic ruleset definition.
+ */
+
 group
        : GROUP group_opts
        {
@@ -443,6 +464,10 @@
        |
        ;
 
+/*
+ * Rule and misc.
+ */
+
 rule
        : block_or_pass opt_stateful rule_dir opt_final on_ifname
          opt_family opt_proto all_or_filt_opts opt_apply
diff -r f5a5f38011e0 -r cd183128dc9a usr.sbin/npf/npfctl/npf_scan.l
--- a/usr.sbin/npf/npfctl/npf_scan.l    Mon Nov 18 20:51:03 2013 +0000
+++ b/usr.sbin/npf/npfctl/npf_scan.l    Mon Nov 18 21:39:03 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_scan.l,v 1.14 2013/11/12 00:46:34 rmind Exp $      */
+/*     $NetBSD: npf_scan.l,v 1.15 2013/11/18 21:39:03 rmind Exp $      */
 
 /*-
  * Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
@@ -186,7 +186,7 @@
                        return TABLE_ID;
                }
 
-"$"{ID}        {
+"$"{ID}                {
                        yylval.str = estrndup(yytext + 1, yyleng - 1);
                        return VAR_ID;
                }



Home | Main Index | Thread Index | Old Index