def handle_integral(func):
    if func.additive():
        integrand = convert_add(func.additive())
    elif func.frac():
        integrand = convert_frac(func.frac())
    else:
        integrand = 1
    int_var = None
    if func.DIFFERENTIAL():
        int_var = get_differential_var(func.DIFFERENTIAL())
    else:
        for sym in integrand.atoms(sympy.Symbol):
            s = str(sym)
            if ((len(s) > 1) and (s[0] == 'd')):
                if (s[1] == '\\'):
                    int_var = sympy.Symbol(s[2:], real=True)
                else:
                    int_var = sympy.Symbol(s[1:], real=True)
                int_sym = sym
        if int_var:
            integrand = integrand.subs(int_sym, 1)
        else:
            int_var = sympy.Symbol('x', real=True)
    if func.subexpr():
        if func.subexpr().atom():
            lower = convert_atom(func.subexpr().atom())
        else:
            lower = convert_expr(func.subexpr().expr())
        if func.supexpr().atom():
            upper = convert_atom(func.supexpr().atom())
        else:
            upper = convert_expr(func.supexpr().expr())
        return sympy.Integral(integrand, (int_var, lower, upper))
    else:
        return sympy.Integral(integrand, int_var)
def handle_integral(func):
    if func.additive():
        integrand = convert_add(func.additive())
    elif func.frac():
        integrand = convert_frac(func.frac())
    else:
        integrand = 1
    int_var = None
    if func.DIFFERENTIAL():
        int_var = get_differential_var(func.DIFFERENTIAL())
    else:
        for sym in integrand.atoms(sympy.Symbol):
            s = str(sym)
            if ((len(s) > 1) and (s[0] == 'd')):
                if (s[1] == '\\'):
                    int_var = sympy.Symbol(s[2:], real=True)
                else:
                    int_var = sympy.Symbol(s[1:], real=True)
                int_sym = sym
        if int_var:
            integrand = integrand.subs(int_sym, 1)
        else:
            int_var = sympy.Symbol('x', real=True)
    if func.subexpr():
        if func.subexpr().atom():
            lower = convert_atom(func.subexpr().atom())
        else:
            lower = convert_expr(func.subexpr().expr())
        if func.supexpr().atom():
            upper = convert_atom(func.supexpr().atom())
        else:
            upper = convert_expr(func.supexpr().expr())
        return sympy.Integral(integrand, (int_var, lower, upper))
    else:
        return sympy.Integral(integrand, int_var)