mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-02 15:34:05 +01:00
CGrammar: Fix typedefs
This commit is contained in:
parent
b38c6c91c1
commit
669e4e37c2
@ -13,7 +13,7 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 677,
|
||||
BUILD_REVISION => 678,
|
||||
BUILD_DATE => "2014-06-25",
|
||||
};
|
||||
|
||||
|
@ -589,21 +589,8 @@ declaration:
|
||||
declaration_specifiers init_declarator_list(?) ';'
|
||||
{
|
||||
my @init_list = defined $item{'init_declarator_list(?)'}->[0] ? @{$item{'init_declarator_list(?)'}->[0]} : ('');
|
||||
my $init_declaration_list;
|
||||
my $typedef = $item{declaration_specifiers} =~ s/^type definition of //;
|
||||
|
||||
if ($item{declaration_specifiers} =~ s/type definition of //) {
|
||||
if(@init_list > 1) {
|
||||
my $last = pop @init_list;
|
||||
$init_declaration_list = join(', ', @init_list) . ' and ' . $last;
|
||||
push @init_list, $last;
|
||||
} else {
|
||||
$init_declaration_list = $init_list[0];
|
||||
}
|
||||
|
||||
$return = "Let $init_declaration_list be another name for $item{declaration_specifiers}.\n";
|
||||
|
||||
push @typedefs, @init_list;
|
||||
} else {
|
||||
my $inits = 0;
|
||||
while(@init_list) {
|
||||
$inits++;
|
||||
@ -716,6 +703,11 @@ declaration:
|
||||
|
||||
$return .= ' be ';
|
||||
|
||||
if($typedef) {
|
||||
$return .= 'another name for ';
|
||||
push @typedefs, @identifiers;
|
||||
}
|
||||
|
||||
if($first_qualifier) {
|
||||
if(@identifiers == 1 and $first_qualifier !~ /^(a|an)\s+/) {
|
||||
$return .= $first_qualifier =~ m/^[aeiouy]/ ? 'an ' : 'a ';
|
||||
@ -765,7 +757,6 @@ declaration:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init_declarator_list:
|
||||
<leftop: init_declarator ',' init_declarator>
|
||||
|
Loading…
Reference in New Issue
Block a user