Index: compile_rules_graph.py ================================================================== --- compile_rules_graph.py +++ compile_rules_graph.py @@ -236,11 +236,11 @@ nPriority = dOptPriority.get(sOption, 4) # valid action? m = re.search(r"(?P[-=~/!>])(?P-?\d+\.?|)(?P:\.?-?\d+|)(?P:|)>>", sAction) if not m: - print(" # Error. No action found at: ", sActionId) + print("\n# Error. No action found at: ", sActionId) return None # Condition sCondition = sAction[:m.start()].strip() if sCondition: @@ -262,11 +262,11 @@ if not m.group("start"): iStartAction = 1 iEndAction = 0 else: if cAction != "-" and (m.group("start").endswith(".") or m.group("end").startswith(":.")): - print(" # Error. Wrong selection on tokens.", sActionId) + print("\n# Error. Wrong selection on tokens.", sActionId) return None if m.group("start").endswith("."): cStartLimit = ">" iStartAction = int(m.group("start").rstrip(".")) if not m.group("end"): @@ -288,11 +288,11 @@ ## error iMsg = sAction.find(" # ") if iMsg == -1: sMsg = "# Error. Error message not found." sURL = "" - print(sMsg + " Action id: " + sActionId) + print("\n" + sMsg + " Action id: " + sActionId) else: sMsg = sAction[iMsg+3:].strip() sAction = sAction[:iMsg].strip() sURL = "" mURL = re.search("[|] *(https?://.*)", sMsg) @@ -311,11 +311,11 @@ if cAction == ">": ## no action, break loop if condition is False return [sOption, sCondition, cAction, ""] if not sAction and cAction != "!": - print("# Error in action at line " + sActionId + ": This action is empty.") + print("\n# Error in action at line <" + sActionId + ">: This action is empty.") if sAction[0:1] != "=" and cAction != "=": checkIfThereIsCode(sAction, sActionId) if cAction == "-": @@ -323,29 +323,36 @@ if sAction[0:1] == "=": sAction = createFunction("sugg", sAction, True) elif sAction.startswith('"') and sAction.endswith('"'): sAction = sAction[1:-1] if not sMsg: - print("# Error in action at line " + sActionId + ": The message is empty.") + print("\n# Error in action at line <" + sActionId + ">: The message is empty.") return [sOption, sCondition, cAction, sAction, iStartAction, iEndAction, cStartLimit, cEndLimit, bCaseSensitivity, nPriority, sMsg, sURL] if cAction == "~": ## text processor if sAction[0:1] == "=": sAction = createFunction("tp", sAction, True) elif sAction.startswith('"') and sAction.endswith('"'): sAction = sAction[1:-1] + elif sAction not in "␣*_": + nToken = sAction.count("|") + 1 + if iStartAction > 0 and iEndAction > 0: + if (iEndAction - iStartAction + 1) != nToken: + print("\n# Error in action at line <" + sActionId + ">: numbers of modified tokens modified.") + elif iStartAction < 0 or iEndAction < 0 and iStartAction != iEndAction: + print("\n# Warning in action at line <" + sActionName + ">: rewriting with possible token position modified.") return [sOption, sCondition, cAction, sAction, iStartAction, iEndAction, bCaseSensitivity] if cAction in "!/": ## tags return [sOption, sCondition, cAction, sAction, iStartAction, iEndAction] if cAction == "=": ## disambiguator if "define(" in sAction and not re.search(r"define\(\\-?\d+ *, *\[.*\] *\)", sAction): - print("# Error in action at line " + sActionId + ": second argument for must be a list of strings") + print("\n# Error in action at line <" + sActionId + ">: second argument for must be a list of strings") sAction = createFunction("da", sAction) return [sOption, sCondition, cAction, sAction] - print(" # Unknown action.", sActionId) + print("\n# Unknown action.", sActionId) return None def make (lRule, sLang, dDef, dDecl, dOptPriority): "compile rules, returns a dictionary of values"