lib/scripts/fixclasimp.pl
author wenzelm
Tue, 13 Feb 2001 16:31:18 +0100
changeset 11109 ce1cefc6c14c
parent 9789 7e5e6c47c0b5
child 14981 e73f8140af78
permissions -rw-r--r--
tuned;

#
# $Id$
# Author: Markus Wenzel, TU Muenchen
# License: GPL (GNU GENERAL PUBLIC LICENSE)
#
# fixclasimp.pl - fix references to implicit claset and simpset
#

sub fixclasimp {
    my ($file) = @_;

    open (FILE, $file) || die $!;
    undef $/; $text = <FILE>; $/ = "\n";         # slurp whole file
    close FILE || die $!;

    $_ = $text;

    s/set_current_thy\s*"([^"]*)"/context $1.thy/sg;

    s/!\s*simpset/simpset()/sg;
    s/simpset\s*:=/simpset_ref() :=/sg;
    s/simpset_of\s*"([^"]*)"/simpset_of $1.thy/sg;

    s/!\s*claset/claset()/sg;
    s/claset\s*:=/claset_ref() :=/sg;
    s/claset_of\s*"([^"]*)"/claset_of $1.thy/sg;


    $result = $_;

    if ($text ne $result) {
	print STDERR "fixing $file\n";
        if (! -f "$file~~") {
	    rename $file, "$file~~" || die $!;
        }
	open (FILE, "> $file") || die $!;
	print FILE $result;
	close FILE || die $!;
    }
}


## main

foreach $file (@ARGV) {
  eval { &fixclasimp($file); };
  if ($@) { print STDERR "*** fixclasimp $file: ", $@, "\n"; }
}