Index: compile_rules_graph.py ================================================================== --- compile_rules_graph.py +++ compile_rules_graph.py @@ -123,10 +123,12 @@ if aAction: dACTIONS[sActionId] = aAction lResult = list(lToken) lResult.extend(["##"+str(iLine), sActionId]) yield lResult + else: + print(" # Error on action at line:", iLine) def changeReferenceToken (sText, dPos): "change group reference in with values in " for i in range(len(dPos), 0, -1): @@ -156,14 +158,13 @@ m = re.match("/(\\w+)/", sAction) if m: sOption = m.group(1) sAction = sAction[m.end():].strip() # valid action? - m = re.search(r"(?P[-~=/>])(?P\d+|)(?P:\d+|)>>", sAction) + m = re.search(r"(?P[-~=/>])(?P\d+\.?|)(?P:\.?\d+|)>>", sAction) if not m: print(" # Error. No action found at: ", sActionId) - print(" ==", sAction, "==") return None # Condition sCondition = sAction[:m.start()].strip() if sCondition: sCondition = prepareFunction(sCondition) @@ -178,12 +179,18 @@ sAction = changeReferenceToken(sAction, dPos) if not m.group("start"): iStartAction = 1 iEndAction = 0 else: - iStartAction = int(m.group("start")) - iEndAction = int(m.group("end")[1:]) if m.group("end") else iStartAction + if cAction != "-" and (m.group("start").endswith(".") or m.group("end").startswith(":.")): + print(" # Error. Wrong selection on tokens.", sActionId) + return None + iStartAction = int(m.group("start")) if not m.group("start").endswith(".") else int("-"+m.group("start")[:-1]) + if not m.group("end"): + iEndAction = iStartAction + else: + iEndAction = int(m.group("end")[1:]) if not m.group("end").startswith(":.") else int("-" + m.group("end")[2:]) if dPos and m.group("start"): try: iStartAction = dPos[iStartAction] if iEndAction: iEndAction = dPos[iEndAction] @@ -260,11 +267,11 @@ sAction = prepareFunction(sAction) dFUNCTIONS["_g_d_"+sActionId] = sAction sAction = "_g_d_"+sActionId return [sOption, sCondition, cAction, sAction] else: - print("# Unknown action at line " + sActionId) + print(" # Unknown action.", sActionId) return None def make (lRule, dDef, sLang, bJavaScript): "compile rules, returns a dictionary of values" 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 @@ -749,15 +749,15 @@ if not sOption or dOptions.get(sOption, False): bCondMemo = not sFuncCond or globals()[sFuncCond](self.lToken, nTokenOffset, nLastToken, sCountry, bCondMemo, self.dTags, self.sSentence, self.sSentence0) if bCondMemo: if cActionType == "-": # grammar error - nTokenErrorStart = nTokenOffset + eAct[0] + nTokenErrorStart = nTokenOffset + abs(eAct[0]) if "bImmune" not in self.lToken[nTokenErrorStart]: - nTokenErrorEnd = (nTokenOffset + eAct[1]) if eAct[1] else nLastToken - nErrorStart = self.nOffsetWithinParagraph + self.lToken[nTokenErrorStart]["nStart"] - nErrorEnd = self.nOffsetWithinParagraph + self.lToken[nTokenErrorEnd]["nEnd"] + nTokenErrorEnd = (nTokenOffset + abs(eAct[1])) if eAct[1] else nLastToken + nErrorStart = self.nOffsetWithinParagraph + (self.lToken[nTokenErrorStart]["nStart"] if eAct[0] >= 0 else self.lToken[nTokenErrorStart]["nStart"]) + nErrorEnd = self.nOffsetWithinParagraph + (self.lToken[nTokenErrorEnd]["nEnd"] if eAct[1] >= 0 else self.lToken[nTokenErrorEnd]["nStart"]) if nErrorStart not in self.dError or eAct[2] > dPriority.get(nErrorStart, -1): self.dError[nErrorStart] = self._createError(sWhat, nTokenOffset, nTokenErrorStart, nErrorStart, nErrorEnd, sLineId, sRuleId, True, eAct[3], eAct[4], bShowRuleId, "notype", bContext) dPriority[nErrorStart] = eAct[2] if bDebug: print(" NEW_ERROR:", self.dError[nErrorStart], "\n ", dRule[sRuleId]) Index: gc_lang/fr/rules.grx ================================================================== --- gc_lang/fr/rules.grx +++ gc_lang/fr/rules.grx @@ -2694,11 +2694,11 @@ !!!! Apostrophe manquante (2) !! __typo_apostrophe_manquante_audace__ [L|D|S|N|C|J|M|T|Ç] ~^[aeéiouhAEÉIOUHyîèêôûYÎÈÊÔÛ] - <<- /mapos/ space_after(\2, 1, 1) -2>> =\2+"’" # Il manque peut-être une apostrophe. + <<- /mapos/ space_after(\2, 1, 1) -2:.3>> =\2+"’" # Il manque peut-être une apostrophe. TEST: __mapos__ {{L }}opinion des gens, elle s’en moquait.