lib/scripts/expandshort.pl
author wenzelm
Tue, 13 Feb 2001 16:31:18 +0100
changeset 11109 ce1cefc6c14c
parent 10025 a281d157ccdf
permissions -rw-r--r--
tuned;
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!
5324
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
     8
# a special case is made to detect    be alpha.alpha digits   
10025
wenzelm
parents: 7491
diff changeset
     9
#
4417
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    10
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    11
sub expandshort {
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    12
    my ($file) = @_;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    13
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    14
    open (FILE, $file) || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    15
    undef $/; $text = <FILE>; $/ = "\n";         # slurp whole file
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    16
    close FILE || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    17
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    18
    $_ = $text;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    19
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    20
    s/\bsafe_tac *\(claset *\( *\) *\)/Safe_tac/sg;
4592
ff0c5c57fdfb Replaced \\1 by $1 as Perl itself asked me to...
paulson
parents: 4478
diff changeset
    21
    s/ *\(Safe_tac\) *([0-9]+)/ Safe_tac $1/sg;
4417
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    22
    s/ *\(Safe_tac\)/ Safe_tac/sg;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    23
    s/\bby\(/by (/sg;
4592
ff0c5c57fdfb Replaced \\1 by $1 as Perl itself asked me to...
paulson
parents: 4478
diff changeset
    24
    s/\bba\b *(\d+);/by (assume_tac $1);/sg;
5324
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
    25
    s/\bbr\b *([^;*!]*) (\d+);/by (rtac $1 $2);/sg;
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
    26
    s/\bbrs\b *([^;*!]*) (\d+);/by (resolve_tac $1 $2);/sg;
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
    27
    s/\bbd\b *([^;*!]*) (\d+);/by (dtac $1 $2);/sg;
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
    28
    s/\bbds\b *([^;*!]*) (\d+);/by (dresolve_tac $1 $2);/sg;
4592
ff0c5c57fdfb Replaced \\1 by $1 as Perl itself asked me to...
paulson
parents: 4478
diff changeset
    29
    s/\bbe\b *([^;.*!]*) (\d+);/by (etac $1 $2);/sg;
5324
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
    30
    s/\bbe\b *(\w+\.\w+) (\d+);/by (etac $1 $2);/sg;
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
    31
    s/\bbes\b *([^;*!]*) (\d+);/by (eresolve_tac $1 $2);/sg;
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
    32
    s/\bbw\b *([^;*!]*);/by (rewtac $1);/sg;
ec84178243ff Now allows "." in rule names, with special treatment for "be"
paulson
parents: 4592
diff changeset
    33
    s/\bbws\b *([^;*!]*);/by (rewrite_goals_tac $1);/sg;
4478
9c5a0eef74ff More restrictive patterns to prevent changing comments
paulson
parents: 4417
diff changeset
    34
    s/\bauto *\(\)/by Auto_tac/sg;
4592
ff0c5c57fdfb Replaced \\1 by $1 as Perl itself asked me to...
paulson
parents: 4478
diff changeset
    35
    s/dresolve_tac *\[(\w+)\] */dtac $1 /sg;
ff0c5c57fdfb Replaced \\1 by $1 as Perl itself asked me to...
paulson
parents: 4478
diff changeset
    36
    s/eresolve_tac *\[(\w+)\] */etac $1 /sg;
7491
95a4af0e10a7 added ftac, eatac, datac, fatac
oheimb
parents: 5324
diff changeset
    37
    s/forward_tac *\[(\w+)\] */ftac $1 /sg;
4592
ff0c5c57fdfb Replaced \\1 by $1 as Perl itself asked me to...
paulson
parents: 4478
diff changeset
    38
    s/resolve_tac *\[(\w+)\] */rtac $1 /sg;
ff0c5c57fdfb Replaced \\1 by $1 as Perl itself asked me to...
paulson
parents: 4478
diff changeset
    39
    s/rewrite_goals_tac *\[(\w+)\]( *)/rewtac $1$2/sg;
ff0c5c57fdfb Replaced \\1 by $1 as Perl itself asked me to...
paulson
parents: 4478
diff changeset
    40
    s/rtac *\((\w+)\s+RS\s+ssubst\)\s+/stac $1 /sg;
4417
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    41
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    42
    $result = $_;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    43
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    44
    if ($text ne $result) {
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    45
	print STDERR "expanding $file\n";
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    46
        if (! -f "$file~~") {
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    47
	    rename $file, "$file~~" || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    48
        }
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    49
	open (FILE, "> $file") || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    50
	print FILE $result;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    51
	close FILE || die $!;
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    52
    }
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    53
}
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    54
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    55
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    56
## main
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    57
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    58
foreach $file (@ARGV) {
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    59
  eval { &expandshort($file); };
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    60
  if ($@) { print STDERR "*** expandshort $file: ", $@, "\n"; }
44ff59be6031 adapted from Larry's version;
wenzelm
parents:
diff changeset
    61
}