[m-rev.] diff: fix mtags processing of instance and typeclass bodys
Peter Ross
pro at missioncriticalit.com
Wed Nov 19 11:27:47 AEDT 2008
On Tue, Nov 18, 2008 at 05:33:34PM +1100, Peter Ross wrote:
> Hi,
>
>
> ===================================================================
>
>
> Fix a bug that inside typeclass or instance declarations, mtags
> was incorrectly detecting the body was detected on all lines
> which ended with a full stop followed by optional whitespace.
>
> This meant that comment lines such as
> % This is a comment.
> were terminating the processing of the body, rather
> than being ignored.
>
> Note the following will still cause mtags to finish
> processing the body prematurely.
>
> /*
> * This is a comment.
> */
>
> scripts/mtags.in:
> When processing instance and typeclass declarations
> skip blank lines and comments.
>
>
Actually this change wasn't quite right, I'm not sure why,
but the following fix does seem to fix everything.
===================================================================
mtags wasn't handling the following
:- typeclass case(T) where [
% comment
func f(T) = int
].
scripts/mtags.in:
Process the comment and blank lines as the first thing
in the loop handling the typeclass and instance bodies.
Index: scripts/mtags.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mtags.in,v
retrieving revision 1.2
diff -u -r1.2 mtags.in
--- scripts/mtags.in 18 Nov 2008 06:32:40 -0000 1.2
+++ scripts/mtags.in 19 Nov 2008 00:15:16 -0000
@@ -507,6 +507,13 @@
}
} elsif ($decl eq "typeclass") {
for(;;) {
+ # Skip blank lines and comments.
+ while ($body =~ /^[ \t]*$/ || $body =~ /^[ \t]*%.*$/) {
+ $_ = <SRCFILE> || last;
+ chop;
+ $body = $_;
+ }
+
# Assume each method declaration starts on a new line.
if ($body =~ /^.*\b(pred|func)[ \t]*/) {
$body =~ s/^.*\b(pred|func)[ \t]*//;
@@ -523,13 +530,6 @@
output_name();
}
- # Skip blank lines and comments.
- while ($body =~ /^[ \t]*$/ || $body =~ /^[ \t]*%.*$/) {
- $_ = <SRCFILE> || last;
- chop;
- $body = $_;
- }
-
last if $_ =~ /\.[ \t]*$/ || $_ =~ /\]/;
$_ = <SRCFILE> || last;
@@ -538,6 +538,13 @@
}
} else { # instance declaration
for(;;) {
+ # Skip blank lines and comments.
+ while ($body =~ /^[ \t]*$/ || $body =~ /^[ \t]*%.*$/) {
+ $_ = <SRCFILE> || last;
+ chop;
+ $body = $_;
+ }
+
# Assume each method declaration starts on a new line.
if ($body =~ /^.*\b(pred\(|func\()/) {
$body =~ s/.*\b(pred\(|func\()//;
@@ -554,13 +561,6 @@
output_name();
}
- # Skip blank lines and comments.
- while ($body =~ /^[ \t]*$/ || $body =~ /^[ \t]*%.*$/) {
- $_ = <SRCFILE> || last;
- chop;
- $body = $_;
- }
-
last if $_ =~ /\.[ \t]*$/ || $_ =~ /\]/;
$_ = <SRCFILE> || last;
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list