]> nuage.metani.fr Git - 3GPP.git/blob - awk/txt2asn.awk
docx2asn.sh: adjusted removal of EN-dash and CR
[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 /^[0-9]+\./ {
19 in_IE = "no" ;
20 }
21
22 /^-- ASN1START/ {
23 print "";
24 in_ASN1 = "yes";
25 next;
26 }
27
28 /^-- ASN1STOP/ {
29 in_ASN1 = "no";
30 next;
31 }
32
33 /^-- TAG-/ {
34 next;
35 }
36
37 /^[[:space:]]*$/ {
38
39 if (next_line == "condition") {
40 print separator ;
41 }
42 if ((next_line == "field description") || (next_line == "field name")){
43 print separator ;
44 }
45
46 next_line = "" ;
47 # #if (empty_line == "yes") {
48 # next;
49 # }
50 empty_line = "yes" ;
51
52 # print "a" ;
53 # print ;
54 }
55
56 /^–[[:space:]]+ParentIE-WithEM$/ {
57 exit 0 ;
58 }
59
60 /^–[[:space:]]+[A-Za-z0-9-]+$/ {
61 if (empty_line == "yes") {
62 print ie_separator;
63 print "-- IE: " $2;
64 print "" ;
65 empty_line = "no" ;
66 conditions = "" ;
67 }
68 in_IE = "yes" ;
69 next ;
70 }
71
72 /^Conditional Presence/ {
73 add_line_after = "";
74 separator = "" ;
75
76 $0 = "Conditional presence" ;
77 for(i=0;i<=140;i++) {
78 separator = separator "-" ;
79 }
80 # print separator;
81 #add_line_after = separator ;
82 next_line = "condition" ;
83 }
84
85 # Need to catch "x and y field descriptions"
86
87 /field descriptions$/ {
88 add_line_after = "";
89 separator = "" ;
90
91 for(i=0;i<=140;i++) {
92 separator = separator "-" ;
93 }
94 # print separator;
95 # add_line_after = separator ;
96 next_line = "field name" ;
97 }
98
99 #/^[A-Za-z0-9-]+[[:space:]]+[A-Za-z0-9-]+/ {
100 # if (next_line == "field description") {
101 # add_line_after = separator ;
102 # next_line = "field name";
103 # }
104 #}
105
106 /^[A-Za-z0-9-]+(, [A-Za-z0-9-]+)*$/ {
107 if (next_line == "field name") {
108
109 print separator ;
110
111 $0 = "Field: " $0
112 #add_line_after = " ";
113 next_line = "field description";
114 }
115 else if (next_line == "field description") {
116 print separator ;
117
118 $0 = "Field: " $0
119 #add_line_after = separator ;
120 #print "separator est " separator;
121 next_line = "field name";
122 }
123 }
124
125
126
127 {
128 if (in_IE == "yes") {
129 if ((next_line == "condition") && ($1 != "Conditional")) {
130
131 if (index(conditions, $1) != 0) {
132 print separator;
133 print "-- Condition: " $1;
134 $1 = "";
135 }
136 if ((in_ASN1 == "no") && !(/^\s*$/)) {
137 $0 = "-- " $0 ;
138 }
139 print ;
140 }
141
142 else {
143 if ((in_ASN1 == "no") && !(/^\s*$/)) {
144 $0 = "-- " $0 ;
145 }
146 print;
147 }
148
149 if (add_line_after != "") {
150 print add_line_after ;
151 add_line_after = "" ;
152 }
153
154 if (/-- Cond [A-Za-z0-9-]+$/) {
155 conditions = conditions " " $NF ;
156 }
157 }
158 }
159