pyrser/meta.py
def rule(cls, rulename=None, erase=False):
    """Attach a method to a parsing class and register it as a parser rule.

       The method is registered with its name unless rulename is provided.
    """
    if not hasattr(cls, '_rules'):
        raise TypeError(
            "%s didn't seems to be a BasicParser subsclasse" % cls.__name__)
    class_hook_list = cls._hooks
    class_rule_list = cls._rules

    def wrapper(f):
        nonlocal rulename
        add_method(cls)(f)
        if rulename is None:
            rulename = f.__name__
        if not erase and (rulename in class_hook_list or rulename in class_rule_list):
            raise TypeError("%s is already define has rule or hook" % rulename)
        if '.' not in rulename:
            rulename = cls.__module__ + '.' + cls.__name__ + '.' + rulename
        set_one(class_rule_list, rulename, f)
        return f
    return wrapper
def rule(cls, rulename=None, erase=False):
    """Attach a method to a parsing class and register it as a parser rule.

       The method is registered with its name unless rulename is provided.
    """
    if not hasattr(cls, '_rules'):
        raise TypeError(
            "%s didn't seems to be a BasicParser subsclasse" % cls.__name__)
    class_hook_list = cls._hooks
    class_rule_list = cls._rules

    def wrapper(f):
        nonlocal rulename
        add_method(cls)(f)
        if rulename is None:
            rulename = f.__name__
        if not erase and (rulename in class_hook_list or rulename in class_rule_list):
            raise TypeError("%s is already define has rule or hook" % rulename)
        if '.' not in rulename:
            rulename = cls.__module__ + '.' + cls.__name__ + '.' + rulename
        set_one(class_rule_list, rulename, f)
        return f
    return wrapper
def rule ( cls , rulename = None , erase = False ) : if not hasattr ( cls , '_rules' ) : raise TypeError ( "%s didn't seems to be a BasicParser subsclasse" % cls . __name__ ) class_hook_list = cls . _hooks class_rule_list = cls . _rules def wrapper ( f ) : nonlocal rulename add_method ( cls ) ( f ) if rulename is None : rulename = f . __name__ if not erase and ( rulename in class_hook_list or rulename in class_rule_list ) : raise TypeError ( "%s is already define has rule or hook" % rulename ) if '.' not in rulename : rulename = cls . __module__ + '.' + cls . __name__ + '.' + rulename set_one ( class_rule_list , rulename , f ) return f return wrapper
Attach a method to a parsing class and register it as a parser rule.

       The method is registered with its name unless rulename is provided.
Attach a method to a parsing class and register it as a parser rule .