3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

CGrammar: Support flexible array struct members; fix up minor whitespace issue

This commit is contained in:
Pragmatic Software 2014-07-05 05:11:07 +00:00
parent 5b10d9769e
commit 520d1a2c9c
2 changed files with 13 additions and 5 deletions

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 708,
BUILD_REVISION => 709,
BUILD_DATE => "2014-07-04",
};

View File

@ -750,7 +750,7 @@ declaration:
$first_qualifier =~ s/an array/arrays/;
}
$return .= "$first_qualifier";
$return .= $item{declaration_specifiers} if $item{declaration_specifiers};
$return .= " $item{declaration_specifiers}" if $item{declaration_specifiers};
} else {
if (@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
$return .= $item{declaration_specifiers} =~ m/^[aeiouy]/ ? 'an ' : 'a ';
@ -837,7 +837,7 @@ init_declarator_list:
<leftop: init_declarator ',' init_declarator>
init_declarator:
declarator[context => 'init_declarator']
declarator[context => "$arg{context}|init_declarator"]
{
$return = $item{declarator};
}
@ -1304,7 +1304,11 @@ array_declarator:
$size = "$size elements";
}
} else {
$size = 'unspecified length';
if ($arg{context} =~ /struct member/) {
$size = 'flexible length';
} else {
$size = 'unspecified length';
}
}
my $qualifiers = join('', @{$item{'array_qualifiers(?)'}});
@ -1395,7 +1399,11 @@ parameter_declaration:
abstract_declarator:
pointer(?) direct_abstract_declarator(s)
{ $return = join(' ',@{$item{'pointer(?)'}}) . ' ' . join(' ', @{$item{'direct_abstract_declarator(s)'}}); }
{
my $pointer = join(' ', @{$item{'pointer(?)'}});
$return = "$pointer " if $pointer;
$return .= join(' ', @{$item{'direct_abstract_declarator(s)'}});
}
| pointer
direct_abstract_declarator: