diff --git a/loopy/context_matching.py b/loopy/context_matching.py index 0fdf82ba918098f3aec035de82906fafa4e07482..6f83982dfaea0940a3332fd4c0a62c8b4c519100 100644 --- a/loopy/context_matching.py +++ b/loopy/context_matching.py @@ -26,14 +26,13 @@ THE SOFTWARE. """ - - # {{{ id match objects class AllMatch(object): def __call__(self, identifier, tag): return True + class RegexIdentifierMatch(object): def __init__(self, id_re, tag_re=None): self.id_re = id_re @@ -50,6 +49,7 @@ class RegexIdentifierMatch(object): self.id_re.match(identifier) is not None and self.tag_re.match(tag) is not None) + class AlternativeMatch(object): def __init__(self, matches): self.matches = matches @@ -61,6 +61,7 @@ class AlternativeMatch(object): # }}} + # {{{ single id match parsing def parse_id_match(id_matches): @@ -109,6 +110,7 @@ def parse_id_match(id_matches): # }}} + # {{{ stack match objects # these match from the tail of the stack @@ -116,10 +118,12 @@ def parse_id_match(id_matches): class StackMatchBase(object): pass + class AllStackMatch(StackMatchBase): def __call__(self, stack): return True + class StackIdMatch(StackMatchBase): def __init__(self, id_match, up_match): self.id_match = id_match @@ -138,6 +142,7 @@ class StackIdMatch(StackMatchBase): else: return self.up_match(stack[:-1]) + class StackWildcardMatch(StackMatchBase): def __init__(self, up_match): self.up_match = up_match @@ -159,6 +164,7 @@ class StackWildcardMatch(StackMatchBase): # }}} + # {{{ stack match parsing def parse_stack_match(smatch): @@ -170,7 +176,8 @@ def parse_stack_match(smatch): arbitrary number of intervening stack levels. There is currently no way to match the top of the stack. - Each of the entries is an identifier match as understood by :func:`parse_id_match`. + Each of the entries is an identifier match as understood by + :func:`parse_id_match`. """ if isinstance(smatch, StackMatchBase):