CGrammar: Improvements to translation of comma operator

This commit is contained in:
Pragmatic Software 2014-06-28 10:18:28 +00:00
parent 99aea7fe63
commit 5730d56d54
3 changed files with 10 additions and 7 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 => 682,
BUILD_DATE => "2014-06-27",
BUILD_REVISION => 683,
BUILD_DATE => "2014-06-28",
};
1;

View File

@ -365,10 +365,11 @@ expression:
{
if($arg{context} eq 'for increment statement') {
$return = join(', then ', @{$item[-1]});
} elsif( $arg{context} =~ /conditional/) {
$return = join(' and the result discarded and ', @{$item[-1]});
} else {
my $that = $arg{context} =~ /conditional/ ? ' that' : '';
$return .= "Evaluate$that " if @{$item[-1]} > 1;
$return .= join(" and then discard the result and then evaluate$that ^L", @{$item[-1]});
$return .= "Evaluate " if @{$item[-1]} > 1;
$return .= join(" and discard the result and then evaluate ^L", @{$item[-1]});
}
}
@ -530,7 +531,7 @@ 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]});
$return = join ('', @{$item[1]});
}
log_OR_AND_bit_or_and_eq:

View File

@ -93,12 +93,14 @@ sub istrue {
my ($result, $and) = ('', '');
foreach my $part (@parts) {
$result .= $and;
if($part !~ /(discard the result|greater|less|equal|false$)/) {
if($part !~ /(discard the result|result discarded|greater|less|equal|false$)/) {
$result .= "$part is nonzero";
} else {
$result .= $part;
}
$and = ' and ';
}
$result =~ s/is nonzero and the result discarded/is evaluated and the result discarded/g;
$result =~ s/is ((?:(?!evaluated).)+) and the result discarded/is evaluated to be $1 and the result discarded/g;
return $result;
}