3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-03 01:48:38 +02:00

CGrammar: Improve enumeration translation

This commit is contained in:
Pragmatic Software 2014-06-09 10:18:26 +00:00
parent ffab2c6f3b
commit 9992119b11
2 changed files with 9 additions and 8 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 => 622, BUILD_REVISION => 623,
BUILD_DATE => "2014-06-09", BUILD_DATE => "2014-06-09",
}; };

View File

@ -1137,7 +1137,7 @@ typedef_name:
foreach (@defined_types) { foreach (@defined_types) {
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/^`[aeiouy]/ ? 'an ' : 'a ') . $item{identifier};
} }
} }
if (!$answer) { undef $answer; } if (!$answer) { undef $answer; }
@ -1218,21 +1218,22 @@ enum_specifier:
{ {
$return .= 'an enumeration'; $return .= 'an enumeration';
if (@{$item{'identifier(?)'}}){
$return .= ' of ' . join('',@{$item{'identifier(?)'}});
}
my @enumerator_list = @{$item{enumerator_list}}; my @enumerator_list = @{$item{enumerator_list}};
if(@enumerator_list == 1) { if(@enumerator_list == 1) {
$return .= " of $enumerator_list[0]"; $return .= " comprising $enumerator_list[0]";
} else { } else {
my $last = pop @enumerator_list; my $last = pop @enumerator_list;
$return .= ' of ' . join(', ', @enumerator_list) . " and $last"; $return .= ' comprising ' . join(', ', @enumerator_list) . " and $last";
} }
if (@{$item{'identifier(?)'}}){
$return .= ' identified as ' . join('',@{$item{'identifier(?)'}});
}
} }
| 'enum' identifier | 'enum' identifier
{ $return = ($item{identifer} =~ m/^[aieouy]/ ? 'an ' : 'a ') . "$item{identifier} enumeration"; } { $return = "an enumeration of type $item{identifier}"; }
enumerator_list: enumerator_list: