aboutsummaryrefslogtreecommitdiffhomepage
path: root/isar
diff options
context:
space:
mode:
authorGravatar David Aspinall <da@inf.ed.ac.uk>2002-06-08 02:16:17 +0000
committerGravatar David Aspinall <da@inf.ed.ac.uk>2002-06-08 02:16:17 +0000
commitec85d5e4ccc623d7ce30b1bebdaee1b07ac5ca42 (patch)
tree7374e962b79618dbfaf86e7dab75532ac9d5b924 /isar
parent16334b1ccea7374256d32512c3ad587b871571f8 (diff)
Program [broken]
Diffstat (limited to 'isar')
-rw-r--r--isar/isartags86
1 files changed, 86 insertions, 0 deletions
diff --git a/isar/isartags b/isar/isartags
new file mode 100644
index 00000000..0d65f8e6
--- /dev/null
+++ b/isar/isartags
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+#
+# Or perhaps: /usr/local/bin/perl
+#
+# FIXME: this code is just borrowed from legotags program,
+# it isn't yet working! Please send us fixes.
+#
+# $Id$
+#
+undef $/;
+
+if($#ARGV<$[) {die "No Files\n";}
+open(tagfile,">TAGS") || die "Couldn't open TAGS: $!\n";
+
+while(<>)
+{
+ print "Tagging $ARGV\n";
+ $a=$_;
+ $cp=1;
+ $lp=1;
+ $tagstring="";
+
+ while(1)
+ {
+
+# ---- Get the next statement starting on a newline ----
+
+ if($a=~/^[ \t\n]*\(\*/)
+ { while($a=~/^\s*\(\*/)
+ { $d=1; $a=$'; $cp+=length $&; $lp+=(($wombat=$&)=~tr/\n/\n/);
+ while($d>0 && $a=~/\(\*|\*\)/)
+ { $a=$'; $cp+=2+length $`; $lp+=(($wombat=$`)=~tr/\n/\n/);
+ if($& eq "(*") {$d++} else {$d--};
+ }
+ if($d!=0) {die "Unbalanced Comment?";}
+ }
+ }
+
+ if($cp>1 && $a=~/.*\n/) {$a=$'; $cp+=length $&; $lp++;}
+ while($a=~/^\n/) {$cp++;$lp++;$a=$'}
+
+ if($a=~/^[^;]*;/)
+ { $stmt=$&;
+ $newa=$';
+ $newcp=$cp+length $&;
+ $newlp=$lp+(($wombat=$&)=~tr/\n/\n/); }
+ else { last;}
+
+# ---- The above embarrasses itself if there are semicolons inside comments or
+# ---- inside commands. Could do better.
+
+# print "----- (",$lp,",",$cp,")\n", $stmt, "\n";
+
+ if($stmt=~/^([ \t]*\$?theory\s*([\w\']+))\s*:/)
+ { $tagstring.=$1."\177".$2."\001".$lp.",".$cp."\n"; }
+
+ elsif($stmt=~/^([ \t]*\$?\[\s*[\w\']+)/)
+ { do adddecs($stmt,$1) }
+
+ elsif($stmt=~/^([ \t]*Inductive\s*\[\s*[\w\']+)/)
+ { do adddecs($stmt,$1) }
+
+# ---- Maybe do something smart with discharge as well?
+
+ $cp=$newcp; $lp=$newlp; $a=$newa;
+ }
+ print tagfile "\f\n".$ARGV.",".(length $tagstring)."\n".$tagstring;
+}
+close tagfile;
+
+
+sub adddecs {
+ $wk=$_[0];
+ $tag=$_[1];
+ while($wk=~/\[\s*([\w\']+)/)
+ { $tagstring.=$tag."\177".$1."\001".$lp.",".$cp."\n"; $wk=$';
+ while($wk=~/^\s*,\s*([\w\']+)/)
+ { $tagstring.=$tag."\177".$1."\001".$lp.",".$cp."\n"; $wk=$'; }
+ $d=1;
+ while($d>0 && $wk=~/\[|\]/)
+ { $wk=$'; if($& eq "[") {$d++} else {$d--};
+ }
+ }
+ 0;
+}
+