Create evaluator for function call
This commit is contained in:
@@ -55,7 +55,7 @@ def types(args):
|
||||
if arg.type == Type.LIST:
|
||||
output.append(listTypes(arg.value, []))
|
||||
else:
|
||||
output.append(arg.type.name)
|
||||
output.append(arg.type.name.lower())
|
||||
return f"({', '.join(output)})"
|
||||
|
||||
|
||||
@@ -64,5 +64,5 @@ def listTypes(l, output=[]):
|
||||
if item.type == Type.LIST:
|
||||
output.append(listTypes(item.value, []))
|
||||
else:
|
||||
output.append(item.type.name)
|
||||
return f"LIST<{'|'.join(set(output))}>"
|
||||
output.append(item.type.name.lower())
|
||||
return f"{Type.LIST.name.lower()}<{'|'.join(set(output))}>"
|
||||
@@ -92,14 +92,14 @@ def allTypes():
|
||||
def ofTypes(*types):
|
||||
def check(value):
|
||||
return value.type in types
|
||||
return Matcher(None, check, f"<{'|'.join([t.name for t in types])}>")
|
||||
return Matcher(None, check, f"<{', '.join([t.name.lower() for t in types])}>")
|
||||
|
||||
|
||||
def listOf(*types):
|
||||
def check(value):
|
||||
return len([item for item in value.value if not item.type in types]) == 0
|
||||
|
||||
return Matcher(Type.LIST, check, f"{Type.LIST.name}<{'|'.join([t.name for t in types])}>")
|
||||
return Matcher(Type.LIST, check, f"{Type.LIST.name.lower()}<{', '.join([t.name.lower() for t in types])}>")
|
||||
|
||||
|
||||
def listMatches(*pattern):
|
||||
|
||||
Reference in New Issue
Block a user