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