Fixed RET functionnality misbehaviour
This commit is contained in:
@@ -196,6 +196,19 @@ class ConceptNode(LexerNode):
|
||||
clone = ConceptNode(self.concept, self.start, self.end, self.tokens, self.source, self.underlying)
|
||||
return clone
|
||||
|
||||
def as_bag(self):
|
||||
"""
|
||||
Creates a dictionary with the useful properties of the ConceptNode
|
||||
see Concept.as_bag() for extra informations
|
||||
"""
|
||||
bag = {}
|
||||
for k, v in self.__dict__.items():
|
||||
bag[k] = v
|
||||
|
||||
# if isinstance(self.concept, Concept):
|
||||
# bag["compiled"] = self.concept.compiled
|
||||
return bag
|
||||
|
||||
|
||||
class SourceCodeNode(LexerNode):
|
||||
"""
|
||||
@@ -528,7 +541,7 @@ class CNC(CN):
|
||||
to_compare = {k: v for k, v in other.concept.compiled.items() if k != ConceptParts.BODY}
|
||||
else:
|
||||
to_compare = other.concept.compiled
|
||||
if self.compiled == to_compare: # expanded form to ease the debug
|
||||
if self.compiled == to_compare: # expanded form to ease the debug
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -23,14 +23,6 @@ from parsers.BaseParser import BaseParser
|
||||
PARSERS = ["AtomNode", "SyaNode", "Python"]
|
||||
|
||||
|
||||
# def debug(obj):
|
||||
# with open("debug.txt", "a") as f:
|
||||
# f.write(f"{obj}\n")
|
||||
|
||||
def debug(obj):
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class ParsingContext:
|
||||
"""
|
||||
@@ -185,7 +177,6 @@ class ParsingExpression:
|
||||
return hash((self.rule_name, self.elements))
|
||||
|
||||
def parse(self, parser):
|
||||
debug(self)
|
||||
# TODO : add memoization
|
||||
return self._parse(parser)
|
||||
|
||||
@@ -590,7 +581,6 @@ class StrMatch(Match):
|
||||
parser_helper.next_token(self.skip_white_space)
|
||||
return node
|
||||
|
||||
debug(f"Failed to match {self}. {token=}")
|
||||
return None
|
||||
|
||||
|
||||
@@ -811,7 +801,6 @@ class BnfConceptParserHelper:
|
||||
self.token = self.parser.parser_input.tokens[self.pos]
|
||||
|
||||
# parse
|
||||
debug(f"parsing {parsing_expression} against '{self.parser.parser_input.text}'")
|
||||
node = parsing_expression.parse(self)
|
||||
|
||||
if isinstance(node, MultiNode):
|
||||
|
||||
Reference in New Issue
Block a user