| 4077 |      1 | #
 | 
|  |      2 | # $Id$
 | 
| 9789 |      3 | # Author: Markus Wenzel, TU Muenchen
 | 
| 4077 |      4 | #
 | 
|  |      5 | # fixclasimp.pl - fix references to implicit claset and simpset
 | 
|  |      6 | #
 | 
|  |      7 | 
 | 
|  |      8 | sub fixclasimp {
 | 
|  |      9 |     my ($file) = @_;
 | 
|  |     10 | 
 | 
|  |     11 |     open (FILE, $file) || die $!;
 | 
|  |     12 |     undef $/; $text = <FILE>; $/ = "\n";         # slurp whole file
 | 
|  |     13 |     close FILE || die $!;
 | 
|  |     14 | 
 | 
|  |     15 |     $_ = $text;
 | 
|  |     16 | 
 | 
| 4110 |     17 |     s/set_current_thy\s*"([^"]*)"/context $1.thy/sg;
 | 
| 4077 |     18 | 
 | 
|  |     19 |     s/!\s*simpset/simpset()/sg;
 | 
|  |     20 |     s/simpset\s*:=/simpset_ref() :=/sg;
 | 
|  |     21 |     s/simpset_of\s*"([^"]*)"/simpset_of $1.thy/sg;
 | 
|  |     22 | 
 | 
|  |     23 |     s/!\s*claset/claset()/sg;
 | 
|  |     24 |     s/claset\s*:=/claset_ref() :=/sg;
 | 
|  |     25 |     s/claset_of\s*"([^"]*)"/claset_of $1.thy/sg;
 | 
|  |     26 | 
 | 
|  |     27 | 
 | 
|  |     28 |     $result = $_;
 | 
|  |     29 | 
 | 
|  |     30 |     if ($text ne $result) {
 | 
|  |     31 | 	print STDERR "fixing $file\n";
 | 
|  |     32 |         if (! -f "$file~~") {
 | 
|  |     33 | 	    rename $file, "$file~~" || die $!;
 | 
|  |     34 |         }
 | 
|  |     35 | 	open (FILE, "> $file") || die $!;
 | 
|  |     36 | 	print FILE $result;
 | 
|  |     37 | 	close FILE || die $!;
 | 
|  |     38 |     }
 | 
|  |     39 | }
 | 
|  |     40 | 
 | 
|  |     41 | 
 | 
|  |     42 | ## main
 | 
|  |     43 | 
 | 
|  |     44 | foreach $file (@ARGV) {
 | 
|  |     45 |   eval { &fixclasimp($file); };
 | 
|  |     46 |   if ($@) { print STDERR "*** fixclasimp $file: ", $@, "\n"; }
 | 
|  |     47 | }
 |