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

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]});
}
}

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;
}