Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
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()
Beispiel #4
0
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()
Beispiel #5
0
 def test61(self):
     eq_(
         preparse(fun.a <= at()[prin(1)]),
         special.begin(
             insert_def(a, (), ((prin(1), ), ), special.UserFunction)))
Beispiel #6
0
 def test42(self):
     eq_(preparse(fun.a(x) <= at[prin(1)]),
         insert_def(a, (x, ), ((prin(1), ), ), special.UserFunction))
Beispiel #7
0
 def test61(self):
   eq_(preparse(fun. a<= at()[prin(1)]), 
       special.begin(insert_def(a, (), ((prin(1),),), special.UserFunction)))
Beispiel #8
0
 def test42(self):
   eq_(preparse(fun. a(x)<= at[prin(1)]),
       insert_def(a, (x,), ((prin(1),),), special.UserFunction))