switch_stmt : SWITCH expr semi_opt case_list END_STMT

def p_switch_stmt(p):
    """
    switch_stmt : SWITCH expr semi_opt case_list END_STMT
    """

    def backpatch(expr, stmt):
        if isinstance(stmt, node.if_stmt):
            stmt.cond_expr.args[1] = expr
            backpatch(expr, stmt.else_stmt)

    backpatch(p[2], p[4])
    p[0] = p[4]