3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

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 # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 678, BUILD_REVISION => 679,
BUILD_DATE => "2014-06-25", BUILD_DATE => "2014-06-25",
}; };

View File

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