Fixed #43 : BnfNodeParser: I can recognize when multiple level of ISA
Fixed #44 : BnfNodeParser: I must simplify results when multiple levels of ISA Fixed #45 : Dynamic variables cannot be parsed at restart Fixed #46 : Concepts variables values are transformed into list by default Fixed #47 : SheerkaAdmin. Add min, max, mean time when restoring files
This commit is contained in:
@@ -10,6 +10,7 @@ class MultipleSuccessEvaluator(AllReturnValuesEvaluator):
|
||||
So we cannot decide whether it's a MultipleSameSuccess or not
|
||||
All parser in error will be discarded
|
||||
Cannot match if there is at least one evaluator in error
|
||||
Cannot match if there is at least one successful parser
|
||||
"""
|
||||
NAME = "MultipleSuccess"
|
||||
|
||||
@@ -25,28 +26,50 @@ class MultipleSuccessEvaluator(AllReturnValuesEvaluator):
|
||||
nb_evaluators_in_success = 0
|
||||
to_process = False
|
||||
|
||||
debugger = context.get_debugger(MultipleSuccessEvaluator.NAME, "matches")
|
||||
debugger.debug_entering(return_value=return_values)
|
||||
|
||||
for ret in return_values:
|
||||
if ret.status and ret.who.startswith(BaseParser.PREFIX):
|
||||
reason = "a successful parser found"
|
||||
debugger.debug_log(f"Failed because {reason}. ret={ret}")
|
||||
return False
|
||||
|
||||
elif ret.who.startswith(BaseEvaluator.PREFIX) and not ret.status:
|
||||
reason = "a failed evaluator found"
|
||||
debugger.debug_log(f"Failed because {reason}. ret={ret}")
|
||||
return False
|
||||
|
||||
elif ret.status and context.sheerka.isinstance(ret.body, BuiltinConcepts.REDUCE_REQUESTED):
|
||||
to_process = True
|
||||
self.eaten.append(ret)
|
||||
debugger.debug_log(f"BuiltinConcepts.REDUCE_REQUESTED is found. {to_process=}")
|
||||
|
||||
elif ret.status and ret.who.startswith(BaseEvaluator.PREFIX):
|
||||
if self.already_seen(context, ret):
|
||||
reason = "of duplicate return value"
|
||||
debugger.debug_log(f"Failed because {reason}. ret={ret}")
|
||||
return False
|
||||
nb_evaluators_in_success += 1
|
||||
self.successful_return_values.append(ret)
|
||||
self.eaten.append(ret)
|
||||
debugger.debug_log(f"Eating and keeping {ret=}. {nb_evaluators_in_success=}")
|
||||
|
||||
elif not ret.status and ret.who.startswith(BaseParser.PREFIX):
|
||||
self.eaten.append(ret)
|
||||
debugger.debug_log(f"Eating {ret=}.")
|
||||
|
||||
# else:
|
||||
# other concepts. We do not care if there are successful or not
|
||||
# They won't be part of result nor part of the parent
|
||||
# --> So they will be handled by other evaluators
|
||||
|
||||
return to_process and nb_evaluators_in_success > 1
|
||||
res = to_process and nb_evaluators_in_success > 1
|
||||
if not res:
|
||||
reason = "not to_process and nb_evaluators_in_success > 1"
|
||||
debugger.debug_log(f"Failed because '{reason}', {to_process=}, {nb_evaluators_in_success=}")
|
||||
|
||||
return res
|
||||
|
||||
def eval(self, context, return_values):
|
||||
context.log(f"{len(self.successful_return_values)} successful return values, {len(self.eaten)} item(s) eaten",
|
||||
|
||||
Reference in New Issue
Block a user