Working on #98 : Persist attribute value when global_truth is set to true

This commit is contained in:
2021-08-03 11:26:57 +02:00
parent e69745adc8
commit c798c2c570
22 changed files with 496 additions and 106 deletions
+13 -6
View File
@@ -199,7 +199,7 @@ class SyaConceptParserHelper:
self.expected = temp
self.eat_token(first_keyword_found) # remove the first token
self.tokens.append(first_keyword_found)
self.tokens.append(first_keyword_found) # and add it to the list of tokens eaten
def is_matched(self):
return len(self.expected) == 0
@@ -554,7 +554,7 @@ class InFixToPostFix:
def nb_expected_parameters(expected):
"""
Count the number of successive variables that are expected
Count the number of successive variables that are still expected
:param expected:
:return:
"""
@@ -1228,10 +1228,10 @@ class SyaNodeParser(BaseNodeParser):
:param concept:
:return:
"""
# We only concepts that has parameter (refuse atoms)
# We only considers concepts that has parameter variables (refuse atoms)
# Bnf definitions are not supposed to be managed by this parser either
return len(
concept.get_metadata().variables) > 0 and concept.get_metadata().definition_type != DEFINITION_TYPE_BNF
return (concept.get_metadata().definition_type != DEFINITION_TYPE_BNF and
len(concept.get_metadata().parameters) > 0)
def infix_to_postfix(self, context, parser_input: ParserInput):
"""
@@ -1368,6 +1368,14 @@ class SyaNodeParser(BaseNodeParser):
concept = sheerka.new_from_template(item.concept, item.concept.key)
concept_metadata = []
for param_index in reversed(range(len(concept.get_metadata().variables))):
param_name = concept.get_metadata().variables[param_index][0]
if param_name not in concept.get_metadata().parameters:
# This is not a real concept parameter, but a concept variable
# just copy its default value
concept_metadata.append(concept.get_metadata().variables[param_index])
continue
inner_item = self.postfix_to_item(sheerka, postfixed)
if inner_item.start < start:
start = inner_item.start
@@ -1376,7 +1384,6 @@ class SyaNodeParser(BaseNodeParser):
has_unrecognized |= isinstance(inner_item, (UnrecognizedTokensNode, SourceCodeWithConceptNode)) or \
hasattr(inner_item, "has_unrecognized") and inner_item.has_unrecognized
param_name = concept.get_metadata().variables[param_index][0]
param_value = inner_item.concept if hasattr(inner_item, "concept") else \
[inner_item.return_value] if isinstance(inner_item, SourceCodeNode) else \
inner_item