mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-24 11:42:35 +01:00
CGrammar: Improvements to translation of comma operator
This commit is contained in:
parent
99aea7fe63
commit
5730d56d54
@ -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 => 682,
|
BUILD_REVISION => 683,
|
||||||
BUILD_DATE => "2014-06-27",
|
BUILD_DATE => "2014-06-28",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -365,10 +365,11 @@ expression:
|
|||||||
{
|
{
|
||||||
if($arg{context} eq 'for increment statement') {
|
if($arg{context} eq 'for increment statement') {
|
||||||
$return = join(', then ', @{$item[-1]});
|
$return = join(', then ', @{$item[-1]});
|
||||||
|
} elsif( $arg{context} =~ /conditional/) {
|
||||||
|
$return = join(' and the result discarded and ', @{$item[-1]});
|
||||||
} else {
|
} else {
|
||||||
my $that = $arg{context} =~ /conditional/ ? ' that' : '';
|
$return .= "Evaluate " if @{$item[-1]} > 1;
|
||||||
$return .= "Evaluate$that " if @{$item[-1]} > 1;
|
$return .= join(" and discard the result and then evaluate ^L", @{$item[-1]});
|
||||||
$return .= join(" and then discard the result and then evaluate$that ^L", @{$item[-1]});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,12 +93,14 @@ sub istrue {
|
|||||||
my ($result, $and) = ('', '');
|
my ($result, $and) = ('', '');
|
||||||
foreach my $part (@parts) {
|
foreach my $part (@parts) {
|
||||||
$result .= $and;
|
$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";
|
$result .= "$part is nonzero";
|
||||||
} else {
|
} else {
|
||||||
$result .= $part;
|
$result .= $part;
|
||||||
}
|
}
|
||||||
$and = ' and ';
|
$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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user