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)
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)
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()
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()
def test61(self): eq_( preparse(fun.a <= at()[prin(1)]), special.begin( insert_def(a, (), ((prin(1), ), ), special.UserFunction)))
def test42(self): eq_(preparse(fun.a(x) <= at[prin(1)]), insert_def(a, (x, ), ((prin(1), ), ), special.UserFunction))
def test61(self): eq_(preparse(fun. a<= at()[prin(1)]), special.begin(insert_def(a, (), ((prin(1),),), special.UserFunction)))
def test42(self): eq_(preparse(fun. a(x)<= at[prin(1)]), insert_def(a, (x,), ((prin(1),),), special.UserFunction))