Example #1
0
 def matchOK(self, pat, exp, expected):
     subst = matchAgainst(pExp(pat), pExp(exp))
     if subst:
         subst_l = list(subst.iteritems())
         subst_l.sort()
         subst = "".join(["%s->%s;" % (vname, e) for (vname, e) in subst_l])
     self.assertEqual(expected, subst)
 def matchOK(self, pat, exp, expected):
     subst = matchAgainst(pExp(pat), pExp(exp))
     if subst:
         subst_l = list(subst.iteritems())
         subst_l.sort()
         subst = "".join(["%s->%s;" % (vname, e) 
                          for (vname, e) in subst_l])
     self.assertEqual(expected, subst)
 def loopBack(self, beta, alpha):
     subst = matchAgainst(alpha.exp, beta.exp)
     bindings = list(subst.items())
     bindings.sort()
     letExp = Let(alpha.exp, bindings)
     self.tree.replaceSubtree(beta, letExp)
 def matchNone(self, pat, exp):
     subst = matchAgainst(pExp(pat), pExp(exp))
     self.assertEqual(None, subst)
Example #5
0
 def loopBack(self, beta, alpha):
     subst = matchAgainst(alpha.exp, beta.exp)
     bindings = list(subst.items())
     bindings.sort()
     letExp = Let(alpha.exp, bindings)
     self.tree.replaceSubtree(beta, letExp)
Example #6
0
 def matchNone(self, pat, exp):
     subst = matchAgainst(pExp(pat), pExp(exp))
     self.assertEqual(None, subst)