def Alt(*inner_rules, **kwargs):
    """
    A rule that expects a sequence of tokens satisfying one of ``rules`` in sequence
    (a rule is satisfied when it returns anything but None) and returns the return
    value of that rule, or None if no rules were satisfied.
    """
    loc = kwargs.get("loc", None)
    expected = lambda parser: reduce(list.__add__, map(lambda x: x.expected(parser), inner_rules))
    if loc is not None:
        @llrule(loc, expected, cases=len(inner_rules))
        def rule(parser):
            data = parser._save()
            for idx, inner_rule in enumerate(inner_rules):
                result = inner_rule(parser)
                if result is unmatched:
                    parser._restore(data, rule=inner_rule)
                else:
                    rule.covered[idx] = True
                    return result
            return unmatched
    else:
        @llrule(loc, expected, cases=len(inner_rules))
        def rule(parser):
            data = parser._save()
            for inner_rule in inner_rules:
                result = inner_rule(parser)
                if result is unmatched:
                    parser._restore(data, rule=inner_rule)
                else:
                    return result
            return unmatched
    return rule
def Alt(*inner_rules, **kwargs):
    """
    A rule that expects a sequence of tokens satisfying one of ``rules`` in sequence
    (a rule is satisfied when it returns anything but None) and returns the return
    value of that rule, or None if no rules were satisfied.
    """
    loc = kwargs.get("loc", None)
    expected = lambda parser: reduce(list.__add__, map(lambda x: x.expected(parser), inner_rules))
    if loc is not None:
        @llrule(loc, expected, cases=len(inner_rules))
        def rule(parser):
            data = parser._save()
            for idx, inner_rule in enumerate(inner_rules):
                result = inner_rule(parser)
                if result is unmatched:
                    parser._restore(data, rule=inner_rule)
                else:
                    rule.covered[idx] = True
                    return result
            return unmatched
    else:
        @llrule(loc, expected, cases=len(inner_rules))
        def rule(parser):
            data = parser._save()
            for inner_rule in inner_rules:
                result = inner_rule(parser)
                if result is unmatched:
                    parser._restore(data, rule=inner_rule)
                else:
                    return result
            return unmatched
    return rule
def Alt ( * inner_rules , * * kwargs ) : loc = kwargs . get ( "loc" , None ) expected = lambda parser : reduce ( list . __add__ , map ( lambda x : x . expected ( parser ) , inner_rules ) ) if loc is not None : @ llrule ( loc , expected , cases = len ( inner_rules ) ) def rule ( parser ) : data = parser . _save ( ) for idx , inner_rule in enumerate ( inner_rules ) : result = inner_rule ( parser ) if result is unmatched : parser . _restore ( data , rule = inner_rule ) else : rule . covered [ idx ] = True return result return unmatched else : @ llrule ( loc , expected , cases = len ( inner_rules ) ) def rule ( parser ) : data = parser . _save ( ) for inner_rule in inner_rules : result = inner_rule ( parser ) if result is unmatched : parser . _restore ( data , rule = inner_rule ) else : return result return unmatched return rule
A rule that expects a sequence of tokens satisfying one of ``rules`` in sequence
    (a rule is satisfied when it returns anything but None) and returns the return
    value of that rule, or None if no rules were satisfied.
A rule that expects a sequence of tokens satisfying one of rules in sequence ( a rule is satisfied when it returns anything but None ) and returns the return value of that rule or None if no rules were satisfied .