Fixed BnfNodeParser to allow expressions like 'number hundred' when number is a group
This commit is contained in:
@@ -26,7 +26,7 @@ class SheerkaEvaluateConcept(BaseService):
|
||||
|
||||
parent = context.get_parent()
|
||||
while parent is not None:
|
||||
if parent.who == context.who and parent.obj == concept:
|
||||
if parent.who == context.who and parent.obj == concept and parent.obj.compiled == concept.compiled:
|
||||
return True
|
||||
|
||||
parent = parent.get_parent()
|
||||
@@ -147,6 +147,11 @@ class SheerkaEvaluateConcept(BaseService):
|
||||
|
||||
def resolve(self, context, to_resolve, current_prop, current_concept, force_evaluation):
|
||||
|
||||
def get_path(context_, prop_name):
|
||||
prefix = context_.path if hasattr(context_, "path") else "<N/A>"
|
||||
value = prop_name.name if isinstance(current_prop, ConceptParts) else prop_name
|
||||
return prefix + "." + value
|
||||
|
||||
if isinstance(to_resolve, DoNotResolve):
|
||||
return to_resolve.value
|
||||
|
||||
@@ -161,12 +166,14 @@ class SheerkaEvaluateConcept(BaseService):
|
||||
sub_context.add_values(return_values=ret_val)
|
||||
return ret_val.body
|
||||
|
||||
desc = f"Evaluating {current_prop} (concept={current_concept})"
|
||||
path = get_path(context, current_prop)
|
||||
desc = f"Evaluating {path} (concept={current_concept})"
|
||||
context.log(desc, self.NAME)
|
||||
with context.push(BuiltinConcepts.EVALUATING_CONCEPT,
|
||||
current_prop,
|
||||
desc=desc,
|
||||
obj=current_concept) as sub_context:
|
||||
obj=current_concept,
|
||||
path=path) as sub_context:
|
||||
|
||||
if force_evaluation:
|
||||
sub_context.local_hints.add(BuiltinConcepts.EVAL_BODY_REQUESTED)
|
||||
|
||||
@@ -76,6 +76,7 @@ class SheerkaSetsManager(BaseService):
|
||||
self.sheerka.new(BuiltinConcepts.CONCEPT_ALREADY_IN_SET, body=concept, concept_set=concept_set))
|
||||
|
||||
self.sets.put(concept_set.id, concept.id)
|
||||
self.concepts_in_set.delete(concept_set.id)
|
||||
return self.sheerka.ret(self.NAME, True, self.sheerka.new(BuiltinConcepts.SUCCESS))
|
||||
|
||||
def add_concepts_to_set(self, context, concepts, concept_set):
|
||||
@@ -95,6 +96,7 @@ class SheerkaSetsManager(BaseService):
|
||||
concept_set=concept_set)
|
||||
else:
|
||||
body = self.sheerka.new(BuiltinConcepts.SUCCESS)
|
||||
self.concepts_in_set.delete(concept_set.id)
|
||||
|
||||
return self.sheerka.ret(self.NAME, len(already_in_set) != len(concepts), body)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user