Ejemplo n.º 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)
Ejemplo n.º 2
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 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)
Ejemplo n.º 4
0
 def matchNone(self, pat, exp):
     subst = matchAgainst(pExp(pat), pExp(exp))
     self.assertEqual(None, subst)
Ejemplo n.º 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)
Ejemplo n.º 6
0
 def matchNone(self, pat, exp):
     subst = matchAgainst(pExp(pat), pExp(exp))
     self.assertEqual(None, subst)