ensure that dots in formulas are followed by non-idents;
authorwenzelm
Thu, 09 Oct 1997 17:45:03 +0200
changeset 3824 9fdde15e3215
parent 3823 071c87125cea
child 3825 478461d77e88
ensure that dots in formulas are followed by non-idents;
lib/Tools/fixdots
lib/scripts/fixdots.pl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/Tools/fixdots	Thu Oct 09 17:45:03 1997 +0200
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# $Id$
+#
+# DESCRIPTION: ensure that dots in formulas are followed by non-idents
+
+
+## diagnostics
+
+PRG=$(basename $0)
+
+function usage()
+{
+  echo
+  echo "Usage: $PRG [FILES|DIRS...]"
+  echo
+  echo "  Recursively find .thy/.ML files, patching them to ensure that"
+  echo "  dots in formulas are followed by non-idents."
+  echo
+  exit 1
+}
+
+
+## process command line
+
+[ $# -eq 0 -o "$1" = "-?" ] && usage
+
+SPECS="$@"; shift $#
+
+
+## main
+
+PERL=$(type -path perl)
+if [ -z $PERL ]; then
+  echo "$PRG fatal error: no perl!?"
+else
+  find $SPECS \( -name \*.thy -o -name \*.ML \) -print | \
+    xargs $PERL $ISABELLE_HOME/lib/scripts/fixdots.pl
+fi
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/scripts/fixdots.pl	Thu Oct 09 17:45:03 1997 +0200
@@ -0,0 +1,42 @@
+#
+# $Id$
+#
+# fixdots.pl - ensure that dots in formulas are followed by non-idents
+#
+
+foreach $file (@ARGV) {
+
+    if (open (FILE, $file)) {
+	undef $/;
+	$text = <FILE>;
+	close FILE;
+
+	$result = "";
+	$rest = $text;
+
+	while (1) {
+	    $_ = $rest;
+	    ($pre, $str, $rest) = m/^([^"]*)"((?:[^"\\]|\\.)*)"(.*)$/s;
+	    if ($str) {
+		$_ = $str;
+		if (!m/^[a-zA-Z0-9_\/\.]*$/s && !m/\.ML$/s && !m/\.thy/) {     # Exclude filenames!
+		    s/([a-zA-Z][a-zA-Z0-9_']*)\.([a-zA-Z])/$1\. $2/g;
+	        }
+                $result = $result . $pre . '"' . $_ . '"';
+            } else {
+ 	        $result = $result . $_;
+    	        last;
+	    }
+        }
+
+        if ($text ne $result) {
+	    print STDERR "fixing $file\n";
+	    open (FILE, "> $file") || die $!;
+	    print FILE $result;
+	    close FILE || die $!;
+        }
+
+    } else {
+        print STDERR "Can't open file $file: $!\n";
+    }
+}