cisco.grammar: parse au/tug inside sonet controller
author"Tomas Zeman <tzeman@volny.cz>"
Thu, 26 Nov 2009 11:07:18 +0100
changeset 15 fb5c38cb93a9
parent 14 dbd1564b0444
child 16 6822d0e5df57
cisco.grammar: parse au/tug inside sonet controller
cisco.grammar
--- a/cisco.grammar	Thu Nov 26 09:39:23 2009 +0100
+++ b/cisco.grammar	Thu Nov 26 11:07:18 2009 +0100
@@ -7,11 +7,19 @@
 
 $::res = {};
 
-# Returns pointer to context hasref as specified by ctx stack.
+# Returns pointer to context hashref as specified by ctx stack.
 # @param ctx_path array of ctx stack.
 sub ctx {
+	return ctx_rel($::res, @_);
+}
+
+# Returns pointer to context hashref as specified by ctx stack,
+# relative to the supplied ctx pointer.
+# @param ptr current ctx pointer from which ctx build starts.
+# @param ctx_path array of ctx stack.
+sub ctx_rel {
+	my $ptr = shift;
 	my @ctx_path = @_;
-	my $ptr = $::res;
 	foreach my $part (@ctx_path) {
 		$ptr->{$part} = {} unless exists ($ptr->{$part});
 		$ptr = $ptr->{$part};
@@ -116,6 +124,16 @@
 		{ $arg{ctx}->{"channel-group"}->{$item{num}}->{unframed} = 1 }
 		| "framing" keyword
 		{ $arg{ctx}->{framing} = $item{keyword} }
+		| "au-4" num "tug-3" num eol s_tug_l[ctx => ctx_rel($arg{ctx}, 'au', $item[2], 'tug', $item[4]) ](s)
+
+s_tug_l:	"2" "tug-2" num "e1" num tug_content[ctx => ctx_rel($arg{ctx}, $item[3].'/'.$item[5]) ] eol
+
+tug_content:	l_description[ctx => $arg{ctx}]
+		| "unframed"
+		{ $arg{ctx}->{unframed} = 1 }
+		| "channel-group" num "timeslots" range
+		{ $arg{ctx}->{"channel-group"}->{$item{num}}->{ts} = $item{range} }
+		| word(s)
 
 # Vlan range
 vlan_s_range:	/\d+/"-"/\d+/
@@ -152,7 +170,7 @@
 		| /(no)?/ "shutdown"
 		{ $arg{ctx}->{shutdown} = ($item[1] eq 'no') ? 0 : 1 }
 		| "ip" "address" ip ip
-		{ $arg{ctx}->{ip} = $item[3]; $arg{ctx}->{mask} = $item[3] }
+		{ $arg{ctx}->{ip} = $item[3]; $arg{ctx}->{mask} = $item[4] }
 		| "encapsulation" keyword /\S*/
 		{
 		$arg{ctx}->{encap} = $item[2];