def METHOD_NAME(parser, token):
    """
        {% has_perm user perm instance as context}
        {% has_perm user perm as context}
    """
    bits = token.split_contents()
    try:
        user = bits[1]
    except:
        user = None
    try:
        perm = bits[2]
    except:
        perm = None
    try:
        object = bits[3]
    except:
        object = None
    if object == 'as':
        object = None
        try:
            context_var = bits[4]
        except:
            context_var = None
    else:
        try: context_var = bits[5]
        except: context_var = None
    return HasPermNode(user, perm, object, context_var=context_var)