|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T d ┃
Length: 4952 (0x1358) Types: TextFile Names: »dep-scan.awk«
└─⟦85b835f43⟧ Bits:30000549 8mm tape, Rational 1000, Xlib rev 6.00 └─ ⟦0c20f784e⟧ »DATA« └─⟦1abbe589f⟧ └─⟦dfeb830e8⟧ └─ ⟦this⟧ »rev6-0-0/tools/config/dep-scan.awk«
# dep-scan.awk # # Used to scan an Ada source file and extract inter-module dependencies. # We simply scan the file and: # # 1) A WITH is always followed by a single name and the name is on that same # line. "with name;", "with name ;", "WITH name;", etc. are all ok. # # 2) A PACKAGE, PACKAGE BODY, PROCEDURE, or FUNCTION declaration aways begins # on a line by itself and the name of the Ada unit is on that same line. # # 3) Any unit that has a line beginning with the word END followed by # anything other than RECORD is a BODY unit. Any other unit is a SPEC # unit. # # 4) Any unit that has a line beginning with the word GENERIC is a GENERIC # unit unless it is a BODY unit. # # If you have a coding style that puts more than one name in a WITH list or # if you put names on different lines than the keywords or otherwise violate # these assuptions then you get to rewrite this script or reformat your Ada # code. # # Our output usually consists of a single line of this form: # # <unit name> <filename> <GENERIC/BODY/SPEC> <lib> <dep. units> # # The <unit name> is the name of the Ada unit as extracted from the main # declaration line as described above as #2. The <filename> is simply the # name of the file we are scanning. The <GENERIC/BODY/SPEC> is obtained # by means of #3 or #4 above. The <dep. units> are simply the Ada unit names # mentioned in the WITHs scanned as #1 describes. <lib> is the library we # are using for compilations. # # If we are processing an Ada IS SEPARATE body then we also put out a second # line of the form: # # <unit name> <filename> SEPARATE <separate> # # The <separate> is the name of our parent body. #---We assume it is a SPEC. BEGIN { HaveName = 0; What = "SPEC"; Deps[""] = ""; } #---Any line that begins with WITH is a line for us. It is a dependency. # Remove any ';'s that may be present. $1 ~ /^[Ww][Ii][Tt][Hh]$/ { if ($0 ~ /^[^;]*,/) { print "Line is not of the form 'WITH <name> ;'?"; print "{", $0, "}"; exit 1; } With = $2 ; i = index( With, ";" ); if (i > 0) { With = substr( With, 1, i-1 ); } Deps[With] = With; next; } #---SEPARATE lines are similar to WITH's in terms of what they require. /^ *[Ss][Ee][Pp][Aa][Rr][Aa][Tt][Ee] *\( *[a-zA-Z0-9_]+ *\)/ { Separate = $0 ; i = index( Separate, "(" ); Separate = substr( Separate, i+1 ); i = index( Separate, ")" ); Separate = substr( Separate, 1, i-1 ); i = split( Separate, j, " " ); Separate = j[1]; What = "BODY"; next; } #---Any of these lines will determine the name of the Ada unit. $1 ~ /^[Pp][Aa][Cc][Kk][Aa][Gg][Ee]$/ && $2 ~ /^[Bb][Oo][Dd][Yy]$/ { if (NF < 3) { print "Expected 'package body <name>' and found:", $0 ; exit 1; } Name = $3; if (Name ~ /[^a-zA-Z0-9_]/) { for (i = 1; i <= length(Name); i++) { if (substr( Name, i, 1 ) ~ /[^a-zA-Z0-9_]/) { Name = substr( Name, 1, i-1 ); break; } } } Name = Name " " FILENAME; What = "BODY"; exit; } $1 ~ /^[Pp][Aa][Cc][Kk][Aa][Gg][Ee]$/ && HaveName == 0 { if (NF < 2) { print "Expected 'package <name>' and found: " $0 ; exit 1; } Name = $2; if (Name ~ /[^a-zA-Z0-9_]/) { for (i = 1; i <= length(Name); i++) { if (substr( Name, i, 1 ) ~ /[^a-zA-Z0-9_]/) { Name = substr( Name, 1, i-1 ); break; } } } Name = Name " " FILENAME; HaveName = 1; next; } $1 ~ /^[Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn]$/ && HaveName == 0 { if (NF < 2) { print "Expected 'function <name>' and found: " $0 ; exit 1; } if (Name != "") { next; } Name = $2; if (Name ~ /[^a-zA-Z0-9_]/) { for (i = 1; i <= length(Name); i++) { if (substr( Name, i, 1 ) ~ /[^a-zA-Z0-9_]/) { Name = substr( Name, 1, i-1 ); break; } } } Name = Name " " FILENAME; HaveName = 1; next; } $1 ~ /^[Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee]$/ && HaveName == 0 { if (NF < 2) { print "Expected 'procedure <name>' and found: " $0 ; exit 1; } if (Name != "") { next; } Name = $2; if (Name ~ /[^a-zA-Z0-9_]/) { for (i = 1; i <= length(Name); i++) { if (substr( Name, i, 1 ) ~ /[^a-zA-Z0-9_]/) { Name = substr( Name, 1, i-1 ); break; } } } Name = Name " " FILENAME; HaveName = 1; next; } #---These things determine that the unit is not (just) a SPEC. $1 ~ /^[Gg][Ee][Nn][Ee][Rr][Ii][Cc]$/ { if (What == "SPEC") { What = "GENERIC"; } if (HaveName != 0) { exit; } next; } $1 ~ /^[Bb][Ee][Gg][Ii][Nn]$/ { if (NF == 1 || $2 !~ /^[Rr][Ee][Cc][Oo][Rr][Dd]($|[^a-zA-Z0-9_])/) { What = "BODY"; exit; } next; } #---Skip any other lines. { next; } #---Put out our single result line. END { if (Name == "") { print "No name was found for the Ada unit in", FILENAME, "."; exit 1; } Dep = ""; for (i in Deps) { Dep = Dep " " Deps[i]; if (length( Dep ) > 128) { print "@" Dep >> OFile; Dep = ""; } } if (Separate != "") { print Name, "SEPARATE", Working, Separate Dep >> OFile; } else { print Name, What, Working Dep >> OFile; } }