From 15f5de6958ca46bbc8e2863db4ce8788690aa7c0 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sun, 14 Jun 2020 22:28:09 +0200 Subject: [PATCH] Raise exception, will fix it later --- relational/optimizations.py | 35 ----------------------------------- relational/optimizer.py | 1 + 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/relational/optimizations.py b/relational/optimizations.py index 9e05bef..51819a7 100644 --- a/relational/optimizations.py +++ b/relational/optimizations.py @@ -64,41 +64,6 @@ def find_duplicates(node, dups=None): dups[str(node)] = node - -def replace_leaves(node, context): - ''' - Node is a parsed tree - context is a dictionary containing - parsed trees as values. - - If a name appearing in node appears - also in context, the parse tree is - modified to replace the node with the - subtree found in context. - ''' - if node.kind == parser.UNARY: - replace_leaves(node.child, context) - elif node.kind == parser.BINARY: - replace_leaves(node.left, context) - replace_leaves(node.right, context) - elif node.name in context: - replace_node(node, context[node.name]) - - -def replace_node(replace, replacement): - '''This function replaces "replace" node with the node "with", - the father of the node will now point to the with node''' - replace.name = replacement.name - replace.kind = replacement.kind - - if replace.kind == parser.UNARY: - replace.child = replacement.child - replace.prop = replacement.prop - elif replace.kind == parser.BINARY: - replace.right = replacement.right - replace.left = replacement.left - - def duplicated_select(n: parser.Node) -> Tuple[parser.Node, int]: '''This function locates and deletes things like σ a ( σ a(C)) and the ones like σ a ( σ b(C)) diff --git a/relational/optimizer.py b/relational/optimizer.py index 7a4c6d7..8976f31 100644 --- a/relational/optimizer.py +++ b/relational/optimizer.py @@ -36,6 +36,7 @@ def optimize_program(code, rels: Dict[str, Relation]): Optimize an entire program, composed by multiple expressions and assignments. ''' + raise NotImplementedError() lines = code.split('\n') context = {}