def register(name=None, exprresolver=None, params=None, reg=None):
def _register(exprresolver, _name=name, _params=params):<EOL><INDENT>"""<STR_LIT>"""<EOL>_exprresolver = exprresolver<EOL>if isclass(exprresolver):  <EOL><INDENT>if _params is None:<EOL><INDENT>_params = {}<EOL><DEDENT>_exprresolver = _exprresolver(**_params)<EOL><DEDENT>if _name is None:<EOL><INDENT>_name = getname(exprresolver)<EOL><DEDENT>reg[_name] = _exprresolver<EOL>if reg.default is None:<EOL><INDENT>reg.default = _name<EOL><DEDENT>return exprresolver<EOL><DEDENT>if name is None:<EOL><INDENT>name = getname(exprresolver)<EOL><DEDENT>if reg is None:<EOL><INDENT>reg = _RESOLVER_REGISTRY<EOL><DEDENT>if exprresolver is None:<EOL><INDENT>result = _register<EOL><DEDENT>else:<EOL><INDENT>result = name<EOL>_register(exprresolver)<EOL><DEDENT>return result<EOL>
Register an expression resolver.

    Can be used such as a decorator.

    For example all remainding expressions are the same.

    .. code-block:: python

        @register('myresolver')
        def myresolver(**kwargs): pass

    .. code-block:: python

        def myresolver(**kwargs): pass

        register('myresolver', myresolver)

    .. code-block:: python

        @register('myresolver')
        class MyResolver():
            def __call__(**kwargs): pass

    .. code-block:: python

        class MyResolver():
            def __call__(**kwargs): pass

        register('myresolver', MyResolver)

    .. code-block:: python

        class MyResolver():
            def __call__(**kwargs): pass

        register('myresolver', MyResolver())


    :param str name: register name to use. Default is the function/class
        name.
    :param exprresolver: function able to resolve an expression.
    :param dict kwargs: parameters of resolver instanciation if exprresolver
        is a class and this function is used such as a decorator.
    :param ResolverRegistry reg: registry to use. Default is the global registry
    .