mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +01:00
CGrammar: Do not use "an" for items beginning with 'y'; improve translation of array of array indices
This commit is contained in:
parent
029cc1ec7a
commit
de3493f1ca
@ -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 => 720,
|
BUILD_REVISION => 721,
|
||||||
BUILD_DATE => "2014-07-07",
|
BUILD_DATE => "2014-07-07",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -745,7 +745,7 @@ 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/^[aeiou]/ ? 'an ' : 'a ';
|
||||||
} elsif (@identifiers > 1 and not $typedef) {
|
} elsif (@identifiers > 1 and not $typedef) {
|
||||||
$first_qualifier =~ s/pointer/pointers/;
|
$first_qualifier =~ s/pointer/pointers/;
|
||||||
$first_qualifier =~ s/an array/arrays/;
|
$first_qualifier =~ s/an array/arrays/;
|
||||||
@ -754,7 +754,7 @@ declaration:
|
|||||||
$return .= " $item{declaration_specifiers}" if $item{declaration_specifiers};
|
$return .= " $item{declaration_specifiers}" if $item{declaration_specifiers};
|
||||||
} else {
|
} else {
|
||||||
if (@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
|
if (@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
|
||||||
$return .= $item{declaration_specifiers} =~ m/^[aeiouy]/ ? 'an ' : 'a ';
|
$return .= $item{declaration_specifiers} =~ m/^[aeiou]/ ? 'an ' : 'a ';
|
||||||
}
|
}
|
||||||
$return .= $item{declaration_specifiers};
|
$return .= $item{declaration_specifiers};
|
||||||
}
|
}
|
||||||
@ -784,7 +784,7 @@ 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/^[aeiou]/ ? 'an ' : 'a ';
|
||||||
} elsif (@identifiers > 1 and not $typedef) {
|
} elsif (@identifiers > 1 and not $typedef) {
|
||||||
$first_qualifier =~ s/pointer/pointers/;
|
$first_qualifier =~ s/pointer/pointers/;
|
||||||
$first_qualifier =~ s/an array/arrays/;
|
$first_qualifier =~ s/an array/arrays/;
|
||||||
@ -793,7 +793,7 @@ declaration:
|
|||||||
$return .= $item{declaration_specifiers};
|
$return .= $item{declaration_specifiers};
|
||||||
} else {
|
} else {
|
||||||
if (@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
|
if (@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
|
||||||
$return .= $item{declaration_specifiers} =~ m/^[aeiouy]/ ? 'an ' : 'a ';
|
$return .= $item{declaration_specifiers} =~ m/^[aeiou]/ ? 'an ' : 'a ';
|
||||||
}
|
}
|
||||||
$return .= $item{declaration_specifiers};
|
$return .= $item{declaration_specifiers};
|
||||||
}
|
}
|
||||||
@ -1019,15 +1019,9 @@ postfix_productions:
|
|||||||
}
|
}
|
||||||
1;
|
1;
|
||||||
}
|
}
|
||||||
| ('[' expression[context => 'array address'] ']'
|
| '[' expression[context => 'array address'] ']' postfix_productions[context => "$arg{context}|array address"](?)
|
||||||
{ $return = $item{expression}; }
|
|
||||||
)(s) postfix_productions[context => "$arg{context}|array address"](?)
|
|
||||||
{
|
{
|
||||||
my $expression = '';
|
my $expression = $item[2];
|
||||||
if (@{$item[-2]}) {
|
|
||||||
$expression = join(', and ', @{$item[-2]});
|
|
||||||
}
|
|
||||||
|
|
||||||
my $postfix = $item[-1]->[0];
|
my $postfix = $item[-1]->[0];
|
||||||
|
|
||||||
if (length $expression) {
|
if (length $expression) {
|
||||||
@ -1058,7 +1052,8 @@ postfix_productions:
|
|||||||
my $plural = $expression == 1 ? '' : 's';
|
my $plural = $expression == 1 ? '' : 's';
|
||||||
$return = "the location $expression element$plural backwards from where ^L$arg{primary_expression} points^L";
|
$return = "the location $expression element$plural backwards from where ^L$arg{primary_expression} points^L";
|
||||||
} else {
|
} else {
|
||||||
$return = "the element of ^L$arg{primary_expression} at location ^L$expression^L";
|
$return = "the element at location ^L$expression^L of";
|
||||||
|
$return .= " $arg{primary_expression}" if $arg{primary_expression};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1642,7 +1637,7 @@ typedef_name:
|
|||||||
foreach (@typedefs) {
|
foreach (@typedefs) {
|
||||||
if ($item{identifier} eq $_) {
|
if ($item{identifier} eq $_) {
|
||||||
$answer = 1;
|
$answer = 1;
|
||||||
$return = ($item{identifier} =~ m/^`[aeiouy]/ ? 'an ' : 'a ') . $item{identifier};
|
$return = ($item{identifier} =~ m/^`[aeiou]/ ? 'an ' : 'a ') . $item{identifier};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$answer) { undef $answer; }
|
if (!$answer) { undef $answer; }
|
||||||
@ -1661,7 +1656,7 @@ struct_or_union_specifier:
|
|||||||
| struct_or_union identifier
|
| struct_or_union identifier
|
||||||
{
|
{
|
||||||
$item{struct_or_union} =~ s/^(a|an)//;
|
$item{struct_or_union} =~ s/^(a|an)//;
|
||||||
$return = $item{identifier} =~ m/^`[aeiouy]/ ? 'an' : 'a';
|
$return = $item{identifier} =~ m/^`[aeiou]/ ? 'an' : 'a';
|
||||||
$return .= " $item{identifier} $item{struct_or_union}";
|
$return .= " $item{identifier} $item{struct_or_union}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user