[Xorp-hackers] [PATCH 2/4] xorp: rtrmgr: Add option to read negative int values
igorm at etf.rs
igorm at etf.rs
Tue Mar 13 03:49:13 PDT 2012
From: Igor Maravic <igorm at etf.rs>
In boot.ll and boot.yy added option to read negative int values. Positive
int values are read as uint values.
Signed-off-by: Igor Maravic <igorm at etf.rs>
---
xorp/rtrmgr/boot.ll | 5 +++++
xorp/rtrmgr/boot.yy | 6 ++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/xorp/rtrmgr/boot.ll b/xorp/rtrmgr/boot.ll
index 3f1d5c4..3e639ef 100644
--- a/xorp/rtrmgr/boot.ll
+++ b/xorp/rtrmgr/boot.ll
@@ -282,6 +282,11 @@ RE_ARITH_OPERATOR [" "]*({RE_BIN_OPERATOR})[" "]*
return UINT_VALUE;
}
+[-][0-9]+ {
+ bootlval = strdup(boottext);
+ return INT_VALUE;
+ }
+
{RE_IPV4}".."{RE_IPV4} {
bootlval = strdup(boottext);
return IPV4RANGE_VALUE;
diff --git a/xorp/rtrmgr/boot.yy b/xorp/rtrmgr/boot.yy
index f815477..8f47eff 100644
--- a/xorp/rtrmgr/boot.yy
+++ b/xorp/rtrmgr/boot.yy
@@ -68,6 +68,7 @@ ConfigOperator boot_lookup_operator(const char* s);
%token END
%left ASSIGN_OPERATOR
%token BOOL_VALUE
+%token INT_VALUE
%token UINT_VALUE
%token UINTRANGE_VALUE
%token IPV4_VALUE
@@ -117,6 +118,7 @@ literals: literals literal
| literal LITERAL { extend_path($2, NODE_TEXT, node_id); }
| literal BOOL_VALUE { extend_path($2, NODE_BOOL, node_id); }
| literal UINTRANGE_VALUE { extend_path($2, NODE_UINTRANGE, node_id); }
+ | literal INT_VALUE { extend_path($2, NODE_INT, node_id); }
| literal UINT_VALUE { extend_path($2, NODE_UINT, node_id); }
| literal IPV4RANGE_VALUE { extend_path($2, NODE_IPV4RANGE, node_id); }
| literal IPV4_VALUE { extend_path($2, NODE_IPV4, node_id); }
@@ -175,6 +177,10 @@ terminal: term_literal END {
terminal($3, NODE_UINT, boot_lookup_operator($2));
free($2);
}
+ | term_literal INFIX_OPERATOR INT_VALUE END {
+ terminal($3, NODE_INT, boot_lookup_operator($2));
+ free($2);
+ }
| term_literal INFIX_OPERATOR IPV4RANGE_VALUE END {
terminal($3, NODE_IPV4RANGE, boot_lookup_operator($2));
free($2);
--
1.7.5.4
More information about the Xorp-hackers
mailing list