parse pointer into tokens

def parse(self, pointer):
        """parse pointer into tokens"""
        if isinstance(pointer, Pointer):
            return pointer.tokens[:]
        elif pointer == '':
            return []

        tokens = []
        staged, _, children = pointer.partition('/')
        if staged:
            try:
                token = StagesToken(staged)
                token.last = False
                tokens.append(token)
            except ValueError:
                raise ParseError('pointer must start with / or int', pointer)

        if _:
            for part in children.split('/'):
                part = part.replace('~1', '/')
                part = part.replace('~0', '~')
                token = ChildToken(part)
                token.last = False
                tokens.append(token)

        return tokens