+/* parse computed goto sides */
+static ast_expression *parse_goto_computed(parser_t *parser, ast_expression *side) {
+ ast_expression *on_true;
+ ast_expression *on_false;
+
+ if (!side)
+ return NULL;
+
+ if (ast_istype(side, ast_ternary)) {
+ on_true = parse_goto_computed(parser, ((ast_ternary*)side)->on_true);
+ on_false = parse_goto_computed(parser, ((ast_ternary*)side)->on_false);
+
+ if (!on_true || !on_false) {
+ parseerror(parser, "expected label or expression in ternary");
+ if (((ast_ternary*)side)->on_false) ast_unref(((ast_ternary*)side)->on_false);
+ if (((ast_ternary*)side)->on_true) ast_unref(((ast_ternary*)side)->on_true);
+ return NULL;
+ }
+
+ return (ast_expression*)ast_ifthen_new(parser_ctx(parser), ((ast_ternary*)side)->cond, on_true, on_false);
+ } else if (ast_istype(side, ast_label)) {
+ ast_goto *gt = ast_goto_new(parser_ctx(parser), ((ast_label*)side)->name);
+ ast_goto_set_label(gt, ((ast_label*)side));
+ return (ast_expression*)gt;
+ }
+ return NULL;
+}
+