- $Stuff{"$mod:declarations"} .= $_; # just save it up
-
- if ( /^[A-Z][A-Za-z0-9_']*\.(\S+)\s+::\s+/ ) {
- $Decl{"$mod:$1"} = $_;
-
- } elsif ( /^type\s+[A-Z][A-Za-z0-9_']*\.(\S+)/ ) {
- $Decl{"$mod:$1"} = $_;
-
- } elsif ( /^(newtype|data)\s+(.*\s+=>\s+)?[A-Z][A-Za-z0-9_']*\.(\S+)\s+/ ) {
- $Decl{"$mod:$3"} = $_;
-
- } elsif ( /class\s+(.*\s+=>\s+)?[A-Z][A-Za-z0-9_']*\.(\S+)\s+.*where\s+\{.*\};/ ) {
- $Decl{"$mod:$2"} = $_; # must be wary of => bit matching after "where"...
- } elsif ( /class\s+(.*\s+=>\s+)?[A-Z][A-Za-z0-9_']*\.(\S+)\s+/ ) {
- $Decl{"$mod:$2"} = $_;
-
- } else { # oh, well...
- print STDERR "$Pgm: decl line didn't match?\n$_";
+ # We're in a declaration
+
+ # Strip off the initial version number, if any
+ if ( /^([0-9]+) (.*\n)/ ) {
+ # The "\n" is because we need to keep the newline at the end, so that
+ # it looks the same as if there's no version number and this if statement
+ # doesn't fire.
+
+ # So there's an initial version number
+ $version = $1;
+ $_ = $2;
+ }
+
+ if ( /^(\S+)\s+_:_\s+/ ) {
+ $current_name = $1;
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } elsif ( /^type\s+(\S+)/ ) {
+ $current_name = $1;
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } elsif ( /^(newtype|data)\s+(.*\s+=>\s+)?(\S+)\s+/ ) {
+ $current_name = $3;
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } elsif ( /class\s+(.*\s+=>\s+)?(\S+)\s+.*where\s+\{.*\};/ ) {
+ # must be wary of => bit matching after "where"...
+ $current_name = $2;
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } elsif ( /class\s+(.*\s+=>\s+)?(\S+)\s+/ ) {
+ $current_name = $2;
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } else { # Continuation line
+ $Decl{"$mod:$current_name"} .= $_