Exemplo n.º 1
0
def unify_macro_head_item1(compiler, cont, arg, head_item):
    # for direct call
    if isinstance(head_item, Var) and not isinstance(head_item, LogicVar):
        k = compiler.new_var(il.ConstLocalVar("cont"))
        return Assign(head_item, direct_interlang(il.Lamda((k,), arg.cps(compiler, k))))
    else:
        return unify(arg, head_item)
Exemplo n.º 2
0
def unify_macro_head_item1(compiler, cont, arg, head_item):
  # for direct call
  if isinstance(head_item, Var) and not isinstance(head_item, LogicVar):
    k = compiler.new_var(il.ConstLocalVar('cont'))
    return Assign(head_item, direct_interlang(il.Lamda((k, ), 
                  arg.cps(compiler, k))))
  else: 
    return unify(arg, head_item)
Exemplo n.º 3
0
def unify_head_item1(arg, head_item):
  # for direct call
  if isinstance(head_item, Var):
    if not isinstance(head_item, LogicVar):
      return Assign(head_item, arg)
    else: 
      raise CompileTypeError(head_item)
  else: 
    if isinstance(head_item, Cons):
      raise CompileTypeError(head_item)
    else:
      return unify(arg, head_item)
Exemplo n.º 4
0
def unify_head_item1(arg, head_item):
    # for direct call
    if isinstance(head_item, Var):
        if not isinstance(head_item, LogicVar):
            return Assign(head_item, arg)
        else:
            raise CompileTypeError(head_item)
    else:
        if isinstance(head_item, Cons):
            raise CompileTypeError(head_item)
        else:
            return unify(arg, head_item)
Exemplo n.º 5
0
 def testcall(self):
   eq_(eval(call(unify(x, 1))), True)
   eq_(eval(is_(x, quote(prin(1)))&call(x)), None)
Exemplo n.º 6
0
 def test2(self):
   eq_(eval(unify(L(1), L(1))), True)
Exemplo n.º 7
0
 def test1(self):
   eq_(eval(unify(x, 1)), True)
Exemplo n.º 8
0
 def test_repeat2(self):
   return
   # the code below loops for ever.
   eq_(eval(and_p(set_text('123'), repeat, char(x), unify(x, '4'))), True) 
Exemplo n.º 9
0
 def test_repeat(self):
   return
   # the code below loops for ever, after modifie the behaviour of solver.parse_state and terminals.
   eq_(eval(and_p(set_text('123'), repeat, char(x), unify(x, '3'))), True)
Exemplo n.º 10
0
 def test_repeat2(self):
     return
     # the code below loops for ever.
     eq_(eval(and_p(set_text('123'), repeat, char(x), unify(x, '4'))), True)
Exemplo n.º 11
0
 def test_repeat(self):
     return
     # the code below loops for ever, after modifie the behaviour of solver.parse_state and terminals.
     eq_(eval(and_p(set_text('123'), repeat, char(x), unify(x, '3'))), True)
Exemplo n.º 12
0
 def testcall(self):
     eq_(eval(call(unify(x, 1))), True)
     eq_(eval(is_(x, quote(prin(1))) & call(x)), None)
Exemplo n.º 13
0
 def test2(self):
     eq_(eval(unify(L(1), L(1))), True)
Exemplo n.º 14
0
 def test1(self):
     eq_(eval(unify(x, 1)), True)