def Seq(*args): """exp1, exp2, ... -> match exp1 followed by exp2 followed by ...""" # I'm always forgetting and passing strings into this function, # so make sure the arguments are expressions for arg in args: assert isinstance(arg, Expression.Expression), \ "expecting an Expression, not a %s" % type(arg) return Expression.Seq(args)
def convert_list(group_names, terms): # This is always a sequence of terms results = [] for term in terms: name = term[0] try: func = converter_table[name] except KeyError: raise AssertionError, "Do not understand sre expression %s" % \ repr(name) results.append(func(*(group_names, ) + term)) if len(results) == 1: return results[0] return Expression.Seq(tuple(results))