Minor code enhancements
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from parsers.BaseParser import BaseParser
|
||||
from parsers.ConceptLexerParser import UnrecognizedTokensNode, ConceptNode
|
||||
from parsers.ConceptLexerParser import ConceptNode
|
||||
from parsers.MultipleConceptsParser import MultipleConceptsParser
|
||||
from parsers.PythonParser import PythonParser
|
||||
|
||||
multiple_concepts_parser = MultipleConceptsParser()
|
||||
|
||||
|
||||
class PythonWithConceptsParser(BaseParser):
|
||||
def __init__(self, **kwargs):
|
||||
@@ -22,16 +25,10 @@ class PythonWithConceptsParser(BaseParser):
|
||||
if not sheerka.isinstance(text, BuiltinConcepts.PARSER_RESULT):
|
||||
return None
|
||||
|
||||
if not text.parser == multiple_concepts_parser:
|
||||
return None
|
||||
|
||||
nodes = text.body
|
||||
if not isinstance(nodes, list):
|
||||
return None
|
||||
|
||||
if len(nodes) == 0:
|
||||
return None
|
||||
|
||||
if not isinstance(nodes[0], (ConceptNode, UnrecognizedTokensNode)):
|
||||
return None
|
||||
|
||||
source = ""
|
||||
to_parse = ""
|
||||
identifiers = {}
|
||||
@@ -107,7 +104,6 @@ class PythonWithConceptsParser(BaseParser):
|
||||
if id(concept) in self.identifiers:
|
||||
return self.identifiers[id(concept)]
|
||||
|
||||
|
||||
identifier = "__C__" + (concept.key or concept.name)
|
||||
if concept.id:
|
||||
identifier += "__" + concept.id
|
||||
|
||||
Reference in New Issue
Block a user