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!
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!