Extracting/Matching Comments

D

darkname

Hello everyone!!

Does anyone knows a module that parses and extracts comments of a given
source code file?? (such as C, C++, Java, PL/SQL, PERL, etc)!!?

There´s a module in CPAN that was designed to do this
(Regexp::Common::comment) but this module don´t preview all cases for
example in PERL!!

Because.. there are special cases that should be contemplated such as:

@array=/1 # 2 3 4/;
print"#This is not a comment";
$size=?#array;
@array=("#", 1,2,3);

How can i do this?

There is another module Text::Balanced that should work to.. with the
function extract_delimited, where the delimitators would be starting
with # and ending with \n! But i can´t make this work! :((

Another issue.. is this regex that should get the comments in Perl but
it doesn´t work also!!

~ m{
( \# .*? \n ) # extract a comment wich starts
with # to \n
| " (?: [^"\#]* | \#. )* " # skip over "..."
| ' (?: [^'\#]* | \#. )* ' # skip over '...'
| . [^\#"']* # skip over non-comments-or-quotes
}xgs;

Can someone tell me why??

Thank you all very much!

darkname...:p
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top