Added empty string parser
This commit is contained in:
@@ -25,6 +25,7 @@ class BuiltinConcepts(Enum):
|
||||
PARSING = 16 # activated during the parsing. It contains the text to parse
|
||||
AFTER_PARSING = 17 # activated when the parsing process seems to be finished
|
||||
CONCEPT_ALREADY_DEFINED = 18 # when you try to add the same concept twice
|
||||
NOP = 19 # no operation concept. Does nothing
|
||||
|
||||
|
||||
"""
|
||||
|
||||
+7
-2
@@ -208,7 +208,8 @@ class Sheerka(Concept):
|
||||
return result
|
||||
|
||||
def process(self, context, return_values, contextual_concepts=None):
|
||||
log.debug("Evaluating parsing result.")
|
||||
contextual_concepts_values = [c.value for c in contextual_concepts] if contextual_concepts else []
|
||||
log.debug(f"Processing parsing result. context concept={contextual_concepts_values}")
|
||||
|
||||
# return_values must be a list
|
||||
if not isinstance(return_values, list):
|
||||
@@ -317,8 +318,12 @@ class Sheerka(Concept):
|
||||
"""
|
||||
for part_key in ConceptParts:
|
||||
source = getattr(concept, part_key.value)
|
||||
if source is None or source == "":
|
||||
if source is None or not isinstance(source, str) or source == "":
|
||||
|
||||
# the only sources that I am sure to parse are strings
|
||||
# I refuse empty strings for performance, I don't want to handle useless NOPConcepts
|
||||
continue
|
||||
|
||||
ret_val = self.expect_one(context, self.parse(context, source))
|
||||
concept.codes[part_key] = ret_val
|
||||
|
||||
|
||||
Reference in New Issue
Block a user