class ExpandDomain: MinKey = Symbolic("min") MaxKey = Symbolic("max") IncKey = Symbolic("inc") def __init__(self, evaluator): self.evaluator = evaluator def apply(self, x): if not isinstance(x, Collection): return x return Set(self.evalDomain(x)) def evalDomain(self, C): D = set() if C.contains_key(self.MinKey): min = self.evaluator.apply(C.get(self.MinKey)).int_value() max = self.evaluator.apply(C.get(self.MaxKey)).int_value() inc = self.evaluator.apply( C.get_or_default(self.IncKey, Integer(1))).int_value() for i in range(min, max + 1, inc): D.add(Integer(i)) else: for e in C: e = self.evaluator.apply(e) if isinstance(e, Collection): D.addAll(self.evalDomain(e)) else: D.add(e) return D
def load_container_interfaces(self, C): evaluator = self.get_function(EVAL) for m in C.get_module_names(): for e in C.get_matching_entries(m, Symbolic("#interface"), Variable()): uri = evaluator.apply(e.get_value()[Symbolic("uri")]) interface_term = evaluator.apply(e.get_value()) self.interfaces[uri] = interface_term
def apply(self, x): name = x[Symbolic("name")] module = x[Symbolic("module")] py_class = x[Symbolic("pyclass")] py_module = x[Symbolic("pymodule")] imp = importlib.import_module(str(py_module)) instance = getattr(imp, str(py_class))() uri = module + name self.freg.add_function(uri, instance)
def apply(self, x): name = x[Symbolic("name")] module = x[Symbolic("module")] py_class = x[Symbolic("pyclass")] py_module = x[Symbolic("pymodule")] imp = importlib.import_module(str(py_module)) constructor = getattr(imp, str(py_class)) factory = PythonFunctionFactory(constructor, self.freg) uri = module + name self.freg.add_function(uri, factory) return FunctionReference(uri, self.freg)
def toggle_namespaces(self, flag): sub_map = {} for m in self.moduleList: ns_sub = m.get_namespace_substitution() if not flag: ns_sub = ns_sub.inverse() sub_map[m.get_name()] = ns_sub for m in self.moduleList: namespaces = self.get_matching_entries(m.get_name(), Symbolic("#namespace"), None) namespaces += self.get_matching_entries(m.get_name(), Symbolic("#nms"), None) s = Substitution() for ns in namespaces: ns_term = ns.get_value() if isinstance(ns_term, Symbolic): ns_mod_name = self.resolve_module_alias( m.get_name(), ns.get_name()) if ns_mod_name is None: raise ValueError("Could not find alias: %s %s" % (m.get_name(), ns.get_name())) if not s.add_substitution(sub_map.get(ns_mod_name)): raise ValueError("Namespace conflict in module " + str(m.get_name()) + ". Change namespace or use " + "#req and references.") elif isinstance(ns_term, Tuple): ns_name = ns_term[0] ns_table = self.resolve_reference(ns_term[1]) ns_sub = Substitution() for entry in ns_table: ns_sub.add(entry[ns_name], entry[0]) if not s.add_substitution(ns_sub): print("Namespace term:", ns_term) print("Substitution before:", s) print("Failed to add:", ns_sub) raise ValueError("Namespace conflict in module " + str(m.get_name()) + ". Change namespace or use " + "#req and references.") if len(s) > 0: m.substitute(s)
def apply(self, arg): arg_term = arg[0] fun_term = arg[1] f = LambdaFunction(arg_term, fun_term, self.evaluator) uri = Symbolic("#lambda_%d" % (LambdaEvaluator.NextID)) LambdaEvaluator.NextID += 1 self.freg.add_function(uri, f) return FunctionReference(uri, self.freg)
class Signature: TYPE = Symbolic("org.aiddl.eval.type") QUOTE = Symbolic("org.aiddl.eval.quote") def __init__(self, evaluator): self.evaluator = evaluator def apply(self, x): targets = x.get(0) types = x.get(1) if not isinstance(targets, Tuple): return Boolean.create(True) for i in range(targets.size()): idx = min(i, types.size() - 1) con = Tuple([TYPE, Tuple([QUOTE, targets.get(i)]), types.get(idx)]) if not self.evaluator.apply(con).bool_value(): return Boolean.create(False) return Boolean.create(True)
def get_mod_name_from_file(fname, aiddl_paths): f = find_and_open_file(fname, aiddl_paths) s = "" for l in f.readlines(): s += l if ")" in l: f.close() break req_mod_n = s.split("(")[1].split(")")[0].split()[-1] return Symbolic(req_mod_n)
def load_req_python_functions(self, C): for m in C.get_module_names(): functions = self.get_function_list( m, C) # C.get_entry(Symbolic("functions"), module=m) # print("Functions:", functions) if len(functions) > 0: missing = False for f in functions: if not self.has_function(f[0]): missing = True break if missing: loader_mod = m + Symbolic("python") if parser.is_known_module(loader_mod): lu = parser.get_mod_file_lookup( parser.collect_aiddl_paths([])) evalutaor = self.get_function(EVAL) parser.parse_internal(lu[loader_mod], C, self, ".") for e in C.get_matching_entries( loader_mod, Symbolic("#on-load"), Variable()): load = e.get_value() if isinstance(load, Tuple): evalutaor.apply(load) else: for call in load: evalutaor.apply(call) # load_request = C.get_entry(Symbolic("load"), module=loader_mod) # if load_request is not None: # rHandler = RequestHandler(C, self) # # rHandler.verbose = True # rHandler.satisfy_request(load_request.get_value(), Symbolic("NIL")) # else: # print("Could not find loader module:", loader_mod) for f in functions: if not self.has_function(f[0]): print("[Warning]", f[0], ": Missing python implementation")
def apply(self, x): uri = None init = None config = None if isinstance(x, Symbolic): uri = x else: uri = x[0] init = x[Symbolic("init")] config = x[Symbolic("config")] f = self.constructor() if init is not None: f.initialize(init) if config is not None: f.configure(config, self.freg) self.freg.add_function(uri, f) return FunctionReference(uri, self.freg)
def load_type_functions(self, C): evaluator = self.get_function(EVAL) for m in C.get_module_names(): for e in C.get_matching_entries(m, Symbolic("#type"), Variable()): uri = m + e.get_name() evaluator.set_follow_references(True) #evaluator.set_verbose(True) type_def = evaluator.apply(e.get_value()) evaluator.set_follow_references(False) #evaluator.set_verbose(False) type_fun = TypeCheckFunction(type_def, evaluator) self.add_function(uri, type_fun) interface_term = evaluator.apply(e.get_value()) self.interfaces[uri] = interface_term
class Reduce: INIT_VAL = Symbolic("initial-value") def __init__(self, freg): self.freg = freg self.evaluator = freg.get_function(EVAL) def apply(self, args): f = self.evaluator.apply(args[0]).get_function_or_panic() C = self.evaluator.apply(args[1]) current_value = args.get(Reduce.INIT_VAL) for e in C: if current_value is None: current_value = e else: current_value = f.apply(Tuple([current_value, e])) return current_value
def run(C, evaluator, freg, verbose): n_tests = 0 n_successful = 0 rHandler = RequestHandler(C, freg) # rHandler.verbose = True for req in C.get_matching_entries(Variable(), Symbolic("#assert-request"), Variable()): request_term = req.get_value()[0] exec_module = req.get_value()[1].resolve(C) rHandler.satisfy_request(request_term, exec_module) tests = C.get_matching_entries(None, ASSERT, None) for test in tests: p, t = run_single_test(str(test.get_name()), test.get_value(), evaluator, freg, verbose) n_successful += p n_tests += t return (n_successful, n_tests)
from aiddl_core.representation.list import List from aiddl_core.representation.set import Set from aiddl_core.representation.variable import Variable import aiddl_core.function.default as dfun test_folder = "../../test/" test_file = test_folder + "example-module.aiddl" C = Container() freg = dfun.get_default_function_registry(C) test_mod = parser.parse(test_file, C, freg, test_folder) e = C.get_entry(Symbolic("a")) assert (e.get_type() == Symbolic("org.aiddl.term.numerical.integer")) assert (e.get_name() == Symbolic("a")) assert (e.get_value() == Integer(1)) E = C.get_matching_entries(Variable("?M"), Variable("?T"), Tuple([Symbolic("X"), Variable("_")])) assert (len(E) == 5) e = Entry(Symbolic("t"), Symbolic("a"), List([Integer(1), Symbolic("x")])) C.set_entry(e, module=test_mod) e_c = C.get_entry(Symbolic("a"))
def get_function_list(self, m, C): L = [] for e in C.get_matching_entries(m, Symbolic("#functions"), Variable()): for t in e.get_value(): L.append(t) return List(L)
from aiddl_core.representation.symbolic import Symbolic from aiddl_core.tools.stopwatch import StopWatch START = Symbolic("stopwatch") STOP = Symbolic("stopwatch") def run_stopwatch(self, request): command = self.eval.apply(request[1].resolve(self.C)) value = self.eval.apply(request[1].resolve(self.C)) if command == START: StopWatch.start(value) elif command == STOP: StopWatch.stop(value) else: raise ValueError("Illegal command %s in request %s" + "(use start or stop)" % (str(command), str(request)))
def check(self, type_def, term): # Logger.msg("TypeCheck", str(type_def) + " ?? " + str(term)) r = False if isinstance(type_def, Tuple): type_class = type_def[0] if type_class == Symbolic("basic-type"): e = Tuple([type_def[1], term]) r = self.evaluator.apply(e).bool_value() elif type_class == Symbolic("set-of"): subType = type_def.get(1) if isinstance(term, Set): r = True Logger.inc_depth() for e in term: if not self.check(subType, e): #print("---> FAIL") r = False break Logger.dec_depth() else: r = False elif type_class == Symbolic("list-of"): subType = type_def.get(1) if isinstance(term, List): r = True Logger.inc_depth() for e in term: if not self.check(subType, e): r = False break Logger.dec_depth() else: r = False elif type_class == Symbolic("collection-of"): subType = type_def.get(1) if isinstance(t, Collection): r = True Logger.inc_depth() for e in term: if not self.check(subType, e): r = False break Logger.dec_depth() else: r = False elif type_class == Symbolic("signed-tuple"): signature = type_def.get(1) min = type_def.get_or_default(Symbolic("min"), Integer(len(signature))) max = type_def.get_or_default(Symbolic("max"), Integer(len(signature))) repeat = type_def.get_or_default(Symbolic("repeat"), Integer(1)) tSize = Integer(len(type_def)) repeat_start_idx = len(signature) - repeat.int_value() if isinstance(term, Tuple) and tSize >= min and tSize <= max: Logger.inc_depth() r = True for i in range(0, len(signature)): sig_idx = i if i >= signature.size(): sig_idx = repeat_start_idx + \ (i - signature.size()) % repeat.getIntValue() if not self.check(signature.get(sig_idx), term.get(i)): r = False break Logger.dec_depth() else: r = False elif type_class == Symbolic("key-value-tuple"): keyTypeCol = type_def.get(1) r = True Logger.inc_depth() for kvp in keyTypeCol: e = term.get(kvp.get_key()) if e is None: r = False break if not self.check(kvp.get_value(), e): r = False break Logger.dec_depth() elif type_class == Symbolic("enum"): r = term in type_def.get(1) elif type_class == Symbolic("numerical-range"): min = type_def.get_or_default(Symbolic("min"), Infinity.neg()) max = type_def.get_or_default(Symbolic("max"), Infinity.pos()) r = False if isinstance(term, Numerical): if term >= min and term <= max: r = True elif type_class == Symbolic("typed-key-value"): r = False if isinstance(term, KeyValue): if self.check(type_def[1], term.get_key()) and self.check( type_def[1], term.get_value()): r = True elif type_class == Symbolic("or-type"): r = False for choice in type_def[1]: if self.check(choice, term): r = True break else: raise ValueError("#type expression not supported:", type_def) elif isinstance(type_def, Symbolic): e = Tuple([type_def, term]) r = self.evaluator.apply(e).bool_value() else: r = False raise ValueError("#type expression not supported:", type_def) # if not r: # Logger.msg("TypeCheck", str(term) + " !! " + str(type_def)) return r
def apply(self, arg): # if not self.evaluatable(arg): # return arg # if arg in self.cache.keys(): # return self.cache[arg] if self.verbose: print(self.log_indent + str(arg)) self.log_indent += " " operator = None if not isinstance(arg, Tuple) or len(arg) == 0: if isinstance(arg, Collection): newCol = [] for t in arg: newCol.append(self.apply(t)) if isinstance(arg, List): result = List(newCol) else: result = Set(newCol) elif isinstance(arg, KeyValue): result = KeyValue(self.apply(arg.get_key()), self.apply(arg.get_value())) elif isinstance(arg, Reference): #print("-----", arg, self.follow_references) if self.follow_references: result = self.apply(self.db.resolve_reference(arg)) else: result = self.db.resolve_reference(arg) #print(arg, "resolved to", result) else: result = arg else: operator = arg.get(0) if isinstance(operator, Reference): target = operator.get_ref_target() if isinstance(target, Symbolic): uri = operator.convert2uri() if self.freg.has_function(uri): operator = uri else: operator = self.db.resolve_reference(operator) else: operator = self.db.resolve_reference(operator) # if self.verbose: # tail = str(operator) resolvedArguments = [] processed_op = self.apply(operator) if not self.freg.has_function(processed_op): resolvedArguments.append(processed_op) for i in range(1, arg.size()): if operator not in self.delayedEval: if isinstance(arg.get(i), Reference): res_arg = self.db.resolve_reference(arg.get(i)) else: res_arg = arg.get(i) # if len(self.selfStack) > 0: # if operator != TYPE: # res_arg = res_arg.substitute(self.selfStack[-1]) # elif i == 1: # res_arg = res_arg.substitute(self.selfStack[-1]) # if operator == TYPE and i == 2: # s = Substitution() # s.add(SELF, resolvedArguments[1]) # res_arg = res_arg.substitute(s) # self.selfStack.append(s) # doPop = True if operator not in self.delayedEval: resolvedArguments.append(self.apply(res_arg)) else: resolvedArguments.append(res_arg) else: resolvedArguments.append(arg.get(i)) if len(resolvedArguments) == 1: processedArgs = resolvedArguments[0] else: processedArgs = Tuple(resolvedArguments) if self.freg.has_function(operator): result = self.freg.get_function(operator).apply(processedArgs) else: result = processedArgs if self.verbose: if operator is None: operator = Symbolic("-") self.log_indent = self.log_indent[0:-2] print(self.log_indent + str(result) + "//" + str(operator)) self.cache[arg] = result return result
class CoreLang: Lang = Symbolic("python") def apply(self, x): return CoreLang.Lang
from aiddl_core.representation.symbolic import Symbolic from aiddl_core.representation.symbolic import Boolean from aiddl_core.representation.numerical import Numerical from aiddl_core.representation.integer import Integer from aiddl_core.representation.infinity import Infinity from aiddl_core.representation.key_value import KeyValue from aiddl_core.representation.list import List from aiddl_core.representation.tuple import Tuple from aiddl_core.representation.set import Set from aiddl_core.representation.function_reference import FunctionReference from aiddl_core.tools.logger import Logger import aiddl_core.function.uri as furi SELF = Symbolic("#self") SELF_ALT = Symbolic("#arg") class NamedFunction: def __init__(self, name, f, e, args=None): self.name = name self.f = f self.e = e self.args = args def apply(self, arg): if self.args is None: s = Substitution() s.add(SELF, arg) s.add(SELF_ALT, arg)
def apply(self, x): split_list = [] for t in str(x).split("."): split_list.append(Symbolic(t)) return List(split_list)
OTUPLE = "(" CTUPLE = ")" OSET = "{" CSET = "}" OLIST = "[" CLIST = "]" REF = "@" SREF = "$" FREF = "^" ASSOC = ":" MOD = Symbolic("#mod") REQ = Symbolic("#req") NAMES = Symbolic("#namespace") NAMES_ALT = Symbolic("#nms") QMARKS = '"' ANY = "_" SPECIAL = [OTUPLE, CTUPLE, OSET, CSET, OLIST, CLIST, ASSOC, REF, SREF, FREF] INFINITY = ["INF", "+INF", "-INF"] def is_float(s): try: float(s)
def parse_string(s, aiddl_paths, freg): str_id = 0 str_lookup = {} bs = False current_str_start = None slices = [] s_new = "" for i in range(len(s)): c = s[i] if c == '"' and not bs and current_str_start is not None: str_lookup[str_id] = s[current_str_start:i] slices.append((current_str_start, i, str(str_id))) s_new += ' "%d"' % (str_id) current_str_start = None str_id += 1 elif c == '"' and not bs: current_str_start = i + 1 elif current_str_start is None: s_new += c if c == '\\': bs = True else: bs = False # for sl in slices: # s = s[:sl[0]] + sl[2] + s[sl[1]:] s = s_new s = re.sub(r";;.*\n", "", s) s = s.replace("\n", " ") s = s.replace("\t", " ") for token in SPECIAL: s = s.replace(token, " " + token + " ") while " " in s: s = s.replace(" ", " ") s = s.strip() stack = [] module_name = None self_ref = None local_refs = {} tokens = s.split(" ") tuple_depth = 0 for token in tokens: token = token.strip() if token == CLIST: assembled_list = [] current = pop(stack) while current != OLIST: assembled_list.append(current) current = pop(stack) assembled_list.reverse() term = List(assembled_list) # push(stack, term) elif token == CTUPLE: tuple_depth -= 1 assembled_list = [] current = pop(stack) while current != OTUPLE: assembled_list.append(current) current = pop(stack) assembled_list.reverse() term = Tuple(assembled_list) # push(stack, term) if tuple_depth == 0: if term.get(0) == MOD: self_ref = term.get(1) module_name = term.get(2) elif term.get(0) == REQ or \ term.get(0) == NAMES or \ term.get(0) == NAMES_ALT: local_refs[term.get(1)] = term.get(2) if isinstance(term.get(2), String): fname = term.get(2).get_string_value() req_mod_n = get_mod_name_from_file(fname, aiddl_paths) local_refs[term.get(1)] = req_mod_n elif token == CSET: assembled_set = [] current = pop(stack) while current != OSET: assembled_set.append(current) current = pop(stack) term = Set(assembled_set) elif token in SPECIAL: push(stack, token) if token == OTUPLE: tuple_depth += 1 continue else: term = None if token[0] == "?": term = Variable(name=token) elif token == "_": term = Variable() elif token[0] == '"': string = str_lookup[int(token[1:-1])] term = String(string) elif "/" in token: n = token.split("/")[0] d = token.split("/")[1] term = Rational(int(n), int(d)) elif is_float(token): term = Real(float(token)) elif is_int(token): term = Integer(int(token)) elif is_bin(token): term = Integer(int(token[2:], 2)) elif is_oct(token): term = Integer(int(token[2:], 8)) elif is_hex(token): term = Integer(int(token[2:], 16)) elif token in INFINITY: if "-" in token: term = Infinity.neg() else: term = Infinity.pos() else: term = Symbolic(token) if len(stack) > 0: back_resolve = True while back_resolve and len(stack) > 0: back_resolve = False if peek(stack) == SREF: pop(stack) term = Reference(term, module_name) back_resolve = True elif peek(stack) == REF: pop(stack) name = pop(stack) if not isinstance(name, FunctionReference): if term == self_ref: # print("Pointing to %s in module %s (aka %s)" # % (str(name), str(module_name), str(term))) term = Reference(name, module_name, alias=term) else: # print("Pointing to %s in module %s (aka %s)" # % (str(name), str(module_name), str(term))) term = Reference(name, local_refs[term], alias=term) else: bad_fref = name.get_fref() if term == self_ref: term = FunctionReference(bad_fref, freg, module=module_name) else: term = FunctionReference(bad_fref, freg, module=module_name) back_resolve = True elif peek(stack) == FREF: pop(stack) term = FunctionReference(term, freg) back_resolve = True elif peek(stack) == ASSOC: pop(stack) key = pop(stack) if isinstance(key, KeyValue): term = KeyValue(key._key, KeyValue(key._value, term)) else: term = KeyValue(key, term) back_resolve = True push(stack, term) return (stack, module_name, self_ref, local_refs)
from aiddl_core.representation.term import Term from aiddl_core.representation.symbolic import Symbolic from aiddl_core.representation.substitution import Substitution from aiddl_core.representation.reference import Reference from aiddl_core.representation.tuple import Tuple from aiddl_core.container.entry import Entry from aiddl_core.container.module import Module MOD = Symbolic("#mod") class Container: def __init__(self): self.modules = {} self.moduleList = [] self.aliasLookup = {} self.selfAliasLookup = {} self.working_module = None def get_entry(self, name, module=None): if module is None: m = self.modules[self.working_module] else: if module in self.modules.keys(): m = self.modules[module] else: m = None if m is None: print("Registered Modules:") for m_e in self.moduleList:
from aiddl_core.representation.symbolic import Symbolic EVAL = Symbolic("org.aiddl.eval") EVAL_REF = Symbolic("org.aiddl.eval.eval-ref") EVAL_ALL_REFS = Symbolic("org.aiddl.eval.eval-all-refs") FUNCTION_LOADER = Symbolic("org.aiddl.eval.load-function") FACTORY_LOADER = Symbolic("org.aiddl.eval.load-function-factory") CORE_LANG = Symbolic("org.aiddl.eval.core-lang") # org.aiddl.eval CALL = Symbolic("org.aiddl.eval.call") CALL_REQUEST = Symbolic("org.aiddl.eval.call-request") LAMBDA = Symbolic("org.aiddl.eval.lambda") QUOTE = Symbolic("org.aiddl.eval.quote") TYPE = Symbolic("org.aiddl.eval.type") ZIP = Symbolic("org.aiddl.eval.zip") MAP = Symbolic("org.aiddl.eval.map") FILTER = Symbolic("org.aiddl.eval.filter") REDUCE = Symbolic("org.aiddl.eval.reduce") DOMAIN = Symbolic("org.aiddl.eval.domain") EVAL_REF = Symbolic("org.aiddl.eval.eval-ref") SIGNATURE = Symbolic("org.aiddl.eval.signature") MATCHES = Symbolic("org.aiddl.eval.matches") EQUALS = Symbolic("org.aiddl.eval.equals") NOT_EQUALS = Symbolic("org.aiddl.eval.not-equals") SUBSTITUTE = Symbolic("org.aiddl.eval.substitute") GET_MATCHING_ENTRIES = Symbolic("org.aiddl.eval.get-matching-entries") FIRST = Symbolic("org.aiddl.eval.first")
from aiddl_core.container.container import Container from aiddl_core.representation.symbolic import Symbolic from aiddl_core.representation.symbolic import TRUE from aiddl_core.representation.symbolic import FALSE from aiddl_core.representation.list import List from aiddl_core.representation.variable import Variable from aiddl_core.request.request_handler import RequestHandler from aiddl_core.function.uri import EVAL import aiddl_core.function.default as dfun ASSERT = Symbolic("#assert") def run(C, evaluator, freg, verbose): n_tests = 0 n_successful = 0 rHandler = RequestHandler(C, freg) # rHandler.verbose = True for req in C.get_matching_entries(Variable(), Symbolic("#assert-request"), Variable()): request_term = req.get_value()[0] exec_module = req.get_value()[1].resolve(C) rHandler.satisfy_request(request_term, exec_module) tests = C.get_matching_entries(None, ASSERT, None)
from aiddl_core.request.if_runner import run_if from aiddl_core.request.list_runner import run_list from aiddl_core.request.init_runner import run_init from aiddl_core.request.write_runner import run_write from aiddl_core.request.call_runner import run_call from aiddl_core.request.reference_runner import run_reference_request from aiddl_core.request.match_runner import run_match from aiddl_core.request.forall_runner import run_forall from aiddl_core.request.while_runner import run_while from aiddl_core.request.loop_runner import run_loop from aiddl_core.request.create_runner import run_create from aiddl_core.request.print_runner import run_print from aiddl_core.request.stopwatch_runner import run_stopwatch IF = Symbolic("if") WRITE = Symbolic("write") CREATE = Symbolic("create") PRINT = Symbolic("print") STOPWATCH = Symbolic("stopwatch") INIT = Symbolic("init") CALL = Symbolic("call") MATCH = Symbolic("match") WHILE = Symbolic("while") FORALL = Symbolic("forall") LOOP = Symbolic("loop") class RequestHandler: def __init__(self, C, F, name="RequestHandler", verbose=False): self.C = C
from aiddl_core.representation.tuple import Tuple from aiddl_core.representation.list import List from aiddl_core.request.request_handler import RequestHandler from aiddl_core.function.eval.eval import NamedFunction from aiddl_core.function.eval.eval import LambdaFunction from aiddl_core.function.eval.eval import TypeCheckFunction from aiddl_core.function.function import InterfaceImplementation import aiddl_core.function.default as dfun import aiddl_core.function.uri as fun_uri import aiddl_core.parser.parser as parser from aiddl_core.function.uri import EVAL DEF = Symbolic("#def") class FunctionRegistry: def __init__(self): self.functions = {} self.interfaces = {} self.interface_implementations = {} def add_function(self, name, f): self.functions[name] = f for k in self.interface_implementations.keys(): self.interface_implementations[k] = filter( (name).__ne__, self.interface_implementations[k]) if isinstance(f, InterfaceImplementation): uri = f.get_interface_uri()