Enable basic support for evaluating float types

This commit is contained in:
Bartłomiej Pluta
2019-07-25 13:37:31 +02:00
parent 6dc503ba86
commit b126f83824
8 changed files with 64 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ from smnp.type.value import Value
class Type(Enum):
INTEGER = (int, lambda x: str(x))
FLOAT = (float, lambda x: str(x))
STRING = (str, lambda x: x)
LIST = (list, lambda x: f"[{', '.join([e.stringify() for e in x])}]")
MAP = (dict, lambda x: '{' + ', '.join(f"'{k.stringify()}' -> '{v.stringify()}'" for k, v in x.items()) + '}')
@@ -25,6 +26,10 @@ class Type(Enum):
def integer(value):
return Value(Type.INTEGER, value, {})
@staticmethod
def float(value):
return Value(Type.FLOAT, value, {})
@staticmethod
def string(value):
return Value(Type.STRING, value, {