mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 20:42:38 +01:00
CGrammar: Fix arrays of function pointers and function pointers returning pointers
This commit is contained in:
parent
476db3d6a9
commit
3f545cefdc
@ -13,7 +13,7 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 657,
|
BUILD_REVISION => 658,
|
||||||
BUILD_DATE => "2014-06-20",
|
BUILD_DATE => "2014-06-20",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -145,7 +145,6 @@ external_declaration:
|
|||||||
function_definition:
|
function_definition:
|
||||||
declaration_specifiers(?) declarator[context => 'function definition'] compound_statement[context => 'function definition'](?)
|
declaration_specifiers(?) declarator[context => 'function definition'] compound_statement[context => 'function definition'](?)
|
||||||
{
|
{
|
||||||
print STDERR "wtf9\n", ::Dumper \%item;
|
|
||||||
my $declaration_specifiers = join('', @{$item{'declaration_specifiers(?)'}});
|
my $declaration_specifiers = join('', @{$item{'declaration_specifiers(?)'}});
|
||||||
my $name = $item{declarator}->[0];
|
my $name = $item{declarator}->[0];
|
||||||
my $parameter_list = $item{declarator}->[1];
|
my $parameter_list = $item{declarator}->[1];
|
||||||
@ -568,7 +567,6 @@ declaration_list:
|
|||||||
declaration:
|
declaration:
|
||||||
declaration_specifiers init_declarator_list(?) ';'
|
declaration_specifiers init_declarator_list(?) ';'
|
||||||
{
|
{
|
||||||
print STDERR "wtf2\n", ::Dumper \%item;
|
|
||||||
my @init_list = defined $item{'init_declarator_list(?)'}->[0] ? @{$item{'init_declarator_list(?)'}->[0]} : ('');
|
my @init_list = defined $item{'init_declarator_list(?)'}->[0] ? @{$item{'init_declarator_list(?)'}->[0]} : ('');
|
||||||
my $init_declaration_list;
|
my $init_declaration_list;
|
||||||
|
|
||||||
@ -591,7 +589,6 @@ declaration:
|
|||||||
$return .= "Let " unless $arg{context} eq 'struct member';
|
$return .= "Let " unless $arg{context} eq 'struct member';
|
||||||
|
|
||||||
my @args = ::flatten shift @init_list;
|
my @args = ::flatten shift @init_list;
|
||||||
print STDERR "wtf7\n", ::Dumper \@args;
|
|
||||||
|
|
||||||
my ($first_qualifier, $first_initializer);
|
my ($first_qualifier, $first_initializer);
|
||||||
my $first_identifier = shift @args;
|
my $first_identifier = shift @args;
|
||||||
@ -616,6 +613,8 @@ declaration:
|
|||||||
$first_initializer = '';
|
$first_initializer = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $remaining_args = join(' ', @args);
|
||||||
|
|
||||||
my @initializers;
|
my @initializers;
|
||||||
if($first_initializer) {
|
if($first_initializer) {
|
||||||
push @initializers, [ $first_identifier, $first_initializer ];
|
push @initializers, [ $first_identifier, $first_initializer ];
|
||||||
@ -702,12 +701,15 @@ declaration:
|
|||||||
} elsif(@identifiers > 1) {
|
} elsif(@identifiers > 1) {
|
||||||
$first_qualifier =~ s/pointer/pointers/;
|
$first_qualifier =~ s/pointer/pointers/;
|
||||||
}
|
}
|
||||||
$return .= "$first_qualifier $item{declaration_specifiers}";
|
$return .= "$first_qualifier ";
|
||||||
|
$return .= "$remaining_args " if $remaining_args;
|
||||||
|
$return .= $item{declaration_specifiers};
|
||||||
} else {
|
} else {
|
||||||
if(@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
|
if(@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
|
||||||
$return .= $item{declaration_specifiers} =~ m/^[aeiouy]/ ? 'an ' : 'a ';
|
$return .= $item{declaration_specifiers} =~ m/^[aeiouy]/ ? 'an ' : 'a ';
|
||||||
}
|
}
|
||||||
$return .= "$item{declaration_specifiers}";
|
$return .= "$remaining_args " if $remaining_args;
|
||||||
|
$return .= $item{declaration_specifiers};
|
||||||
}
|
}
|
||||||
|
|
||||||
if(@initializers) {
|
if(@initializers) {
|
||||||
@ -923,7 +925,6 @@ postfix_productions:
|
|||||||
}
|
}
|
||||||
| ('++')(s)
|
| ('++')(s)
|
||||||
{
|
{
|
||||||
print STDERR "wtf4\n", ::Dumper \%item;
|
|
||||||
my $increment = join('',@{$item[-1]});
|
my $increment = join('',@{$item[-1]});
|
||||||
if ($increment) {
|
if ($increment) {
|
||||||
if ($arg{context} eq 'statement') {
|
if ($arg{context} eq 'statement') {
|
||||||
|
Loading…
Reference in New Issue
Block a user