lib/scripts/expandshort.pl
author paulson
Wed, 24 Dec 1997 10:42:27 +0100
changeset 4478 9c5a0eef74ff
parent 4417 44ff59be6031
child 4592 ff0c5c57fdfb
permissions -rw-r--r--
More restrictive patterns to prevent changing comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4417
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
     1
#
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
     2
# $Id$
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
     3
#
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
     4
# expandshort.pl - expand shorthand goal commands
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
     5
#
4478
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
     6
# in "be ... i;" -> "by (etac ... i);" the "..." phrase is not allowed to
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
     7
#   contain punctuation.  Otherwise, comments can be affected!
4417
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
     8
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
     9
sub expandshort {
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    10
    my ($file) = @_;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    11
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    12
    open (FILE, $file) || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    13
    undef $/; $text = <FILE>; $/ = "\n";         # slurp whole file
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    14
    close FILE || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    15
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    16
    $_ = $text;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    17
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    18
    s/\bsafe_tac *\(claset *\( *\) *\)/Safe_tac/sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    19
    s/ *\(Safe_tac\) *([0-9]+)/ Safe_tac \1/sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    20
    s/ *\(Safe_tac\)/ Safe_tac/sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    21
    s/\bby\(/by (/sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    22
    s/\bba\b *(\d+);/by (assume_tac \1);/sg;
4478
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    23
    s/\bbr\b *([^;.*!]*) (\d+);/by (rtac \1 \2);/sg;
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    24
    s/\bbrs\b *([^;.*!]*) (\d+);/by (resolve_tac \1 \2);/sg;
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    25
    s/\bbd\b *([^;.*!]*) (\d+);/by (dtac \1 \2);/sg;
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    26
    s/\bbds\b *([^;.*!]*) (\d+);/by (dresolve_tac \1 \2);/sg;
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    27
    s/\bbe\b *([^;.*!]*) (\d+);/by (etac \1 \2);/sg;
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    28
    s/\bbes\b *([^;.*!]*) (\d+);/by (eresolve_tac \1 \2);/sg;
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    29
    s/\bbw\b *([^;.*!]*);/by (rewtac \1);/sg;
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    30
    s/\bbws\b *([^;.*!]*);/by (rewrite_goals_tac \1);/sg;
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    31
    s/\bauto *\(\)/by Auto_tac/sg;
4417
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    32
    s/dresolve_tac *\[(\w+)\] */dtac \1 /sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    33
    s/eresolve_tac *\[(\w+)\] */etac \1 /sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    34
    s/resolve_tac *\[(\w+)\] */rtac \1 /sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    35
    s/rewrite_goals_tac *\[(\w+)\]( *)/rewtac \1\2/sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    36
    s/rtac *\((\w+)\s+RS\s+ssubst\)\s+/stac \1 /sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    37
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    38
    $result = $_;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    39
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    40
    if ($text ne $result) {
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    41
	print STDERR "expanding $file\n";
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    42
        if (! -f "$file~~") {
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    43
	    rename $file, "$file~~" || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    44
        }
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    45
	open (FILE, "> $file") || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    46
	print FILE $result;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    47
	close FILE || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    48
    }
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    49
}
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    50
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    51
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    52
## main
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    53
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    54
foreach $file (@ARGV) {
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    55
  eval { &expandshort($file); };
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    56
  if ($@) { print STDERR "*** expandshort $file: ", $@, "\n"; }
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    57
}