Added empty string parser
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
from core.builtin_concepts import ParserResultConcept
|
||||
from core.concept import Concept, ConceptParts
|
||||
from evaluators.BaseEvaluator import OneReturnValueEvaluator
|
||||
import logging
|
||||
|
||||
from parsers.BaseParser import BaseParser
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -11,8 +14,9 @@ class ConceptEvaluator(OneReturnValueEvaluator):
|
||||
|
||||
def matches(self, context, return_value):
|
||||
return return_value.status and \
|
||||
return_value.who == "Parsers:ConceptParser" and \
|
||||
isinstance(return_value.value, Concept)
|
||||
return_value.who.startswith(BaseParser.PREFIX) and \
|
||||
isinstance(return_value.value, Concept) and \
|
||||
not isinstance(return_value.value, ParserResultConcept) # because there are specific evaluators
|
||||
|
||||
def eval(self, context, return_value):
|
||||
sheerka = context.sheerka
|
||||
@@ -27,9 +31,12 @@ class ConceptEvaluator(OneReturnValueEvaluator):
|
||||
# TODO; check pre
|
||||
# if pre is not true, return Concept with a false value
|
||||
|
||||
body = concept.codes[ConceptParts.BODY]
|
||||
if body is None:
|
||||
return None # nothing to do
|
||||
if ConceptParts.BODY in concept.codes:
|
||||
body = concept.codes[ConceptParts.BODY]
|
||||
if body is None:
|
||||
return None # nothing to do
|
||||
|
||||
return sheerka.ret(self.name, True, body.value, parents=[return_value])
|
||||
return sheerka.ret(self.name, True, body.value, parents=[return_value])
|
||||
|
||||
else:
|
||||
return sheerka.ret(self.name, True, concept, parents=[return_value])
|
||||
|
||||
Reference in New Issue
Block a user