3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 22:09:26 +01:00

CGrammar: Improve array translation and fix pointer pluralization

This commit is contained in:
Pragmatic Software 2014-06-17 23:12:02 +00:00
parent 77f1005e03
commit b2a0963abb
2 changed files with 10 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 => 648,
BUILD_REVISION => 649,
BUILD_DATE => "2014-06-17",
};

View File

@ -716,7 +716,7 @@ declaration:
if($first_qualifier) {
if(@identifiers == 1 and $first_qualifier !~ /^(a|an)\s+/) {
$return .= $first_qualifier =~ m/^[aeiouy]/ ? 'an ' : 'a ';
} else {
} elsif(@identifiers > 1) {
$first_qualifier =~ s/pointer/pointers/;
}
$return .= "$first_qualifier $item{declaration_specifiers} ";
@ -754,7 +754,7 @@ declaration:
if($first_qualifier) {
if(@identifiers == 1 and $first_qualifier !~ /^(a|an)\s+/) {
$return .= $first_qualifier =~ m/^[aeiouy]/ ? 'an ' : 'a ';
} else {
} elsif(@identifiers > 1) {
$first_qualifier =~ s/pointer/pointers/;
}
$return .= "$first_qualifier $item{declaration_specifiers}";
@ -1100,9 +1100,14 @@ array_declarator:
( '[' assignment_expression(?) ']'
{
if (@{$item{'assignment_expression(?)'}}) {
$return = 'size '. join('',@{$item{'assignment_expression(?)'}}) . ' ';
my $size = join('', @{$item{'assignment_expression(?)'}});
if($size =~ /^(unsigned|long)*\s*1$/) {
$return = "$size element ";
} else {
$return = "$size elements ";
}
} else {
$return = 'unspecified size ';
$return = 'unspecified length ';
}
}
)(s?)