5 # |
5 # |
6 # convert.pl - convert legacy tactic scripts to Isabelle/Isar tactic |
6 # convert.pl - convert legacy tactic scripts to Isabelle/Isar tactic |
7 # emulation using heuristics - leaves unrecognized patterns unchanged |
7 # emulation using heuristics - leaves unrecognized patterns unchanged |
8 # produces from each input file (on the command line) a new file with |
8 # produces from each input file (on the command line) a new file with |
9 # ".thy" appended and renames the original input file by appending "~0~" |
9 # ".thy" appended and renames the original input file by appending "~0~" |
10 |
|
11 |
10 |
12 sub thmlist { |
11 sub thmlist { |
13 my $s = shift; |
12 my $s = shift; |
14 $s =~ s/^\[(.*)\]$/$1/sg; |
13 $s =~ s/^\[(.*)\]$/$1/sg; |
15 $s =~ s/, +/ /g; |
14 $s =~ s/, +/ /g; |
234 $finalfile = "$currfile.thy"; |
233 $finalfile = "$currfile.thy"; |
235 $tmpfile = "$finalfile.~0~"; |
234 $tmpfile = "$finalfile.~0~"; |
236 open(ARGVOUT, '>'.$tmpfile); |
235 open(ARGVOUT, '>'.$tmpfile); |
237 select(ARGVOUT); |
236 select(ARGVOUT); |
238 } |
237 } |
239 |
|
240 nl: |
238 nl: |
241 if(!s/;(\s*?(\n?$|\(\*))/$1/s && !eof()) {# no end_of_ML_command marker |
239 if(!s/;(\s*?(\n?$|\(\*))/$1/s && !eof()) {# no end_of_ML_command marker |
242 $_ = $_ . <>; |
240 $_ = $_ . <>; |
243 goto nl; |
241 goto nl; |
244 } |
242 } |
245 s/\\(\s*\n\s*)\\/ $1 /g; # remove backslashes escaping newlines |
243 s/\\(\s*\n\s*)\\/ $1 /g; # remove backslashes escaping newlines |
246 nlc: |
244 nlc: |
247 m/^(\s*)(.*?)(\s*)$/s; |
245 m/^(\s*)(.*?)(\s*)$/s; |
248 $head=$1; $line=$2; $tail=$3; |
246 $head=$1; $line=$2; $tail=$3; |
249 $tail =~ s/\s+\n/\n/sg; # remove trailing whitespace at end of lines |
247 $tail =~ s/\s+\n/\n/sg; # remove trailing whitespace at end of lines |
|
248 $line =~ s/\\\\<(\^?)(\w+)>/\\<$1$2>/g; # convert \\<...> to \<...> and \\<^...> to \<^...> |
250 print $head; $_=$line.$tail; |
249 print $head; $_=$line.$tail; |
251 if ($line =~ m/^\(\*/) { # start comment |
250 if ($line =~ m/^\(\*/) { # start comment |
252 while (($i = index $_,"*)") == -1 && !eof()) { # no end comment |
251 while (($i = index $_,"*)") == -1 && !eof()) { # no end comment |
|
252 s/\\\\<(\^?)(\w+)>/\\<$1$2>/g; # convert \\<...> to \<...> and \\<^...> to \<^...> |
253 print; |
253 print; |
254 $_ = <>; |
254 $_ = <>; |
255 } |
255 } |
256 if ($i == -1) { print; last; } |
256 if ($i == -1) { print; last; } |
257 print substr $_,0,$i+2; |
257 print substr $_,0,$i+2; |