]> nuage.metani.fr Git - 3GPP.git/blob - awk/txt2asn.awk
Add command to set git proxy to windows system proxy
[3GPP.git] / awk / txt2asn.awk
1 #!/bin/awk -f
2
3 BEGIN {
4 add_line_after != "" ;
5 separator = "" ;
6
7 wide_separator = "" ;
8 for(i=0;i<=140;i++) {
9 wide_separator = wide_separator "-" ;
10 }
11
12 ie_separator = "-- " ;
13 for (i=0;i<=137;i++) {
14 ie_separator = ie_separator "=" ;
15 }
16 }
17
18 # Section headers
19 # This will also catch bits of Short Message description but that won't cause issues
20 # A way not to catch those could be to check that the numbers are in sequence
21
22 /^[0-9]+(\.[0-9]+)*\t/ {
23 in_IE = "no" ;
24 # print "Titre" ;
25 # print ;
26 }
27
28 /^-- ASN1START/ {
29 print "";
30 in_ASN1 = "yes";
31 next;
32 }
33
34 /^-- ASN1STOP/ {
35 in_ASN1 = "no";
36 next;
37 }
38
39 /^-- TAG-/ {
40 next;
41 }
42
43 # Recording empty line (to avoid multiple empty lines)
44 # Printing separators in some cases
45
46 /^[[:space:]]*$/ {
47
48 if (next_line == "condition") {
49 print separator ;
50 }
51 if ((next_line == "field description") || (next_line == "field name")){
52 print separator ;
53 }
54
55 next_line = "" ;
56 # #if (empty_line == "yes") {
57 # next;
58 # }
59 empty_line = "yes" ;
60
61 # print "a" ;
62 # print ;
63 }
64
65 # Stopping before ASN.1 examples (end of specification)
66 /^-[[:space:]]+ParentIE-WithEM$/ {
67 exit 0 ;
68 }
69
70 # Start of IE definitions
71 # This cannot catch "Multiplicity and type constraints"
72 # This also cannot catch NR-InterNodeDefinitions
73 /^-[[:space:]]+[A-Za-z0-9-]+$/ {
74 if (empty_line == "yes") {
75 print ie_separator;
76 print "-- IE: " $2;
77 print "" ;
78 empty_line = "no" ;
79 conditions = "" ;
80 }
81 in_IE = "yes" ;
82 next ;
83 }
84
85 /^NR-InterNodeDefinitions/ {
86 if (empty_line == "yes") {
87 print ie_separator;
88 print "-- IE: NR-InterNodeDefinitions";
89 print "" ;
90 # Perhaps it could work without this if the "next" at the end is removed
91 print ;
92 empty_line = "no" ;
93 conditions = "" ;
94 }
95 in_IE = "yes" ;
96 next ;
97 }
98
99
100 # Sometimes there is an "s" to constraint, sometimes not
101 /^-[[:space:]]+Multiplicity and type constraints? definitions$/ {
102 if (empty_line == "yes") {
103 print ie_separator;
104 print "-- IE: Constants";
105 empty_line = "no" ;
106 conditions = "" ;
107 }
108 in_IE = "yes" ;
109 next ;
110 }
111
112 #/^-[[:space:]]+Multiplicity and type constraints definitions/ {
113 # in_IE = "yes" ;
114 # next ;
115 #}
116
117 /^Conditional Presence/ {
118 add_line_after = "";
119 separator = "" ;
120
121 $0 = "Conditional presence" ;
122 for(i=0;i<=140;i++) {
123 separator = separator "-" ;
124 }
125 # print separator;
126 #add_line_after = separator ;
127 next_line = "condition" ;
128 }
129
130 # Need to catch "x and y field descriptions"
131
132 /field descriptions$/ {
133 add_line_after = "";
134 separator = "" ;
135
136 for(i=0;i<=140;i++) {
137 separator = separator "-" ;
138 }
139 # print separator;
140 # add_line_after = separator ;
141 next_line = "field name" ;
142 }
143
144 #/^[A-Za-z0-9-]+[[:space:]]+[A-Za-z0-9-]+/ {
145 # if (next_line == "field description") {
146 # add_line_after = separator ;
147 # next_line = "field name";
148 # }
149 #}
150
151 /^[A-Za-z0-9-]+(, [A-Za-z0-9-]+)*$/ {
152 if (next_line == "field name") {
153
154 print separator ;
155
156 $0 = "Field: " $0
157 #add_line_after = " ";
158 next_line = "field description";
159 }
160 else if (next_line == "field description") {
161 print separator ;
162
163 $0 = "Field: " $0
164 #add_line_after = separator ;
165 #print "separator est " separator;
166 next_line = "field name";
167 }
168 }
169
170
171
172 {
173 if (in_IE == "yes") {
174 if ((next_line == "condition") && ($1 != "Conditional")) {
175
176 if (index(conditions, $1) != 0) {
177 print separator;
178 print "-- Condition: " $1;
179 $1 = "";
180 }
181 if ((in_ASN1 == "no") && !(/^\s*$/)) {
182 $0 = "-- " $0 ;
183 }
184 print ;
185 }
186
187 else {
188 if ((in_ASN1 == "no") && !(/^\s*$/)) {
189 $0 = "-- " $0 ;
190 }
191 print;
192 }
193
194 if (add_line_after != "") {
195 print add_line_after ;
196 add_line_after = "" ;
197 }
198
199 if (/-- Cond [A-Za-z0-9-]+$/) {
200 conditions = conditions " " $NF ;
201 }
202 }
203 }
204