︙ | | |
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
-
+
|
#### REGEX TRIGGER
i = s.find(" <<-")
if i == -1:
print("# Error: no condition at line " + sLineId)
return None
sRegex = s[:i].strip()
s = s[i+4:]
# JS groups positioning codes
m = re.search("@@\\S+", sRegex)
if m:
tGroups = jsconv.groupsPositioningCodeToList(sRegex[m.start()+2:])
sRegex = sRegex[:m.start()].strip()
# JS regex
m = re.search("<js>.+</js>i?", sRegex)
|
︙ | | |
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
-
+
|
else:
sCondition = None
#### iGroup / positioning
iGroup = int(m.group(2)) if m.group(2) else 0
if iGroup > nGroup:
print("# Selected group > group number in regex at line " + sIdAction)
#### ACTION
sAction = sAction[m.end():].strip()
cAction = m.group(1)
if cAction == "-":
## error
iMsg = sAction.find(" # ")
if iMsg == -1:
|
︙ | | |
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
-
+
|
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):
print("# Error in message at line " + sIdAction + ": This message looks like code. Line should begin with =")
if sAction[0:1] == "=" or cAction == "=":
if "define" in sAction and not re.search(r"define\(\\\d+ *, *\[.*\] *\)", sAction):
print("# Error in action at line " + sIdAction + ": second argument for define must be a list of strings")
sAction = prepareFunction(sAction)
sAction = sAction.replace("m.group(i[4])", "m.group("+str(iGroup)+")")
for x in re.finditer("group[(](\d+)[)]", sAction):
if int(x.group(1)) > nGroup:
|
︙ | | |
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
-
+
|
lOpt.append(sLine)
elif re.match("[ \t]*$", sLine):
pass
elif sLine.startswith("!!"):
m = zBookmark.search(sLine)
nExMk = len(m.group(0))
if sLine[nExMk:].strip():
printBookmark(nExMk-2, sLine[nExMk:].strip(), i)
printBookmark(nExMk-2, sLine[nExMk:-3].strip(), i)
elif sLine.startswith((" ", "\t")):
lRuleLine[len(lRuleLine)-1][1] += " " + sLine.strip()
else:
lRuleLine.append([i, sLine.strip()])
# generating options files
print(" parsing options...")
|
︙ | | |