Parsing a CPP file

Discussion in 'Perl Misc' started by JKG, May 15, 2006.

  1. JKG

    JKG Guest

    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.
     
    JKG, May 15, 2006
    #1
    1. Advertising

  2. "JKG" <> wrote in news::

    > 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 <>
    (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
     
    A. Sinan Unur, May 15, 2006
    #2
    1. Advertising

  3. JKG

    JKG Guest

    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 >
     
    JKG, May 16, 2006
    #3
  4. JKG

    JKG Guest

    Any takers....
     
    JKG, May 16, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DrUg13
    Replies:
    1
    Views:
    497
    DrUg13
    Feb 10, 2004
  2. Alex Vinokur
    Replies:
    7
    Views:
    429
    Greg Comeau
    Nov 15, 2004
  3. Vinu
    Replies:
    9
    Views:
    684
  4. www.hitechskill.com
    Replies:
    0
    Views:
    1,394
    www.hitechskill.com
    Apr 9, 2006
  5. Replies:
    0
    Views:
    550
Loading...

Share This Page