Module Name:    src
Committed By:   rmind
Date:           Mon Nov 18 21:39:03 UTC 2013

Modified Files:
        src/usr.sbin/npf/npfctl: npf_parse.y npf_scan.l

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


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/npf/npfctl/npf_parse.y
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/npf/npfctl/npf_scan.l

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/npf/npfctl/npf_parse.y
diff -u src/usr.sbin/npf/npfctl/npf_parse.y:1.27 src/usr.sbin/npf/npfctl/npf_parse.y:1.28
--- src/usr.sbin/npf/npfctl/npf_parse.y:1.27	Fri Nov  8 00:38:26 2013
+++ src/usr.sbin/npf/npfctl/npf_parse.y	Mon Nov 18 21:39:03 2013
@@ -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 @@ yyerror(const char *fmt, ...)
 %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 @@ lines
 	;
 
 line
-	: def
+	: vardef
 	| table
 	| map
 	| group
@@ -201,33 +201,45 @@ line
 	|
 	;
 
-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 @@ list_elem
 	}
 	;
 
+/*
+ * Table definition.
+ */
+
 table
 	: TABLE TABLE_ID TYPE table_type table_store
 	{
@@ -284,6 +300,10 @@ table_store
 	| TFILE STRING	{ $$ = $2; }
 	;
 
+/*
+ * Map definition.
+ */
+
 map_sd
 	: TSTATIC	{ $$ = NPFCTL_NAT_STATIC; }
 	| TDYNAMIC	{ $$ = NPFCTL_NAT_DYNAMIC; }
@@ -319,6 +339,10 @@ map
 	}
 	;
 
+/*
+ * Rule procedure definition and its parameters.
+ */
+
 rproc
 	: PROCEDURE STRING CURLY_OPEN procs CURLY_CLOSE
 	{
@@ -326,13 +350,6 @@ rproc
 	}
 	;
 
-alg
-	: ALG STRING
-	{
-		npfctl_build_alg($2);
-	}
-	;
-
 procs
 	: proc_call SEPLINE procs
 	{
@@ -383,6 +400,10 @@ proc_param_val
 	|		{ $$ = NULL; }
 	;
 
+/*
+ * Group and dynamic ruleset definition.
+ */
+
 group
 	: GROUP group_opts
 	{
@@ -443,6 +464,10 @@ rule_group
 	|
 	;
 
+/*
+ * 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

Index: src/usr.sbin/npf/npfctl/npf_scan.l
diff -u src/usr.sbin/npf/npfctl/npf_scan.l:1.14 src/usr.sbin/npf/npfctl/npf_scan.l:1.15
--- src/usr.sbin/npf/npfctl/npf_scan.l:1.14	Tue Nov 12 00:46:34 2013
+++ src/usr.sbin/npf/npfctl/npf_scan.l	Mon Nov 18 21:39:03 2013
@@ -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 @@ any			return ANY;
 			return TABLE_ID;
 		}
 
-"$"{ID}	{
+"$"{ID}		{
 			yylval.str = estrndup(yytext + 1, yyleng - 1);
 			return VAR_ID;
 		}

Reply via email to