def reduce_USING_Identifier_BaseStringConstant(self, *kids): lang = _parse_language(kids[1]) code = kids[2].val.value self.val = qlast.FunctionCode(language=lang, code=code)
def _process_function_body(self, block, *, optional_using: bool = False): props = {} commands = [] code = None nativecode = None language = qlast.Language.EdgeQL from_expr = False from_function = None for node in block.val: if isinstance(node, qlast.FunctionCode): if node.from_function: if from_function is not None: raise EdgeQLSyntaxError( 'more than one USING FUNCTION clause', context=node.context) from_function = node.from_function language = qlast.Language.SQL elif node.nativecode: if code is not None or nativecode is not None: raise EdgeQLSyntaxError( 'more than one USING <code> clause', context=node.context) nativecode = node.nativecode language = node.language elif node.code: if code is not None or nativecode is not None: raise EdgeQLSyntaxError( 'more than one USING <code> clause', context=node.context) code = node.code language = node.language else: # USING SQL EXPRESSION from_expr = True language = qlast.Language.SQL else: commands.append(node) if (nativecode is None and code is None and from_function is None and not from_expr and not optional_using): raise EdgeQLSyntaxError('missing a USING clause', context=block.context) else: if from_expr and (from_function or code): raise EdgeQLSyntaxError( 'USING SQL EXPRESSION is mutually exclusive with other ' 'USING variants', context=block.context) props['code'] = qlast.FunctionCode( language=language, from_function=from_function, from_expr=from_expr, code=code, ) props['nativecode'] = nativecode if commands: props['commands'] = commands return props
def reduce_USING_ParenExpr(self, *kids): lang = qlast.Language.EdgeQL self.val = qlast.FunctionCode(language=lang, nativecode=kids[1].val)