def make_eq_cond(left, right): """Make a condition of form <var> == <var>.""" return L.Cond(L.Compare(L.Name(left), L.Eq(), L.Name(right)))
'match_eq_cond', 'make_eq_cond', 'SelfJoin', 'ClauseTools', 'CoreClauseTools', ] from enum import Enum from incoq.util.seq import zip_strict from incoq.util.collections import OrderedSet, Partitioning from incoq.compiler.incast import L from .clause import ClauseVisitor, CoreClauseVisitor, Kind, ShouldFilter eq_cond_pattern = L.Cond( L.Compare(L.Name(L.PatVar('LEFT')), L.Eq(), L.Name(L.PatVar('RIGHT')))) def match_eq_cond(tree): """If tree is a condition clause with form <var> == <var>, return a pair of the variables. Otherwise return None. """ result = L.match(eq_cond_pattern, tree) if result is None: return None else: return result['LEFT'], result['RIGHT'] def make_eq_cond(left, right): """Make a condition of form <var> == <var>."""