def make_fun2(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 append_def(fun, head, body[0][1], klass) else: return append_def(fun, head, [body], klass)
def make_fun2(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 append_def(fun, head, body[0][1], klass) else: return append_def(fun, head, [body], klass)
def make_fun5(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(*[append_def(fun, head, bodies, klass) for head, bodies in clauses]) elif isinstance(rules, list): return append_def(fun, head, [rules], klass) else: raise DinpySyntaxError()
def make_fun5(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( * [append_def(fun, head, bodies, klass) for head, bodies in clauses]) elif isinstance(rules, list): return append_def(fun, head, [rules], klass) else: raise DinpySyntaxError()
def test41(self): eq_( preparse(fun.a(x) >= at[prin(1)][prin(2)]), append_def(a, (x, ), ( (prin(1), ), (prin(2), ), ), special.UserFunction))
def test6(self): eq_( preparse(fun.a >= at()[prin(1)]), special.begin( append_def(a, (), ((prin(1), ), ), special.UserFunction)))
def test3(self): eq_(preparse(fun.a(x) >= [prin(1)]), append_def(a, (x, ), [(prin(1), )], special.UserFunction))
def test6(self): eq_(preparse(fun. a>= at()[prin(1)]), special.begin(append_def(a, (), ((prin(1),),), special.UserFunction)))
def test41(self): eq_(preparse(fun. a(x)>= at[prin(1)][prin(2)]), append_def(a, (x,), ((prin(1),),(prin(2),),), special.UserFunction))
def test3(self): eq_(preparse(fun. a(x)>= [prin(1)]), append_def(a, (x,), [(prin(1),)], special.UserFunction))