From 7590644422994788485e91a9ccc452a1f54fbd6c Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Wed, 18 Jun 2014 01:08:19 +0000 Subject: [PATCH] CGrammar: Improve conditional operator translation --- PBot/VERSION.pm | 2 +- modules/c2english/CGrammar.pm | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index eaa4b8ee..2851b2cf 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -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", }; diff --git a/modules/c2english/CGrammar.pm b/modules/c2english/CGrammar.pm index b1a6ff32..010f99cb 100644 --- a/modules/c2english/CGrammar.pm +++ b/modules/c2english/CGrammar.pm @@ -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: