Parse and evaluate a ternary expression string like 'T?2:3' or 'F?1:T?4:5'.
Given a ternary expression (a conditional expression with format condition ? value1 : value2), parse and evaluate it. The expression may be nested.
condition ? value1 : value2
Return the result of evaluating the ternary expression.