alge.py
def of(pat):
    """Decorator for methods of Case to describe the pattern.

    Args
    ----
    pat: str

    Patterns are like writing tuples (of tuples (of ...)) for the type
    structure to match against.  Names starting with a lowercase letter are
    used as binding slots that the matcher will capture and used as argument
    to the action function, the function being decorated.  Names that starts
    with a underscore '_' is ignored.  Names starting with a uppercase letter
    are type names.
    """

    # Get globals from caller's frame
    glbls = inspect.currentframe().f_back.f_globals
    # Parse pattern
    parser = _PatternParser(pat, glbls)
    parser.parse()

    codes = []
    keepalive = tuple(parser.result.gen_match())
    stacksz = 2
    for m in keepalive:
        codes.extend(m.codify())
        # This will over allocate the stack space
        # TODO: do this properly
        stacksz += m.stackuse()
    codes = tuple(codes)
    bytecodes = struct.pack('P' * len(codes), *codes)

    def decor(fn):
        assert fn.__name__ not in RESERVED, "function name is reserved"

        @functools.wraps(fn)
        def closure(self):
            cap = {}
            if _alge.match(bytecodes, self.value, cap, stacksz):
                return fn(self, **cap)
            else:
                return NoMatch

        closure._inner = fn
        closure._keepalive = keepalive
        return closure

    return decor
Decorator for methods of Case to describe the pattern.

    Args
    ----
    pat: str

    Patterns are like writing tuples (of tuples (of ...)) for the type
    structure to match against.  Names starting with a lowercase letter are
    used as binding slots that the matcher will capture and used as argument
    to the action function, the function being decorated.  Names that starts
    with a underscore '_' is ignored.  Names starting with a uppercase letter
    are type names.
    
Decorator for methods of Case to describe the pattern.
Args

str

Patterns are like writing tuples (of tuples (of ...)) for the type
structure to match against.  Names starting with a lowercase letter are
used as binding slots that the matcher will capture and used as argument
to the action function, the function being decorated.  Names that starts
with a underscore '_' is ignored.  Names starting with a uppercase letter
are type names.
Decorator for methods of Case to describe the pattern . Args str Patterns are like writing tuples ( of tuples ( of ... )) for the type structure to match against . Names starting with a lowercase letter are used as binding slots that the matcher will capture and used as argument to the action function the function being decorated . Names that starts with a underscore ' _ ' is ignored . Names starting with a uppercase letter are type names .
def of(pat):
    glbls = inspect.currentframe().f_back.f_globals
    parser = _PatternParser(pat, glbls)
    parser.parse()
    codes = []
    keepalive = tuple(parser.result.gen_match())
    stacksz = 2
    for m in keepalive:
        codes.extend(m.codify())
        stacksz += m.stackuse()
    codes = tuple(codes)
    bytecodes = struct.pack('P' * len(codes), *codes)
    def decor(fn):
        assert fn.__name__ not in RESERVED, "function name is reserved"
        @functools.wraps(fn)
        def closure(self):
            cap = {}
            if _alge.match(bytecodes, self.value, cap, stacksz):
                return fn(self, **cap)
            else:
                return NoMatch
        closure._inner = fn
        closure._keepalive = keepalive
        return closure
    return decor
def of ( pat ) : glbls = inspect . currentframe ( ) . f_back . f_globals parser = _PatternParser ( pat , glbls ) parser . parse ( ) codes = [ ] keepalive = tuple ( parser . result . gen_match ( ) ) stacksz = 2 for m in keepalive : codes . extend ( m . codify ( ) ) stacksz += m . stackuse ( ) codes = tuple ( codes ) bytecodes = struct . pack ( 'P' * len ( codes ) , * codes ) def decor ( fn ) : assert fn . __name__ not in RESERVED , "function name is reserved" @ functools . wraps ( fn ) def closure ( self ) : cap = { } if _alge . match ( bytecodes , self . value , cap , stacksz ) : return fn ( self , ** cap ) else : return NoMatch closure . _inner = fn closure . _keepalive = keepalive return closure return decor
Decorator for methods of Case to describe the pattern.
Decorator for methods of Case to describe the pattern .
"""Decorator for methods of Case to describe the pattern.

    Args
    ----
    pat: str

    Patterns are like writing tuples (of tuples (of ...)) for the type
    structure to match against.  Names starting with a lowercase letter are
    used as binding slots that the matcher will capture and used as argument
    to the action function, the function being decorated.  Names that starts
    with a underscore '_' is ignored.  Names starting with a uppercase letter
    are type names.
    """ # Get globals from caller's frame # Parse pattern # This will over allocate the stack space # TODO: do this properly
pat