Create new type: map (dictionary) with all support for it

This commit is contained in:
Bartłomiej Pluta
2019-07-09 00:11:39 +02:00
parent a3dfae73f1
commit d23e7a1276
17 changed files with 150 additions and 29 deletions

View File

@@ -0,0 +1,11 @@
from smnp.runtime.evaluator import Evaluator, evaluate
from smnp.type.model import Type
class MapEvaluator(Evaluator):
@classmethod
def evaluator(cls, node, environment):
keys = [ evaluate(entry.key, environment).value for entry in node.children ]
values = [ evaluate(entry.value, environment).value for entry in node.children ]
return Type.map(dict(zip(keys, values)))