ensure that dots in formulas are followed by non-idents;
authorwenzelm
Thu Oct 09 17:45:03 1997 +0200 (1997-10-09)
changeset 38249fdde15e3215
parent 3823 071c87125cea
child 3825 478461d77e88
ensure that dots in formulas are followed by non-idents;
lib/Tools/fixdots
lib/scripts/fixdots.pl
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lib/Tools/fixdots	Thu Oct 09 17:45:03 1997 +0200
     1.3 @@ -0,0 +1,39 @@
     1.4 +#!/bin/bash
     1.5 +#
     1.6 +# $Id$
     1.7 +#
     1.8 +# DESCRIPTION: ensure that dots in formulas are followed by non-idents
     1.9 +
    1.10 +
    1.11 +## diagnostics
    1.12 +
    1.13 +PRG=$(basename $0)
    1.14 +
    1.15 +function usage()
    1.16 +{
    1.17 +  echo
    1.18 +  echo "Usage: $PRG [FILES|DIRS...]"
    1.19 +  echo
    1.20 +  echo "  Recursively find .thy/.ML files, patching them to ensure that"
    1.21 +  echo "  dots in formulas are followed by non-idents."
    1.22 +  echo
    1.23 +  exit 1
    1.24 +}
    1.25 +
    1.26 +
    1.27 +## process command line
    1.28 +
    1.29 +[ $# -eq 0 -o "$1" = "-?" ] && usage
    1.30 +
    1.31 +SPECS="$@"; shift $#
    1.32 +
    1.33 +
    1.34 +## main
    1.35 +
    1.36 +PERL=$(type -path perl)
    1.37 +if [ -z $PERL ]; then
    1.38 +  echo "$PRG fatal error: no perl!?"
    1.39 +else
    1.40 +  find $SPECS \( -name \*.thy -o -name \*.ML \) -print | \
    1.41 +    xargs $PERL $ISABELLE_HOME/lib/scripts/fixdots.pl
    1.42 +fi
    1.43 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lib/scripts/fixdots.pl	Thu Oct 09 17:45:03 1997 +0200
     2.3 @@ -0,0 +1,42 @@
     2.4 +#
     2.5 +# $Id$
     2.6 +#
     2.7 +# fixdots.pl - ensure that dots in formulas are followed by non-idents
     2.8 +#
     2.9 +
    2.10 +foreach $file (@ARGV) {
    2.11 +
    2.12 +    if (open (FILE, $file)) {
    2.13 +	undef $/;
    2.14 +	$text = <FILE>;
    2.15 +	close FILE;
    2.16 +
    2.17 +	$result = "";
    2.18 +	$rest = $text;
    2.19 +
    2.20 +	while (1) {
    2.21 +	    $_ = $rest;
    2.22 +	    ($pre, $str, $rest) = m/^([^"]*)"((?:[^"\\]|\\.)*)"(.*)$/s;
    2.23 +	    if ($str) {
    2.24 +		$_ = $str;
    2.25 +		if (!m/^[a-zA-Z0-9_\/\.]*$/s && !m/\.ML$/s && !m/\.thy/) {     # Exclude filenames!
    2.26 +		    s/([a-zA-Z][a-zA-Z0-9_']*)\.([a-zA-Z])/$1\. $2/g;
    2.27 +	        }
    2.28 +                $result = $result . $pre . '"' . $_ . '"';
    2.29 +            } else {
    2.30 + 	        $result = $result . $_;
    2.31 +    	        last;
    2.32 +	    }
    2.33 +        }
    2.34 +
    2.35 +        if ($text ne $result) {
    2.36 +	    print STDERR "fixing $file\n";
    2.37 +	    open (FILE, "> $file") || die $!;
    2.38 +	    print FILE $result;
    2.39 +	    close FILE || die $!;
    2.40 +        }
    2.41 +
    2.42 +    } else {
    2.43 +        print STDERR "Can't open file $file: $!\n";
    2.44 +    }
    2.45 +}