package Inline
::C
::ParseRecDescent
;
overrides
=> [qw(get_parser)],
eval { require Parse
::RecDescent
};
This innvocation of Inline requires the Parse::RecDescent module.
Parse
::RecDescent
->new(grammar
())
my $function = $item[1][0];
$return = 1, last if $thisparser->{data}{done}{$function}++;
push @{$thisparser->{data}{functions}}, $function;
$thisparser->{data}{function}{$function}{return_type} =
$thisparser->{data}{function}{$function}{arg_types} =
[map {ref $_ ? $_->[0] : '...'} @{$item[1][2]}];
$thisparser->{data}{function}{$function}{arg_names} =
[map {ref $_ ? $_->[1] : '...'} @{$item[1][2]}];
$return = 1, last unless $thisparser->{data}{AUTOWRAP};
my $function = $item[1][0];
$return = 1, last if $thisparser->{data}{done}{$function}++;
push @{$thisparser->{data}{functions}}, $function;
$thisparser->{data}{function}{$function}{return_type} =
$thisparser->{data}{function}{$function}{arg_types} =
[map {ref $_ ? $_->[0] : '...'} @{$item[1][2]}];
$thisparser->{data}{function}{$function}{arg_names} =
[map {ref $_ ? ($_->[1] || $dummy++) : '...'} @{$item[1][2]}];
| m{\s* /\* (?:[^*]+|\*(?!/))* \*/ ([ \t]*)? }x
rtype IDENTIFIER '(' <leftop: arg ',' arg>(s?) ')' '{'
rtype IDENTIFIER '(' <leftop: arg_decl ',' arg_decl>(s?) ')' ';'
rtype1: modifier(s?) TYPE star(s?)
$return = join ' ',@{$item[1]},$return
if @{$item[1]} and $item[1][0] ne 'extern';
$return .= join '',' ',@{$item[3]} if @{$item[3]};
return undef unless (defined $thisparser->{data}{typeconv}
{valid_rtypes}{$return});
rtype2: modifier(s) star(s?)
$return = join ' ',@{$item[1]};
$return .= join '',' ',@{$item[2]} if @{$item[2]};
return undef unless (defined $thisparser->{data}{typeconv}
{valid_rtypes}{$return});
arg: type IDENTIFIER {[@item[1,2]]}
type IDENTIFIER(s?) {[$item[1], $item[2][0] || '']}
type1: modifier(s?) TYPE star(s?)
$return = join ' ',@{$item[1]},$return if @{$item[1]};
$return .= join '',' ',@{$item[3]} if @{$item[3]};
return undef unless (defined $thisparser->{data}{typeconv}
type2: modifier(s) star(s?)
$return = join ' ',@{$item[1]};
$return .= join '',' ',@{$item[2]} if @{$item[2]};
return undef unless (defined $thisparser->{data}{typeconv}
'unsigned' | 'long' | 'extern' | 'const'
my $hack = sub { # Appease -w using Inline::Files
print Parse
::RecDescent
::IN
'';
print Parse
::RecDescent
::IN
'';
print Parse
::RecDescent
::TRACE_FILE
'';
print Parse
::RecDescent
::TRACE_FILE
'';
Inline::C::ParseRecDescent - The Classic Inline::C Parser
This module is Inline::C's original Parse::RecDescent based parser. It
was previously packaged as Inline::C::grammar.
Try Inline::C::ParseRegExp for an alternative.
Brian Ingerson <ingy@ttul.org>
Copyright (c) 2002. Brian Ingerson. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html