@@ -124,11 +124,11 @@ for lToken in genTokenLines(sTokenLine, dDef): # Calculate positions dPos = {} # key: iGroup, value: iToken iGroup = 0 #if iLine == 3971: # debug - # print(lToken.join(" ")) + # print(" ".join(lToken)) for i, sToken in enumerate(lToken): if sToken.startswith("(") and sToken.endswith(")"): lToken[i] = sToken[1:-1] iGroup += 1 dPos[iGroup] = i + 1 # we add 1, for we count tokens from 1 to n (not from 0) @@ -313,10 +313,11 @@ sActions = "" nPriority = -1 dAllGraph = {} sGraphName = "" iActionBlock = 0 + aRuleName = set() for i, sLine in lRule: sLine = sLine.rstrip() if "\t" in sLine: # tabulation not allowed @@ -326,11 +327,11 @@ # rules graph call m = re.match(r"@@@@GRAPH: *(\w+)", sLine.strip()) if m: sGraphName = m.group(1) if sGraphName in dAllGraph: - print("Error. Graph name " + sGraphName + " already exists.") + print("Error at line " + i + ". Graph name <" + sGraphName + "> already exists.") exit() dAllGraph[sGraphName] = [] else: print("Error. Graph name not found at line", i) exit() @@ -337,10 +338,13 @@ elif sLine.startswith("__") and sLine.endswith("__"): # new rule group m = re.match("__(\\w+)(!\\d|)__", sLine) if m: sRuleName = m.group(1) + if sRuleName in aRuleName: + print("Error at line " + i + ". Rule name <" + sRuleName + "> already exists.") + exit() iActionBlock = 1 nPriority = int(m.group(2)[1:]) if m.group(2) else -1 else: print("Syntax error in rule group: ", sLine, " -- line:", i) exit()