[m-dev.] diff: change mtags to handle module qualifiers

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Dec 24 08:37:02 AEDT 1999


> On 23-Dec-1999, Peter Ross <petdr at cs.mu.OZ.AU> wrote:
> > On 23-Dec-1999, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > > Now that we're not using Prolog, it might be nicer (i.e. more
> > > concise and not significantly less clear) for each module to
> > > only module-qualify the symbols from other modules.
> > > 
> > > Comments?
> > 
> > Sounds like a reasonable suggestion to me. I guess it is time to start
> > using `:- use_module'.
> > 
> > It would be nice though if mtags could be rewritten so that tags still
> > worked, before enforcing the change.

Estimated hours taken: 0.75

scripts/mtags:
	Handle module qualifiers properly: module-qualify all symbols, and then
	output tags for the fully module-qualified version and also for any
	partially qualified or unqualified versions of each symbol.

Workspace: /d-drive/home/hg/fjh/mercury
Index: scripts/mtags
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mtags,v
retrieving revision 1.19
diff -u -d -r1.19 mtags
--- scripts/mtags	1999/10/07 11:54:04	1.19
+++ scripts/mtags	1999/12/23 21:33:59
@@ -152,6 +152,22 @@
 	$match_line =~ s|\\|\\\\|g;   # replace `\' with `\\'
 	$match_line =~ s|/|\\/|g;     # replace `/' with `\/'
 
+	# output a tag for the fully-qualified name
+	if (substr($name, 0, length($module)) ne $module) {
+		$name = "${module}__$name";
+	}
+	do output_single_name();
+
+	# strip off the leading module qualifiers one by one,
+	# and output a tag for each partially qualified
+	# or unqualified name
+	while ($name =~ /__/) {
+		$name =~ s/[^_]*(_[^_]+)*__//;
+		do output_single_name();
+	}
+}
+
+sub output_single_name() {
 	if (!$emacs && !$keep_dups && $seen{$name}) {
 	    if ($warnings &&
 		$file ne $prev_file{$name} &&
@@ -254,6 +270,12 @@
 	open(out, ">> TAGS") ||
 		die "mtags: error opening pipe: $!\n";
     }
+    
+    $module = $file;
+    $module =~ s/.*\///;	# delete the directory name, if any
+    $module =~ s/\.m$//;	# delete the trailing `.m'
+    $module =~ s/\./__/;	# replace `.' module qualifiers with `__'
+
     while ($_ = <srcfile>)
     {
 	# skip lines which are not declarations

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list