def valuemap(f):
    """
    Decorator to help PEG functions handle value conversions.
    """
    @wraps(f)
    def wrapper(*args, **kwargs):
        if 'value' in kwargs:
            val = kwargs['value']
            del kwargs['value']
            _f = f(*args, **kwargs)
            def valued_f(*args, **kwargs):
                result = _f(*args, **kwargs)
                s, obj, span = result
                if callable(val):
                    return PegreResult(s, val(obj), span)
                else:
                    return PegreResult(s, val, span)
            return valued_f
        else:
            return f(*args, **kwargs)
    return wrapper
def valuemap ( f ) : @ wraps ( f ) def wrapper ( * args , ** kwargs ) : if 'value' in kwargs : val = kwargs [ 'value' ] del kwargs [ 'value' ] _f = f ( * args , ** kwargs ) def valued_f ( * args , ** kwargs ) : result = _f ( * args , ** kwargs ) s , obj , span = result if callable ( val ) : return PegreResult ( s , val ( obj ) , span ) else : return PegreResult ( s , val , span ) return valued_f else : return f ( * args , ** kwargs ) return wrapper
Decorator to help PEG functions handle value conversions.