Fixed memory() and RET usage
This commit is contained in:
@@ -772,8 +772,6 @@ class BaseNodeParser(BaseParser):
|
||||
|
||||
if token.type == TokenKind.STRING:
|
||||
name = token.value[1:-1] if strip_quotes else token.value
|
||||
elif token.type == TokenKind.KEYWORD:
|
||||
name = token.value.value
|
||||
else:
|
||||
name = token.value
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class ExactConceptParser(BaseParser):
|
||||
for combination in self.combinations(words):
|
||||
|
||||
concept_key = " ".join(combination)
|
||||
result = sheerka.new(concept_key) # use new(), not get() because we need a new instance
|
||||
result = sheerka.get_by_key(concept_key) # use new(), not get() because we need a new instance
|
||||
|
||||
if sheerka.isinstance(result, BuiltinConcepts.UNKNOWN_CONCEPT):
|
||||
continue
|
||||
@@ -66,6 +66,9 @@ class ExactConceptParser(BaseParser):
|
||||
continue
|
||||
|
||||
context.log(f"Recognized concept {concept}.", self.name)
|
||||
# We can ask for a new instance
|
||||
concept = sheerka.new_from_template(concept, concept.key)
|
||||
|
||||
# update the properties if needed
|
||||
for i, token in enumerate(combination):
|
||||
if token.startswith(VARIABLE_PREFIX):
|
||||
|
||||
@@ -38,6 +38,14 @@ class NamesNode(FunctionParserNode):
|
||||
def to_unrecognized(self):
|
||||
return UnrecognizedTokensNode(self.start, self.end, self.tokens).fix_source()
|
||||
|
||||
def to_str_unrecognized(self):
|
||||
token = Token(TokenKind.STRING,
|
||||
"'" + self.str_value() + "'",
|
||||
self.tokens[0].index,
|
||||
self.tokens[0].line,
|
||||
self.tokens[0].column)
|
||||
return UnrecognizedTokensNode(self.start, self.end, [token]).fix_source()
|
||||
|
||||
|
||||
@dataclass()
|
||||
class FunctionParameter:
|
||||
@@ -322,10 +330,13 @@ class FunctionParser(BaseParser):
|
||||
scn.add_node(sep.to_unrecognized())
|
||||
|
||||
res = [SourceCodeWithConceptNode(function_node.first.to_unrecognized(), function_node.last.to_unrecognized())]
|
||||
|
||||
function_name = function_node.first.str_value()
|
||||
|
||||
for param in function_node.parameters:
|
||||
if isinstance(param.value, NamesNode):
|
||||
unrecognized = param.value.to_unrecognized()
|
||||
# try to recognize concepts
|
||||
unrecognized = param.value.to_unrecognized()
|
||||
nodes_sequences = get_lexer_nodes_from_unrecognized(self.context,
|
||||
unrecognized,
|
||||
PARSERS)
|
||||
|
||||
@@ -1219,7 +1219,8 @@ class SyaNodeParser(BaseNodeParser):
|
||||
start = inner_item.start
|
||||
if inner_item.end > end:
|
||||
end = inner_item.end
|
||||
has_unrecognized |= isinstance(inner_item, (UnrecognizedTokensNode, SourceCodeWithConceptNode))
|
||||
has_unrecognized |= isinstance(inner_item, (UnrecognizedTokensNode, SourceCodeWithConceptNode)) or \
|
||||
hasattr(inner_item, "has_unrecognized") and inner_item.has_unrecognized
|
||||
|
||||
param_name = concept.metadata.variables[param_index][0]
|
||||
param_value = inner_item.concept if hasattr(inner_item, "concept") else \
|
||||
|
||||
Reference in New Issue
Block a user