Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def extern_func(self, node):
name, params, returns, newline = self.visit_children(node)
name = name.value
if isinstance(params, Token):
params = self.token_to_val(params)
if isinstance(returns, Token):
returns = self.token_to_val(returns)
from .variables import VarType
params = [(VarType._init_from_parser(params[i*2]), params[(i*2)+1]) \
for i in range(len(params or []) // 2)]
returns = [VarType._init_from_parser(r) for r in returns or []]
existing = self.top.lookup_func(name)
extern = ExternFunction(name, params, returns)
if existing:
existing.expect_signature(extern)
if not existing.finished and \
not isinstance(existing, ExternFunction):
# This is a forward-referenced function, replace references
# with our extern
mapping = {existing: extern}
Token('IDENT', 'Custom'),
]),
]),
]),
]),
]),
]),
]),
]),
]),
]),
]),
]),
]),
),
# Schema with invalid double ! modifier
(
Token('IDENT', 'Date'),
]),
]),
]),
]),
]),
]),
]),
]),
Tree('type_system_definition', [
Tree('type_extension', [
Tree('input_object_type_extension', [
Token('EXTEND', 'extend'),
Token('INPUT', 'input'),
Tree('name', [
Token('IDENT', 'FilterCharacters'),
]),
Tree('input_fields_definition', [
Tree('input_value_definition', [
Tree('name', [
Token('IDENT', 'existsSince'),
]),
Tree('type', [
Tree('named_type', [
Tree('name', [
Token('IDENT', 'Date'),
]),
]),
]),
]),
]),
]),
Token('IDENT', 'acl'),
]),
Tree('arguments', [
Tree('argument', [
Tree('name', [
Token('IDENT', 'role'),
]),
Tree('value', [
Tree('string_value', [
Token('STRING', '"can-filter"'),
]),
]),
]),
]),
]),
]),
Tree('input_fields_definition', [
def test_string_turns_list_into_empty_string(self):
h = HaxeTransformer()
metadata = '@:build(flixel.system.FlxAssets.buildFileReferences("assets", true))'
data = [Token("LONG_STRING", '"""{}"""'.format(metadata))]
output = h.string(data)
self.assertEqual("", output)
Token('IDENT', 'INACTIVE'),
]),
]),
]),
Tree('enum_value_definition', [
Tree('enum_value', [
Tree('name', [
Token('IDENT', 'SUSPENDED'),
]),
]),
]),
]),
]),
]),
]),
]),
),
Token('IDENT', 'str'),
]),
Tree('value', [
Tree('string_value', [
Token('STRING', '"test"')
]),
]),
]),
Tree('argument', [
Tree('name', [
Token('IDENT', 'int'),
]),
Tree('value', [
Tree('int_value', [
Token('SIGNED_INT', '14')
]),
]),
Token('IDENT', 'NOT_FOUND'),
]),
]),
]),
Tree('enum_value_definition', [
Tree('enum_value', [
Tree('name', [
Token('IDENT', 'ACTIVE'),
]),
]),
Tree('directives', [
Tree('directive', [
Tree('name', [
Token('IDENT', 'cache'),
]),
Tree('arguments', [
Tree('argument', [