Create evaluator for function call

This commit is contained in:
Bartłomiej Pluta
2019-07-08 14:10:10 +02:00
parent 6e42ac0f91
commit 1e634180d6
10 changed files with 81 additions and 62 deletions

View File

@@ -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))}>"

View File

@@ -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):