Parsing a CPP file

J

JKG

Hi friends,

Does any body knows about the following module.

use matchpairs ('('=>')', '{'=>'}'; '['=>']', '"'=>'"', "'"=>"'",
'<'=>'>');

I want to parse a balance parenthesis using a single regular
expression. For this I wanted to use this module.
 
A

A. Sinan Unur

JKG said:
Re: Parsing a CPP file

I see nothing in your post about either the C preprocessor or
C++ source files, so please explain what your subject is about.

Does any body knows about the following module.

use matchpairs ('('=>')', '{'=>'}'; '['=>']', '"'=>'"', "'"=>"'",
'<'=>'>');

I did not, but a Google search resulted in:

http://dev.perl.org/perl6/rfc/145.pod
I want to parse a balance parenthesis using a single regular
expression. For this I wanted to use this module.

Please formulate a concrete question following the posting guidelines
for this group.

See also:

http://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp/Common/balanced.pm

Sinan
--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
J

JKG

Hi,
Thanks for replying.
I am sorry as I was not able to formulate my question well, at the same
time I appreciate your effort for figuring out what I wanted. Thanks
again as your reply solved my query. I have lots of other things
regarding CPP file parsing. First I will clear what I wanted to do:
I have a large CPP file with lots of functions like:
MyClass::myFunction(int a, int b) const
{
....
}
I want to write a tool in Perl that automatically add a debug statement
at the start of the function:
int* MyClass::myFunction(int a, int b) const
{
cout << "Begin of myFunc()" << endl << flush;
....
}
My approach is as follows (assuming the syntax of the CPP file is
correct):
(1). Remove all the comments (both C and C++ style comments) from the
CPP file.
< Referring http://faq.perl.org/perlfaq6.html#How_do_I_use_a_regul >
(2). Now identify all the function implementations in the CPP file and
put the debug statements:
This is also not a very straight forward task as I can't relay on the
type or format for the function implementation. Here are few of them:
int globalFun() { ... }
int MyClass::classMember() { ... }
(3) Place the comment back to the proper position.
< Open for discussion >
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top