Enhanced PythonEvaluator to accept concepts

This commit is contained in:
2019-11-21 11:52:15 +01:00
parent cb6be9fec7
commit 714f4f5dd0
20 changed files with 964 additions and 208 deletions
+5 -3
View File
@@ -1,4 +1,5 @@
from core.builtin_concepts import ParserResultConcept, BuiltinConcepts
import core.builtin_helpers
from core.concept import Concept, ConceptParts
from evaluators.BaseEvaluator import OneReturnValueEvaluator
import logging
@@ -47,13 +48,14 @@ class ConceptEvaluator(OneReturnValueEvaluator):
sheerka.new(BuiltinConcepts.PROPERTY_EVAL_ERROR, body=prop, concept=concept, error=res.value),
parents=[return_value])
# Evaluate body
# Returns the concept when no body
if ConceptParts.BODY not in concept.codes:
return sheerka.ret(self.name, True, concept, parents=[return_value])
# Evaluate the body otherwise
body = concept.codes[ConceptParts.BODY]
if body is None:
return None # seems weird
raise NotImplementedError("Seems weird !")
sub_context = context.push(self.name, "Evaluating body", concept)
res = self.evaluate_parsing(sheerka, sub_context, body)
@@ -61,5 +63,5 @@ class ConceptEvaluator(OneReturnValueEvaluator):
def evaluate_parsing(self, sheerka, context, parsing_result):
res = sheerka.chain_process(context, parsing_result, self.evaluation_steps)
res = sheerka.expect_one(context, res)
res = core.builtin_helpers.expect_one(context, res)
return res