Index: gc_core/py/lang_core/gc_engine.py ================================================================== --- gc_core/py/lang_core/gc_engine.py +++ gc_core/py/lang_core/gc_engine.py @@ -603,12 +603,14 @@ self.dTokenPos = { dToken["nStart"]: dToken for dToken in self.lToken if dToken["sType"] != "INFO" } if bDebug: print("UPDATE:") print(self) - def _getNextPointers (self, dToken, dGraph, iNode1, dNode, bKeep=False, bDebug=False): + def _getNextPointers (self, dToken, dGraph, dPointer, bDebug=False): "generator: return nodes where “values” match arcs" + dNode = dPointer["dNode"] + iNode1 = dPointer["iNode1"] bTokenFound = False # token value if dToken["sValue"] in dNode: if bDebug: print(" MATCH:", dToken["sValue"]) @@ -722,16 +724,17 @@ elif dToken["sType"] in sMeta: if bDebug: print(" MATCH: *" + sMeta) yield { "iNode1": iNode1, "dNode": dGraph[dNode[""][sMeta]] } bTokenFound = True - if bKeep and not bTokenFound: - yield { "iNode1": iNode1, "dNode": dNode, "bKeep": True } + if "bKeep" in dPointer and not bTokenFound: + yield dPointer # JUMP # Warning! Recurssion! if "<>" in dNode: - yield from self._getNextPointers(self, dToken, dGraph, iNode1, dGraph[dNode["<>"]], True, bDebug) + dPointer2 = { "iNode1": iNode1, "dNode": dGraph[dNode["<>"]], "bKeep": True } + yield from self._getNextPointers(dToken, dGraph, dPointer2, bDebug) def parse (self, dGraph, dPriority, sCountry="${country_default}", dOptions=None, bShowRuleId=False, bDebug=False, bContext=False): "parse tokens from the text and execute actions encountered" dOpt = _dOptions if not dOptions else dOptions @@ -741,14 +744,14 @@ if bDebug: print("TOKEN:", dToken["sValue"]) # check arcs for each existing pointer lNextPointer = [] for dPointer in lPointer: - lNextPointer.extend(self._getNextPointers(dToken, dGraph, dPointer["iNode1"], dPointer["dNode"], dPointer.get("bKeep", False), bDebug)) + lNextPointer.extend(self._getNextPointers(dToken, dGraph, dPointer, bDebug)) lPointer = lNextPointer # check arcs of first nodes - lPointer.extend(self._getNextPointers(dToken, dGraph, iToken, dGraph[0], False, bDebug)) + lPointer.extend(self._getNextPointers(dToken, dGraph, { "iNode1": iToken, "dNode": dGraph[0] }, bDebug)) # check if there is rules to check for each pointer for dPointer in lPointer: #if bDebug: # print("+", dPointer) if "" in dPointer["dNode"]: