CGrammar: Improve pluralization of arrays/pointers in declarations and improve translation of multiple identifiers in typedefs

This commit is contained in:
Pragmatic Software 2014-06-25 12:01:06 +00:00
parent 669e4e37c2
commit 682e6d2af3
2 changed files with 9 additions and 6 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 => 678,
BUILD_REVISION => 679,
BUILD_DATE => "2014-06-25",
};

View File

@ -668,8 +668,9 @@ declaration:
if(@identifiers == 1 and $first_qualifier !~ /^(a|an)\s+/) {
$return .= $first_qualifier =~ m/^[aeiouy]/ ? 'an ' : 'a ';
} elsif(@identifiers > 1) {
} elsif(@identifiers > 1 and not $typedef) {
$first_qualifier =~ s/pointer/pointers/;
$first_qualifier =~ s/an array/arrays/;
}
$return .= "$first_qualifier $item{declaration_specifiers} ";
} else {
@ -701,18 +702,20 @@ declaration:
}
}
$return .= ' be ';
if($typedef) {
$return .= 'another name for ';
$return .= ' each' if @identifiers > 1;
$return .= ' be another name for ';
push @typedefs, @identifiers;
} else {
$return .= ' be ';
}
if($first_qualifier) {
if(@identifiers == 1 and $first_qualifier !~ /^(a|an)\s+/) {
$return .= $first_qualifier =~ m/^[aeiouy]/ ? 'an ' : 'a ';
} elsif(@identifiers > 1) {
} elsif(@identifiers > 1 and not $typedef) {
$first_qualifier =~ s/pointer/pointers/;
$first_qualifier =~ s/an array/arrays/;
}
$return .= "$first_qualifier ";
$return .= "$remaining_args " if $remaining_args;