mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-23 02:24:25 +01:00
CGrammar: Improve conditional operator translation
This commit is contained in:
parent
8f5e4c9e88
commit
7590644422
@ -13,7 +13,7 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 653,
|
||||
BUILD_REVISION => 654,
|
||||
BUILD_DATE => "2014-06-17",
|
||||
};
|
||||
|
||||
|
@ -421,7 +421,10 @@ conditional_expression:
|
||||
logical_OR_AND_expression[context => $arg{context}] conditional_ternary_expression
|
||||
{
|
||||
if($item{conditional_ternary_expression}) {
|
||||
$return = "depending on if $item{logical_OR_AND_expression} is true then $item{conditional_ternary_expression}";
|
||||
my $op1 = $item{conditional_ternary_expression}->[0];
|
||||
my $op2 = $item{conditional_ternary_expression}->[1];
|
||||
my $istrue = $item{logical_OR_AND_expression} =~ /(greater|less|equal)/ ? '' : ' is true';
|
||||
$return = "$op1 if $item{logical_OR_AND_expression}$istrue otherwise to $op2";
|
||||
} else {
|
||||
$return = $item{logical_OR_AND_expression};
|
||||
}
|
||||
@ -429,7 +432,7 @@ conditional_expression:
|
||||
|
||||
conditional_ternary_expression:
|
||||
'?' expression ':' conditional_expression
|
||||
{ $return = "$item{expression} otherwise $item{conditional_expression}"; }
|
||||
{ $return = [$item{expression}, $item{conditional_expression}]; }
|
||||
| {""}
|
||||
|
||||
assignment_operator:
|
||||
|
Loading…
Reference in New Issue
Block a user