Please also note that I am passing a reference to an array of strings that contains the doc++ comment to this subroutine. Subsequently, I get the array of strings that is the doc++ comment into a single string which I then attempt to use pattern matching to extract the different components of the string, which I will store and then output in a nicely formatted way.

thanks heaps

David.

David Buddrige wrote:

To do this, I have written the following function:

# This subroutine takes as input a single array reference, and
# rearranges any doc++ commands that are split over multiple lines so
# that each doc++ command is on a line of its own, including the /** and
# */ delimiters which indicate the start and end of a doc++ comment.

sub format_docpp_comment
{
my $doc_comment_array;
my $comment_line;
my $single_comment_line;

$doc_comment_array = $_[0]; # give a friendly name to the array

foreach $comment_line ( @$doc_comment_array )
{
#chomp $comment_line;
my $temp_string;
$temp_string = $comment_line;
chomp $temp_string;
$single_comment_line .= $temp_string;
}

# At this point we have a single string that contains our entire
# doc++ comment. We can now use simple pattern matching to parse
# it.

$single_comment_line =~ m"(\/\*\*)(([\t\n ]*)(\@)(doc|invariant|return|precondition|postcondition)([\t\n\w\.\ ]+))+";
print "2: $2\n";
}



At this point, the $2 variable has within it, the very first doc++ style comment which is usually:

@doc some text.

I want to get at the rest of the repeated @somecommand doc++ commands.

Does anyone know how this is done?

I kind'of want to store what I have already matched in $2 to some scalar, and then delete that part of the string matched so far, so that I can repeat the pattern match for the next chunk. However I am not sure how to proceed.

thanks

David.




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to