mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
CGrammar: Improve handling of "the result of the expression"
This commit is contained in:
parent
46b5b95d54
commit
2a8d9152f5
@ -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 => 731,
|
BUILD_REVISION => 732,
|
||||||
BUILD_DATE => "2014-07-11",
|
BUILD_DATE => "2014-07-12",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -363,7 +363,7 @@ jump_statement:
|
|||||||
}
|
}
|
||||||
| 'continue' ';'
|
| 'continue' ';'
|
||||||
{ $return = "Return to the top of the current loop.\n"; }
|
{ $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(?)'}});
|
my $expression = join('', @{$item{'expression(?)'}});
|
||||||
|
|
||||||
@ -584,7 +584,11 @@ logical_OR_AND_expression:
|
|||||||
rel_add_mul_shift_expression[context => '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"; }
|
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:
|
log_OR_AND_bit_or_and_eq:
|
||||||
@ -630,20 +634,14 @@ rel_add_mul_shift_expression:
|
|||||||
cast_expression ...';'
|
cast_expression ...';'
|
||||||
{ $return = $item{cast_expression}; }
|
{ $return = $item{cast_expression}; }
|
||||||
| <leftop: cast_expression rel_mul_add_ex_op cast_expression>
|
| <leftop: cast_expression rel_mul_add_ex_op cast_expression>
|
||||||
{
|
{ $return = join('', @{$item[1]}); }
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
closure:
|
closure:
|
||||||
',' | ';' | ')'
|
',' | ';' | ')'
|
||||||
|
|
||||||
cast_expression:
|
cast_expression:
|
||||||
'(' type_name ')' cast_expression[context => 'recast']
|
'(' 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
|
| unary_expression
|
||||||
{ $return = $item{unary_expression}; }
|
{ $return = $item{unary_expression}; }
|
||||||
|
|
||||||
@ -1008,7 +1006,7 @@ postfix_productions:
|
|||||||
|
|
||||||
$arg{primary_expression} =~ s/^Evaluate the expression/resulting from the expression/;
|
$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}";
|
$return = "Call the function $arg{primary_expression}";
|
||||||
} else {
|
} else {
|
||||||
$return = "the result of the function $arg{primary_expression}";
|
$return = "the result of the function $arg{primary_expression}";
|
||||||
|
@ -75,7 +75,6 @@ foreach my $arg (@ARGV) {
|
|||||||
$output =~ s/the evaluate the/the/g;
|
$output =~ s/the evaluate the/the/g;
|
||||||
$output =~ s/by evaluate the/by the/g;
|
$output =~ s/by evaluate the/by the/g;
|
||||||
$output =~ s/the a /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) {
|
foreach my $quote (@quotes) {
|
||||||
next unless $quote;
|
next unless $quote;
|
||||||
|
Loading…
Reference in New Issue
Block a user