Script that adapts theories and proof scripts to new datatype package.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/Tools/fixdatatype Thu Jul 30 15:49:18 1998 +0200
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# $Id$
+#
+# DESCRIPTION: adapt theories and proof scripts to new datatype package
+
+
+## diagnostics
+
+PRG=$(basename $0)
+
+function usage()
+{
+ echo
+ echo "Usage: $PRG [FILES|DIRS...]"
+ echo
+ echo " Recursively find .thy/.ML files, adapting them to"
+ echo " the new datatype package"
+ echo
+ echo " Renames old versions of FILES by appending \"~~\"."
+ echo
+ exit 1
+}
+
+
+## process command line
+
+[ $# -eq 0 -o "$1" = "-?" ] && usage
+
+SPECS="$@"; shift $#
+
+
+## main
+
+find $SPECS \( -name \*.thy -o -name \*.ML \) -print | \
+ xargs perl -w $ISABELLE_HOME/lib/scripts/fixdatatype.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/scripts/fixdatatype.pl Thu Jul 30 15:49:18 1998 +0200
@@ -0,0 +1,48 @@
+#
+# $Id$
+#
+# fixdatatype.pl - adapt theories and proof scripts to new datatype package
+#
+
+sub fixdatatype {
+ my ($file) = @_;
+
+ open (FILE, $file) || die $!;
+ undef $/; $text = <FILE>; $/ = "\n"; # slurp whole file
+ close FILE || die $!;
+
+ $_ = $text;
+
+ ## convert split_type_case[_asm] to type.split[_asm]
+ s/([^"])\bsplit_([\w]+)_case\b/$1$2.split/sg;
+ s/([^"])\bsplit_([\w]+)_case_asm\b/$1$2.split_asm/sg;
+
+ ## delete function name and type after "primrec"
+ s/\bprimrec\b\s+([\w]+|"[^"]+")\s+([\w\.]+)/primrec/sg;
+
+ ## replace specific induct_tac by generic induct_tac
+ s/[\w\.]+\.induct_tac/induct_tac/sg;
+
+ ## replace res_inst_tac ... natE by exhaust_tac
+ s/\bres_inst_tac\b\s*\[\s*\(\s*"[^"]+"\s*,\s*("[^"]+")\s*\)\s*\]\s*natE\b/exhaust_tac $1/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 { &fixdatatype($file); };
+ if ($@) { print STDERR "*** fixdatatype $file: ", $@, "\n"; }
+}