Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C::Scan help please

Status
Not open for further replies.

soren

Technical User
Jan 26, 2001
7
US
Help please -- I found the C::Scan module on CPAN, but I am having trouble getting it to do what I want, and the documentation is admittedly sparse. What I want to do is to use it to parse a C source file and return a list of the functions in the file. I have used the sample posted on perlmonks, with only slight modified for my purposes, but it seems to misbehave. My perl isn't good enough, yet, to follow what the Data::Flow module (on which the C::Scan is based) to find my error.

Here is my perl code:
#---snip----
use C::Scan;

$c = new C::Scan(filename => 'test.c',
filename_filter => 'test.c'
);

#
# Fetch and iterate through information about function declarations.
#
my $array_ref = $c->get('fdecls');
foreach my $func (@$array_ref) {
my ($type, $name, $args, $full_text, undef) = @$func;
foreach my $arg (@$args) {
my ($atype, $aname, $aargs, $full_text, $array_modifiers) = @$arg;
}
}

#
# Fetch and iterate through information about #define macros w/args.
#
my $hash_ref = $c->get('defines_args');
foreach my $macro_name (keys %$hash_ref) {
print "$macro_name \n";
my $array_ref = $macros_hash{$macro_name};
my ($arg_ref, $macro_text) = @$array_ref;
my @macro_args = @$arg_ref;
}

__END__

For the macro, it works correctly, but for the fdecls, it prints this:
'cppstdin' is not recognized as an internal or external command, operable program or batch file.

any help out there?

Thanks!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top