def transform(self, edgeql_tree, deoptimize=False, strip_builtins=True): context = Context() context.current.deoptimize = deoptimize context.current.strip_builtins = strip_builtins self._process_expr(context, edgeql_tree) nses = [] for alias, fq_name in context.current.modaliases.items(): decl = qlast.ModuleAliasDecl(module=fq_name, alias=alias) nses.append(decl) if isinstance(edgeql_tree, qlast.Statement): if deoptimize: edgeql_tree.aliases[:] = [ a for a in edgeql_tree.aliases if not isinstance(a, qlast.ModuleAliasDecl) ] else: if edgeql_tree.aliases is not None: edgeql_tree.aliases[:] = nses else: edgeql_tree.aliases = nses return edgeql_tree
def reduce_Identifier_AS_MODULE_ModuleName(self, *kids): self.val = qlast.ModuleAliasDecl( alias=kids[0].val, module='.'.join(kids[3].val))
def reduce_MODULE_ModuleName(self, *kids): self.val = qlast.ModuleAliasDecl( module='.'.join(kids[1].val))