def Arithm(tokens):
    """(x op1 y) op2 z ..."""
OP = {'*': mul, '/': div, '+': add, '-': sub}
tokens = iter(tokens)
a = next(tokens)
for op, b in zip(tokens, tokens):
    a = OP[op](a, b)
return a

def makeparser():
    expr = Delayed()
determining numerator and denominator in a relatively complex mathematical expression using python