mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +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
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 682,
|
||||
BUILD_DATE => "2014-06-27",
|
||||
BUILD_REVISION => 683,
|
||||
BUILD_DATE => "2014-06-28",
|
||||
};
|
||||
|
||||
1;
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user