예제 #1
0
파일: dinpy.py 프로젝트: charyorde/dao
def make_fun3(name, args, body, klass): 
  fun = varcache(name)
  head = args
  body = preparse(body)
  if isinstance(body, AtForm): 
    body = body.clauses
    if len(body)>1: raise DinpySyntaxError()
    if body[0][0] is not None: raise DinpySyntaxError()
    return insert_def(fun, head,  body[0][1], klass)
  else: return insert_def(fun, head, [body], klass)
예제 #2
0
파일: dinpy.py 프로젝트: hermetique/dao
def make_fun3(name, args, body, klass):
    fun = varcache(name)
    head = args
    body = preparse(body)
    if isinstance(body, AtForm):
        body = body.clauses
        if len(body) > 1: raise DinpySyntaxError()
        if body[0][0] is not None: raise DinpySyntaxError()
        return insert_def(fun, head, body[0][1], klass)
    else:
        return insert_def(fun, head, [body], klass)
예제 #3
0
파일: dinpy.py 프로젝트: charyorde/dao
def make_fun6(name, rules, klass): 
  fun = varcache(name)
  rules = preparse(rules)
  if isinstance(rules, AtForm): 
    clauses = [(head if head is not None else (), bodies) 
              for head, bodies in rules.clauses]
    return special.begin(*[insert_def(fun, head, bodies, klass) 
                         for head, bodies in clauses])
  elif isinstance(rules, list):
    return insert_def(fun, head, [rules], klass) 
  else: raise DinpySyntaxError()
예제 #4
0
파일: dinpy.py 프로젝트: hermetique/dao
def make_fun6(name, rules, klass):
    fun = varcache(name)
    rules = preparse(rules)
    if isinstance(rules, AtForm):
        clauses = [(head if head is not None else (), bodies)
                   for head, bodies in rules.clauses]
        return special.begin(
            *
            [insert_def(fun, head, bodies, klass) for head, bodies in clauses])
    elif isinstance(rules, list):
        return insert_def(fun, head, [rules], klass)
    else:
        raise DinpySyntaxError()
예제 #5
0
 def test61(self):
     eq_(
         preparse(fun.a <= at()[prin(1)]),
         special.begin(
             insert_def(a, (), ((prin(1), ), ), special.UserFunction)))
예제 #6
0
 def test42(self):
     eq_(preparse(fun.a(x) <= at[prin(1)]),
         insert_def(a, (x, ), ((prin(1), ), ), special.UserFunction))
예제 #7
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test61(self):
   eq_(preparse(fun. a<= at()[prin(1)]), 
       special.begin(insert_def(a, (), ((prin(1),),), special.UserFunction)))
예제 #8
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test42(self):
   eq_(preparse(fun. a(x)<= at[prin(1)]),
       insert_def(a, (x,), ((prin(1),),), special.UserFunction))