[Xorp-hackers] [PATCH 01/15] xorp:rtrmgr: Add patern for one line comment

igorm at etf.rs igorm at etf.rs
Fri Aug 31 04:33:47 PDT 2012


From: Igor Maravic <igorm at etf.rs>

Everything in a line, that is behind %% is considered a comment.

Signed-off-by: Igor Maravic <igorm at etf.rs>
---
 xorp/rtrmgr/boot.ll        |   10 ++++++++++
 xorp/rtrmgr/op_commands.ll |   10 ++++++++++
 xorp/rtrmgr/template.ll    |   12 ++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/xorp/rtrmgr/boot.ll b/xorp/rtrmgr/boot.ll
index d832afd..6e682ae 100644
--- a/xorp/rtrmgr/boot.ll
+++ b/xorp/rtrmgr/boot.ll
@@ -33,6 +33,7 @@ extern YYSTYPE bootlval;
 %option noyywrap
 %option nounput
 %option never-interactive
+%x one_liner
 %x comment
 %x string
 %x arith
@@ -453,6 +454,15 @@ RE_ARITH_OPERATOR	[" "]*({RE_BIN_OPERATOR})[" "]*
 
 <comment>"*"+"/"	BEGIN(INITIAL);
 
+"%%"				BEGIN(one_liner);
+
+<one_liner>[^\n]*	/* eat up everything, except new line*/
+
+<one_liner>\n	{
+				boot_linenum++;
+				BEGIN(INITIAL);
+				}
+
 .	{
 	/* everything else is a syntax error */
 	return SYNTAX_ERROR;
diff --git a/xorp/rtrmgr/op_commands.ll b/xorp/rtrmgr/op_commands.ll
index 0052a41..6dea7a4 100644
--- a/xorp/rtrmgr/op_commands.ll
+++ b/xorp/rtrmgr/op_commands.ll
@@ -30,6 +30,7 @@ extern YYSTYPE opcmdlval;
 %option noyywrap
 %option nounput
 %option never-interactive
+%x one_liner
 %x comment
 %x string
 
@@ -151,6 +152,15 @@ extern YYSTYPE opcmdlval;
 
 <comment>"*"+"/"	BEGIN(INITIAL);
 
+"%%"				BEGIN(one_liner);
+
+<one_liner>[^\n]*	/* eat up everything, except new line*/
+
+<one_liner>\n	{
+				opcmd_linenum++;
+				BEGIN(INITIAL);
+				}
+
 .	{
 	/* everything else is a syntax error */
 	return SYNTAX_ERROR;
diff --git a/xorp/rtrmgr/template.ll b/xorp/rtrmgr/template.ll
index a256ccb..d9f9184 100644
--- a/xorp/rtrmgr/template.ll
+++ b/xorp/rtrmgr/template.ll
@@ -29,6 +29,7 @@ extern YYSTYPE tpltlval;
 %option noyywrap
 %option nounput
 %option never-interactive
+%x one_liner
 %x comment
 %x string
 
@@ -487,6 +488,17 @@ RE_URL_SUBDELIMS "!"|"$"|"&"|"'"|"("|")"|"*"|"+"|","|";"|"="
 
 <comment>"*"+"/"	BEGIN(INITIAL);
 
+"%%"				BEGIN(one_liner);
+
+<one_liner>[^\n]*	/* eat up everything, except new line*/
+
+<one_liner>\n	{
+				tplt_linenum++;
+				BEGIN(INITIAL);
+				}
+
+
+
 .	{
 	/* everything else is a syntax error */
 	return SYNTAX_ERROR;
-- 
1.7.9.5



More information about the Xorp-hackers mailing list