3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-19 10:29:30 +01:00

CGrammar: Fix structure member access; add lower-case markers

This commit is contained in:
Pragmatic Software 2014-06-24 08:44:28 +00:00
parent 95949153e0
commit a8320f52f9
3 changed files with 24 additions and 15 deletions

View File

@ -13,8 +13,8 @@ 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 => 674, BUILD_REVISION => 675,
BUILD_DATE => "2014-06-23", BUILD_DATE => "2014-06-24",
}; };
1; 1;

View File

@ -406,8 +406,8 @@ if(not $output) {
# beautification # beautification
$output =~ s/the value the expression/the value of the expression/g; $output =~ s/the value the expression/the value of the expression/g;
$output =~ s/the value the member/the value of the member/g;
$output =~ s/the value the/the/g; $output =~ s/the value the/the/g;
$output =~ s/(is true is)+/is/g;
print "$output\n"; print "$output\n";

View File

@ -906,16 +906,16 @@ postfix_productions:
$expression .= 'th'; $expression .= 'th';
} }
if($arg{context} eq 'function call') { if($arg{context} eq 'function call') {
$return = "the $expression element of"; $return = "the $expression element of^L";
} else { } else {
$return = "the $expression element of $arg{primary_expression}"; $return = "the $expression element of ^L$arg{primary_expression}^L";
} }
} elsif($expression =~ /^-\s*\d+$/) { } elsif($expression =~ /^-\s*\d+$/) {
$expression *= -1; $expression *= -1;
my $plural = $expression == 1 ? '' : 's'; my $plural = $expression == 1 ? '' : 's';
$return = "the location $expression element$plural backwards from where $arg{primary_expression} points"; $return = "the location $expression element$plural backwards from where ^L$arg{primary_expression} points^L";
} else { } else {
$return = "the element of $arg{primary_expression} at location $expression"; $return = "the element of ^L$arg{primary_expression} at location ^L$expression^L";
} }
} }
@ -923,26 +923,31 @@ postfix_productions:
$return = "$postfix $return"; $return = "$postfix $return";
} }
} }
| ('.' identifier)(s) postfix_productions[context => 'struct access'](?) | '.' identifier postfix_productions[context => 'struct access'](?)
{ {
my $identifier = join('',@{$item[-2]}); my $identifier = $item[-2];
my $postfix = $item[-1]->[0]; my $postfix = $item[-1]->[0];
if ($identifier) { if ($identifier) {
if($arg{context} eq 'array_address') { if($arg{context} eq 'array_address') {
$return = "member $identifier of"; $return = "the member $identifier of^L";
} else { } else {
$return = "the member $identifier of $arg{primary_expression}"; $return = "the member $identifier of^L";
$return .= " $arg{primary_expression}" if $arg{primary_expression};
} }
} }
if($postfix) { if($postfix) {
$return = "$postfix->[0] $return $postfix->[1]"; if(ref $postfix eq 'ARRAY') {
$return = "$postfix->[0] $return $postfix->[1]";
} else {
$return = "$postfix $return";
}
} }
} }
| ('->' identifier)(s) postfix_productions[context => 'struct access'](?) | '->' identifier postfix_productions[context => 'struct access'](?)
{ {
my $identifier = join('',@{$item[-2]}); my $identifier = $item[-2];
my $postfix = $item[-1]->[0]; my $postfix = $item[-1]->[0];
if ($identifier) { if ($identifier) {
@ -950,7 +955,11 @@ postfix_productions:
} }
if($postfix) { if($postfix) {
$return = "$postfix->[0] $return $postfix->[1]"; if(ref $postfix eq 'ARRAY') {
$return = "$postfix->[0] $return $postfix->[1]";
} else {
$return = "$postfix $return";
}
} }
} }
| ('++')(s) | ('++')(s)