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