3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

CGrammar: Improve handling of "the result of the expression"

This commit is contained in:
Pragmatic Software 2014-07-13 06:36:55 +00:00
parent 46b5b95d54
commit 2a8d9152f5
3 changed files with 11 additions and 14 deletions

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 731,
BUILD_DATE => "2014-07-11",
BUILD_REVISION => 732,
BUILD_DATE => "2014-07-12",
};
1;

View File

@ -363,7 +363,7 @@ jump_statement:
}
| 'continue' ';'
{ $return = "Return to the top of the current loop.\n"; }
| 'return' <commit> expression[context => 'return statement'](?) ';'
| 'return' <commit> expression[context => "$arg{context}|return expression"](?) ';'
{
my $expression = join('', @{$item{'expression(?)'}});
@ -584,7 +584,11 @@ logical_OR_AND_expression:
rel_add_mul_shift_expression[context => 'logical_OR_AND_expression']>
{
if (defined $arg{context} and $arg{context} eq 'for conditional') { print STDERR "hmm2\n"; }
$return = join('', @{$item[1]});
my $expression = join('', @{$item[1]});
if($arg{context} =~ /expression$/ and $expression =~ / / and $expression !~ /^the result of/i) {
$return = 'the result of the expression ^L';
}
$return .= $expression;
}
log_OR_AND_bit_or_and_eq:
@ -630,20 +634,14 @@ rel_add_mul_shift_expression:
cast_expression ...';'
{ $return = $item{cast_expression}; }
| <leftop: cast_expression rel_mul_add_ex_op cast_expression>
{
my $expression = join('', @{$item[1]});
if($arg{context} =~ /expression/ and $expression =~ / / and $expression !~ /the result of the expression/i) {
$return = 'the result of the expression ';
}
$return .= $expression;
}
{ $return = join('', @{$item[1]}); }
closure:
',' | ';' | ')'
cast_expression:
'(' type_name ')' cast_expression[context => 'recast']
{ $return = "$item{cast_expression} type-casted as $item{type_name}"; }
{ $return = "$item{cast_expression} converted to $item{type_name}"; }
| unary_expression
{ $return = $item{unary_expression}; }
@ -1008,7 +1006,7 @@ postfix_productions:
$arg{primary_expression} =~ s/^Evaluate the expression/resulting from the expression/;
if($arg{context} =~ /statement/) {
if($arg{context} =~ /statement$/) {
$return = "Call the function $arg{primary_expression}";
} else {
$return = "the result of the function $arg{primary_expression}";

View File

@ -75,7 +75,6 @@ foreach my $arg (@ARGV) {
$output =~ s/the evaluate the/the/g;
$output =~ s/by evaluate the/by the/g;
$output =~ s/the a /the /g;
$output =~ s/result of the expression the result of the function/result of the function/g;
foreach my $quote (@quotes) {
next unless $quote;