author | kleing |
Wed, 05 Dec 2007 04:29:27 +0100 | |
changeset 25530 | a09ab5a79d42 |
parent 10025 | a281d157ccdf |
permissions | -rw-r--r-- |
4417 | 1 |
# |
2 |
# $Id$ |
|
3 |
# |
|
4 |
# expandshort.pl - expand shorthand goal commands |
|
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 | 9 |
# |
4417 | 10 |
|
11 |
sub expandshort { |
|
12 |
my ($file) = @_; |
|
13 |
||
14 |
open (FILE, $file) || die $!; |
|
15 |
undef $/; $text = <FILE>; $/ = "\n"; # slurp whole file |
|
16 |
close FILE || die $!; |
|
17 |
||
18 |
$_ = $text; |
|
19 |
||
20 |
s/\bsafe_tac *\(claset *\( *\) *\)/Safe_tac/sg; |
|
4592 | 21 |
s/ *\(Safe_tac\) *([0-9]+)/ Safe_tac $1/sg; |
4417 | 22 |
s/ *\(Safe_tac\)/ Safe_tac/sg; |
23 |
s/\bby\(/by (/sg; |
|
4592 | 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 | 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 | 35 |
s/dresolve_tac *\[(\w+)\] */dtac $1 /sg; |
36 |
s/eresolve_tac *\[(\w+)\] */etac $1 /sg; |
|
7491 | 37 |
s/forward_tac *\[(\w+)\] */ftac $1 /sg; |
4592 | 38 |
s/resolve_tac *\[(\w+)\] */rtac $1 /sg; |
39 |
s/rewrite_goals_tac *\[(\w+)\]( *)/rewtac $1$2/sg; |
|
40 |
s/rtac *\((\w+)\s+RS\s+ssubst\)\s+/stac $1 /sg; |
|
4417 | 41 |
|
42 |
$result = $_; |
|
43 |
||
44 |
if ($text ne $result) { |
|
45 |
print STDERR "expanding $file\n"; |
|
46 |
if (! -f "$file~~") { |
|
47 |
rename $file, "$file~~" || die $!; |
|
48 |
} |
|
49 |
open (FILE, "> $file") || die $!; |
|
50 |
print FILE $result; |
|
51 |
close FILE || die $!; |
|
52 |
} |
|
53 |
} |
|
54 |
||
55 |
||
56 |
## main |
|
57 |
||
58 |
foreach $file (@ARGV) { |
|
59 |
eval { &expandshort($file); }; |
|
60 |
if ($@) { print STDERR "*** expandshort $file: ", $@, "\n"; } |
|
61 |
} |