import string


def _parse_number(stream):
    """Expects the stream to contain a number next, returns the number without
    consuming any more bytes."""
    rv = ''
    while stream.peek() and stream.peek() in string.digits:
        rv += next(stream)

    return int(rv)