]> nuage.metani.fr Git - 3GPP.git/blobdiff - awk/txt2asn.awk
Add -p before mkdir
[3GPP.git] / awk / txt2asn.awk
index 1eb8414f61362acff287bc50a18dde2460da5746..09cc066fdd49cfc354d9279c65f4bd78538fc20f 100755 (executable)
@@ -5,18 +5,24 @@ BEGIN {
     separator = "" ;
 
     wide_separator = "" ;
     separator = "" ;
 
     wide_separator = "" ;
-    for(i=0;i<=140;i++) {
+    for(i=0;i<=70;i++) {
        wide_separator = wide_separator "-" ;
     }
 
     ie_separator = "-- " ;
        wide_separator = wide_separator "-" ;
     }
 
     ie_separator = "-- " ;
-    for (i=0;i<=137;i++) {
+    for (i=0;i<=70;i++) {
        ie_separator = ie_separator "=" ;
     }
 }
 
        ie_separator = ie_separator "=" ;
     }
 }
 
-/^[0-9]+\./ {
+# Section headers
+# This will also catch bits of Short Message description but that won't cause issues
+# A way not to catch those could be to check that the numbers are in sequence
+
+/^[0-9]+(\.[0-9]+)*\t/ {
     in_IE = "no" ;
     in_IE = "no" ;
+#    print "Titre" ;
+#    print ;
 }
 
 /^-- ASN1START/ {
 }
 
 /^-- ASN1START/ {
@@ -34,6 +40,9 @@ BEGIN {
     next;
 }
 
     next;
 }
 
+# Recording empty line (to avoid multiple empty lines)
+# Printing separators in some cases
+
 /^[[:space:]]*$/ {
 
      if (next_line == "condition") {
 /^[[:space:]]*$/ {
 
      if (next_line == "condition") {
@@ -53,11 +62,15 @@ BEGIN {
 #    print ; 
 }
 
 #    print ; 
 }
 
-/^–[[:space:]]+ParentIE-WithEM$/ {
+# Stopping before ASN.1 examples (end of specification)
+/^-[[:space:]]+ParentIE-WithEM$/ {
     exit 0 ;
 }
 
     exit 0 ;
 }
 
-/^–[[:space:]]+[A-Za-z0-9-]+$/ {
+# Start of IE definitions
+# This cannot catch "Multiplicity and type constraints"
+# This also cannot catch NR-InterNodeDefinitions
+/^-[[:space:]]+[A-Za-z0-9-]+$/ {
     if (empty_line == "yes") {
        print ie_separator;
        print "-- IE: " $2;
     if (empty_line == "yes") {
        print ie_separator;
        print "-- IE: " $2;
@@ -69,15 +82,45 @@ BEGIN {
     next ;
 }
 
     next ;
 }
 
+/^NR-InterNodeDefinitions/ {
+    if (empty_line == "yes") {
+       print ie_separator;
+       print "-- IE: NR-InterNodeDefinitions";
+       print "" ;
+       # Perhaps it could work without this if the "next" at the end is removed
+       print ;
+       empty_line = "no" ;
+       conditions = "" ;
+    }
+    in_IE = "yes" ;
+    next ;
+}
+
+
+# Sometimes there is an "s" to constraint, sometimes not
+/^-[[:space:]]+Multiplicity and type constraints? definitions$/ {
+    if (empty_line == "yes") {
+       print ie_separator;
+       print "-- IE: Constants";
+       empty_line = "no" ;
+       conditions = "" ;
+    }
+    in_IE = "yes" ;
+    next ;
+}
+
+#/^-[[:space:]]+Multiplicity and type constraints definitions/ {
+#    in_IE = "yes" ;
+#    next ;
+#}
+
 /^Conditional Presence/ {
     add_line_after = "";
 /^Conditional Presence/ {
     add_line_after = "";
-    separator = "" ;
+    separator = ie_separator ;
 
     $0 = "Conditional presence" ;
 
     $0 = "Conditional presence" ;
-    for(i=0;i<=140;i++) {
-       separator = separator "-" ;
-    }
-#    print separator;
+  
+    print separator;
     #add_line_after = separator ;
     next_line = "condition" ;
 }
     #add_line_after = separator ;
     next_line = "condition" ;
 }
@@ -86,12 +129,9 @@ BEGIN {
 
 /field descriptions$/ {
     add_line_after = "";
 
 /field descriptions$/ {
     add_line_after = "";
-    separator = "" ;
 
 
-    for(i=0;i<=140;i++) {
-       separator = separator "-" ;
-    }
-#    print separator;
+    separator = ie_separator;
+    print separator;
 #   add_line_after = separator ;
     next_line = "field name" ;
 }
 #   add_line_after = separator ;
     next_line = "field name" ;
 }
@@ -107,6 +147,7 @@ BEGIN {
     if (next_line == "field name") {
        
        print separator ;
     if (next_line == "field name") {
        
        print separator ;
+       separator = wide_separator ;
        
        $0 = "Field: " $0
        #add_line_after = " ";
        
        $0 = "Field: " $0
        #add_line_after = " ";
@@ -114,6 +155,7 @@ BEGIN {
     }
     else if (next_line == "field description") {
        print separator ;
     }
     else if (next_line == "field description") {
        print separator ;
+       separator = wide_separator ;
        
        $0 = "Field: " $0
        #add_line_after = separator ;
        
        $0 = "Field: " $0
        #add_line_after = separator ;
@@ -130,6 +172,7 @@ BEGIN {
           
            if (index(conditions, $1) != 0) {
                print separator;
           
            if (index(conditions, $1) != 0) {
                print separator;
+               separator = wide_separator ;
                print "-- Condition: " $1;
                $1 = "";
            }
                print "-- Condition: " $1;
                $1 = "";
            }