Hello There.
You might look at Regexp::Common for help, it has an ability to match
balanced parentheses.
But I suspect that it will be easily confused by comments and strings inside
the C code. For example:
void f() {
/* { */
print "xyz { xyz \n";
}
So I can only recommend a do-it-yourself. Parse the file char by char, and a
simple state machine can solve your problem.
Shmuel.
>-----Original Message-----
>From: Meron Cohen [mailto:[EMAIL PROTECTED]
>Sent: Sunday, November 11, 2007 2:17 PM
>To: Perl in Israel
>Subject: [Israel.pm] Regex that matches a C-style function definition.
>
>Hello,
>
>I'm trying to parse ".c" file and extract a given function's definition.
>
>Example:
>
>void f ()
>{
> /* definition of f () */
>}
>
>I know that the name of the function is "f" and what I want is the
>definition of f (), inside the "{" and "}".
>Could you tell me if there is a CPAN module that already does it, or
>give me a Regex that does it.
>
>10x,
>Meron
>_______________________________________________
>Perl mailing list
>[email protected]
>http://perl.org.il/mailman/listinfo/perl
>
>
>--
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.5.503 / Virus Database: 269.15.29/1124 - Release Date:
>11/11/2007 10:12
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl