Improve support for functions #1

This commit is contained in:
Bartłomiej Pluta
2019-07-04 02:09:24 +02:00
parent c8ff5ce38f
commit 6390ac20de
31 changed files with 514 additions and 328 deletions

17
smnp/type/value.py Normal file
View File

@@ -0,0 +1,17 @@
class Value:
def __init__(self, objectType, value):
self.value = value
if type(value) == objectType.value[0]:
self.type = objectType
else:
raise RuntimeError(f"Invalid type '{objectType.name}' for value '{value}'")
def stringify(self):
return self.type.stringify(self.value)
def __str__(self):
return f"{self.type.name}({self.stringify()})"
def __repr__(self):
return self.__str__()