4 # A record is an IE heading
5 RS =
"-- =+\n-- IE: [A-Z][A-Za-z0-9-]+"
10 # Do not add new lines when printing
15 print "Usage: " ARGV[0] " file.asn"
16 print "Splits file.asn generated by txt2asn into one file per module"
20 gsub(/.asn$
/, "", file_prefix
)
26 # Search for the start of a module definition in every field (= line) of the IE
27 for (i =
1; i
<=
NF; i
++) {
28 if ($i ~
/[[A
-Z
][A
-Za
-z0
-9-]+ DEFINITIONS AUTOMATIC TAGS
::=
/) {
29 split($i, module_name
, " ")
30 outfile = file_prefix
"-" module_name
[1] ".asn"
34 # See below about heading
36 print heading
$0 > outfile
39 # RT is the record terminator i.e., the string that matched RS
40 # It actually is the heading of the next record, so store it
41 # to be printed with the next record.