Index: compile_rules.py ================================================================== --- compile_rules.py +++ compile_rules.py @@ -182,11 +182,12 @@ cWordLimitRight = m.group('borders_and_case')[2] sOption = m.group('option')[1:] if m.group('option') else False if m.group('ruleid'): sRuleId = m.group('ruleid')[1:-1] if sRuleId in RULESET: - print("# Warning. Several rules have the same id: " + sRuleId) + print("# Error. Several rules have the same id: " + sRuleId) + exit() RULESET.add(sRuleId) nPriority = dOptPriority.get(sOption, 4) if m.group('priority'): nPriority = int(m.group('priority')[1:]) s = s[m.end(0):] @@ -267,11 +268,11 @@ #### PARSE ACTIONS lActions = [] nAction = 1 for sAction in s.split(" <<- "): - t = createAction(sLineId + "_" + str(nAction), sAction, nGroup) + t = createAction(sRuleId + "_" + str(nAction), sAction, nGroup) nAction += 1 if t: lActions.append(t) if not lActions: return None @@ -290,17 +291,17 @@ #### CONDITION sCondition = sAction[:m.start()].strip() if sCondition: sCondition = prepareFunction(sCondition) - FUNCTIONS.append(("c"+sIdAction, sCondition)) + FUNCTIONS.append(("c_"+sIdAction, sCondition)) for x in re.finditer("[.](?:group|start|end)[(](\d+)[)]", sCondition): if int(x.group(1)) > nGroup: print("# Error in groups in condition at line " + sIdAction + " ("+str(nGroup)+" groups only)") if ".match" in sCondition: print("# Error. JS compatibility. Don't use .match() in condition, use .search()") - sCondition = "c"+sIdAction + sCondition = "c_"+sIdAction else: sCondition = None #### iGroup / positioning iGroup = int(m.group(2)) if m.group(2) else 0 @@ -320,15 +321,15 @@ if mURL: sURL = mURL.group(1).strip() sMsg = sMsg[:mURL.start(0)].strip() if sMsg[0:1] == "=": sMsg = prepareFunction(sMsg[1:]) - FUNCTIONS.append(("m"+sIdAction, sMsg)) + FUNCTIONS.append(("m_"+sIdAction, sMsg)) for x in re.finditer("group[(](\d+)[)]", sMsg): if int(x.group(1)) > nGroup: print("# Error in groups in message at line " + sIdAction + " ("+str(nGroup)+" groups only)") - sMsg = "=m"+sIdAction + sMsg = "=m_"+sIdAction else: for x in re.finditer(r"\\(\d+)", sMsg): if int(x.group(1)) > nGroup: print("# Error in groups in message at line " + sIdAction + " ("+str(nGroup)+" groups only)") if re.search("[.]\\w+[(]", sMsg): @@ -348,39 +349,39 @@ print("# Error in groups in replacement at line " + sIdAction + " ("+str(nGroup)+" groups only)") if re.search("[.]\\w+[(]", sAction): print("# Error in action at line " + sIdAction + ": This action looks like code. Line should begin with =") if cAction == "-": - ## error detected + ## error detected --> suggestion if not sAction: print("# Error in action at line " + sIdAction + ": This action is empty.") if sAction[0:1] == "=": - FUNCTIONS.append(("s"+sIdAction, sAction[1:])) - sAction = "=s"+sIdAction + FUNCTIONS.append(("s_"+sIdAction, sAction[1:])) + sAction = "=s_"+sIdAction elif sAction.startswith('"') and sAction.endswith('"'): sAction = sAction[1:-1] if not sMsg: print("# Error in action at line " + sIdAction + ": the message is empty.") return [sCondition, cAction, sAction, iGroup, sMsg, sURL] elif cAction == "~": - ## text preprocessor + ## text processor if not sAction: print("# Error in action at line " + sIdAction + ": This action is empty.") if sAction[0:1] == "=": - FUNCTIONS.append(("p"+sIdAction, sAction[1:])) - sAction = "=p"+sIdAction + FUNCTIONS.append(("p_"+sIdAction, sAction[1:])) + sAction = "=p_"+sIdAction elif sAction.startswith('"') and sAction.endswith('"'): sAction = sAction[1:-1] return [sCondition, cAction, sAction, iGroup] elif cAction == "=": ## disambiguator if sAction[0:1] == "=": sAction = sAction[1:] if not sAction: print("# Error in action at line " + sIdAction + ": This action is empty.") - FUNCTIONS.append(("d"+sIdAction, sAction)) - sAction = "d"+sIdAction + FUNCTIONS.append(("d_"+sIdAction, sAction)) + sAction = "d_"+sIdAction return [sCondition, cAction, sAction] elif cAction == ">": ## no action, break loop if condition is False return [sCondition, cAction, ""] else: