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 @@ -274,11 +274,10 @@ return xErr def _createTokenDictError (lToken, sSentence, sSentence0, sRepl, iFirstToken, nStart, nEnd, sLineId, sRuleId, bUppercase, sMsg, sURL, bIdRule, sOption, bContext): "error as a dictionary" - print(locals()) dErr = {} dErr["nStart"] = nStart dErr["nEnd"] = nEnd dErr["sLineId"] = sLineId dErr["sRuleId"] = sRuleId @@ -672,11 +671,11 @@ def __init__ (self, sSentence, sSentence0, iStart): self.sSentence = sSentence self.sSentence0 = sSentence0 self.iStart = iStart - self.lToken = list(_oTokenizer.genTokens(sSentence)) + self.lToken = list(_oTokenizer.genTokens(sSentence, True)) def _getNextMatchingNodes (self, dToken, dNode): "generator: return nodes where “values” match arcs" # token value if dToken["sValue"] in dNode: @@ -729,11 +728,11 @@ if not bValid: del lPointer[i] lPointer.extend(lNewPointer) # check arcs of first nodes for dNode in self._getNextMatchingNodes(dToken, dGraph[0]): - lPointer.append({"nOffset": 0, "dNode": dNode}) + lPointer.append({"nOffset": dToken["i"], "dNode": dNode}) # check if there is rules to check for each pointer for dPointer in lPointer: if "" in dPointer["dNode"]: bHasChanged, errs = self._executeActions(dPointer["dNode"][""], dPointer["nOffset"], dPriority, dOpt, bIdRule, bContext) dErr.update(errs) @@ -742,11 +741,11 @@ if dErr: print(dErr) return (bChange, dErr) def _executeActions (self, dNode, nTokenOffset, dPriority, dOpt, bIdRule, bContext): - print(locals()) + #print(locals()) dErrs = {} bChange = False for sLineId, nextNodeKey in dNode.items(): for sRuleId in dGraph[nextNodeKey]: print(sRuleId) @@ -757,14 +756,16 @@ bCondMemo = not sFuncCond or globals()[sFuncCond](self, sCountry, bCondMemo) if bCondMemo: if cActionType == "-": # grammar error print("-") - nErrorStart = self.iStart + self.lToken[eAct[0]]["nStart"] - nErrorEnd = self.iStart + self.lToken[eAct[1]]["nEnd"] + nTokenErrorStart = nTokenOffset + eAct[0] + nTokenErrorEnd = nTokenOffset + eAct[1] + nErrorStart = self.iStart + self.lToken[nTokenErrorStart]["nStart"] + nErrorEnd = self.iStart + self.lToken[nTokenErrorEnd]["nEnd"] if nErrorStart not in dErrs or eAct[2] > dPriority[nErrorStart]: - dErrs[nErrorStart] = _createTokenError(self.lToken, self.sSentence, self.sSentence0, sWhat, eAct[0], nErrorStart, nErrorEnd, sLineId, sRuleId, True, eAct[3], eAct[4], bIdRule, "notype", bContext) + dErrs[nErrorStart] = _createTokenError(self.lToken, self.sSentence, self.sSentence0, sWhat, nTokenErrorStart, nErrorStart, nErrorEnd, sLineId, sRuleId, True, eAct[3], eAct[4], bIdRule, "notype", bContext) dPriority[nErrorStart] = eAct[2] elif cActionType == "~": # text processor print("~") self._rewrite(sWhat, nErrorStart, nErrorEnd)