def convert_frac(frac):
    diff_op = False
    partial_op = False
    lower_itv = frac.lower.getSourceInterval()
    lower_itv_len = ((lower_itv[1] - lower_itv[0]) + 1)
    if ((frac.lower.start == frac.lower.stop) and (frac.lower.start.type == PSLexer.DIFFERENTIAL)):
        wrt = get_differential_var_str(frac.lower.start.text)
        diff_op = True
    elif ((lower_itv_len == 2) and (frac.lower.start.type == PSLexer.SYMBOL) and (frac.lower.start.text == '\\partial') and ((frac.lower.stop.type == PSLexer.LETTER_NO_E) or (frac.lower.stop.type == PSLexer.SYMBOL))):
        partial_op = True
        wrt = frac.lower.stop.text
        if (frac.lower.stop.type == PSLexer.SYMBOL):
            wrt = wrt[1:]
    if (diff_op or partial_op):
        wrt = sympy.Symbol(wrt, real=True)
        if (diff_op and (frac.upper.start == frac.upper.stop) and (frac.upper.start.type == PSLexer.LETTER_NO_E) and (frac.upper.start.text == 'd')):
            return [wrt]
        elif (partial_op and (frac.upper.start == frac.upper.stop) and (frac.upper.start.type == PSLexer.SYMBOL) and (frac.upper.start.text == '\\partial')):
            return [wrt]
        upper_text = rule2text(frac.upper)
        expr_top = None
        if (diff_op and upper_text.startswith('d')):
            expr_top = process_sympy(upper_text[1:])
        elif (partial_op and (frac.upper.start.text == '\\partial')):
            expr_top = process_sympy(upper_text[len('\\partial'):])
        if expr_top:
            return sympy.Derivative(expr_top, wrt)
    expr_top = convert_expr(frac.upper)
    expr_bot = convert_expr(frac.lower)
    if (expr_top.is_Matrix or expr_bot.is_Matrix):
        return sympy.MatMul(expr_top, sympy.Pow(expr_bot, (- 1), evaluate=False), evaluate=False)
    else:
        return sympy.Mul(expr_top, sympy.Pow(expr_bot, (- 1), evaluate=False), evaluate=False)
def convert_frac(frac):
    diff_op = False
    partial_op = False
    lower_itv = frac.lower.getSourceInterval()
    lower_itv_len = ((lower_itv[1] - lower_itv[0]) + 1)
    if ((frac.lower.start == frac.lower.stop) and (frac.lower.start.type == PSLexer.DIFFERENTIAL)):
        wrt = get_differential_var_str(frac.lower.start.text)
        diff_op = True
    elif ((lower_itv_len == 2) and (frac.lower.start.type == PSLexer.SYMBOL) and (frac.lower.start.text == '\\partial') and ((frac.lower.stop.type == PSLexer.LETTER_NO_E) or (frac.lower.stop.type == PSLexer.SYMBOL))):
        partial_op = True
        wrt = frac.lower.stop.text
        if (frac.lower.stop.type == PSLexer.SYMBOL):
            wrt = wrt[1:]
    if (diff_op or partial_op):
        wrt = sympy.Symbol(wrt, real=True)
        if (diff_op and (frac.upper.start == frac.upper.stop) and (frac.upper.start.type == PSLexer.LETTER_NO_E) and (frac.upper.start.text == 'd')):
            return [wrt]
        elif (partial_op and (frac.upper.start == frac.upper.stop) and (frac.upper.start.type == PSLexer.SYMBOL) and (frac.upper.start.text == '\\partial')):
            return [wrt]
        upper_text = rule2text(frac.upper)
        expr_top = None
        if (diff_op and upper_text.startswith('d')):
            expr_top = process_sympy(upper_text[1:])
        elif (partial_op and (frac.upper.start.text == '\\partial')):
            expr_top = process_sympy(upper_text[len('\\partial'):])
        if expr_top:
            return sympy.Derivative(expr_top, wrt)
    expr_top = convert_expr(frac.upper)
    expr_bot = convert_expr(frac.lower)
    if (expr_top.is_Matrix or expr_bot.is_Matrix):
        return sympy.MatMul(expr_top, sympy.Pow(expr_bot, (- 1), evaluate=False), evaluate=False)
    else:
        return sympy.Mul(expr_top, sympy.Pow(expr_bot, (- 1), evaluate=False), evaluate=False)