def _tokens(string):
    "Private module function: recursively builds a tree."
    expression = string.strip()
    if not expression:
        raise SyntaxError('empty expression')
    divisions = Operation.split(expression)
    if divisions:
        left, symbol, right = divisions
        return Operation(_tokens(left), symbol, _tokens(right))
    if len(expression.split()) > 1:
        raise SyntaxError(expression)
    if expression.startswith('0x'):
        return Constant(int(expression[2:], 16))
    if expression.startswith('0d'):
        return Constant(int(expression[2:], 10))
    if expression.startswith('0o'):
        return Constant(int(expression[2:], 8))
    if expression.startswith('0q'):
        return Constant(int(expression[2:], 4))
    if expression.startswith('0b'):
        return Constant(int(expression[2:], 2))
    if expression.isdigit():
        return Constant(int(expression))
    if expression.isidentifier():
        return Variable(expression)
    raise SyntaxError(expression)
Private module function: recursively builds a tree.
recipes/Python/577469_Evaluator_20/recipe-577469.py