- } elsif ( $now_in eq 'versions' && /^(\S+) (\d+)/ ) {
- local($item) = $1;
- local($n) = $2;
-#print STDERR "version read:item=$item, n=$n, line=$_";
- $Version{"$mod:$item"} = $n;
-
- } elsif ( $now_in eq 'versions' && /^(\S+)/ && $mod eq 'new') { # doesn't have versions
- local($item) = $1;
-#print STDERR "new version read:item=$item, line=$_";
- $Version{"$mod:$item"} = 'y'; # stub value...
-
- } elsif ( $now_in =~ /^(exports|instance_modules|instances|fixities|pragmas)$/ ) {
- $Stuff{"$mod:$1"} .= $_; # just save it up
-
- } elsif ( $now_in eq 'declarations' ) { # relatively special treatment needed...
- $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$_";
+ } elsif ( /^__instimport/ ) {
+ $Stuff{"$mod:instance_modules"} .= $_;
+
+ } elsif ( /^__export/ ) {
+ $Stuff{"$mod:exports"} .= $_;
+
+ } elsif ( /^infix(r|l)? / ) {
+ $Stuff{"$mod:fixities"} .= $_;
+
+ } elsif ( /^instance / ) {
+ $Stuff{"$mod:instances"} .= $_;
+
+ } elsif ( /^--.*/ ) { # silently ignore comment lines.
+ ;
+ } else { # We're in a declaration
+
+ # Strip off the initial version number, if any
+ if ( /^([0-9]+)\s+(.*\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 ( /^type\s+(\S+)/ ) {
+ # Type declaration
+ $current_name = "type $1";
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } elsif ( /^(newtype|data)\s+(.*\s+=>\s+)?(\S+)\s+/ ) {
+ # Data declaration
+ $current_name = "data $3";
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } elsif ( /^class\s+(\{[^{}]*\}\s+=>\s+)?(\S+)\s+/ ) {
+ # Class declaration
+ # must be wary of => bit matching after "where"...
+ # ..hence the [^{}] part
+ # NB: a class decl may not have a where part at all
+ $current_name = "class $2";
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } elsif ( /^(\S+)\s+::\s+/ ) {
+ # Value declaration
+ $current_name = $1;
+ $Decl{"$mod:$current_name"} = $_;
+ if ($mod eq "old") { $OldVersion{$current_name} = $version; }
+
+ } else { # Continuation line
+ print STDERR "$Pgm:junk old iface line?:$_";
+ # $Decl{"$mod:$current_name"} .= $_