Create evaluators for literals, list and identifier nodes

This commit is contained in:
Bartłomiej Pluta
2019-07-08 13:39:07 +02:00
parent fd9f240ce5
commit 6e42ac0f91
10 changed files with 166 additions and 53 deletions

View File

@@ -1,10 +1,13 @@
from smnp.error.runtime import RuntimeException
from smnp.runtime.evaluator import Evaluator
def evaluateIdentifier(identifier, environment):
try:
value = environment.findVariable(identifier.identifier)
return value
except RuntimeException as e:
e.pos = identifier.pos
raise e
class IdentifierEvaluator(Evaluator):
@classmethod
def evaluator(cls, node, environment):
try:
return environment.findVariable(node.value)
except RuntimeException as e:
e.pos = node.pos
raise e