Update wmllint calls to parse_macroref (#7662)

Fixup for #7561.
This commit is contained in:
Slayer95 2023-05-30 11:03:20 -05:00 committed by GitHub
parent b2f95d6241
commit 81014cc0c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2394,38 +2394,39 @@ to be called on their own".format(filename, num))
# this here rather than hack_syntax so the character can be
# recognized.
if macname == 'LOYAL_UNIT':
(args, optional_args, brack, paren) = parse_macroref(0, leadmac.string)
if len(args) == 7:
(args, optional_args, is_unfinished) = parse_macroref(0, leadmac.string)
if len(args) == 6:
lines[i] = lines[i].replace('{LOYAL_UNIT', '{NAMED_LOYAL_UNIT', 1)
# Auto-recognize the people in the {NAMED_*UNIT} macros.
if re.match(r'NAMED_[A-Z_]*UNIT$', macname):
(args, optional_args, brack, paren) = parse_macroref(0, leadmac.string)
if len(args) >= 7 and \
re.match(r'([0-9]+|[^\s]*\$[^\s]*side[^\s]*|{[^\s]*SIDE[^\s]*})$', args[1]) and \
re.match(r'([0-9]+|[^\s]*\$[^\s]*x[^\s]*|{[^\s]*X[^\s]*})$', args[3]) and \
re.match(r'([0-9]+|[^\s]*\$[^\s]*y[^\s]*|{[^\s]*Y[^\s]*})$', args[4]) and \
len(args[5]) > 0:
present.append(args[5])
(args, optional_args, is_unfinished) = parse_macroref(0, leadmac.string)
if len(args) >= 6 and \
re.match(r'([0-9]+|[^\s]*\$[^\s]*side[^\s]*|{[^\s]*SIDE[^\s]*})$', args[0]) and \
re.match(r'([0-9]+|[^\s]*\$[^\s]*x[^\s]*|{[^\s]*X[^\s]*})$', args[2]) and \
re.match(r'([0-9]+|[^\s]*\$[^\s]*y[^\s]*|{[^\s]*Y[^\s]*})$', args[3]) and \
len(args[4]) > 0:
present.append(args[4])
elif macname == 'RECALL':
(args, optional_args, brack, paren) = parse_macroref(0, leadmac.string)
if len(args) == 2 and brack == 0:
present.append(args[1])
(args, optional_args, is_unfinished) = parse_macroref(0, leadmac.string)
if len(args) == 1 and not is_unfinished:
present.append(args[0])
elif macname == 'RECALL_XY':
(args, optional_args, brack, paren) = parse_macroref(0, leadmac.string)
if len(args) == 4:
present.append(args[1])
(args, optional_args, is_unfinished) = parse_macroref(0, leadmac.string)
if len(args) == 3:
present.append(args[0])
elif macname == 'CLEAR_VARIABLE':
(args, optional_args, brack, paren) = parse_macroref(0, leadmac.string)
(args, optional_args, is_unfinished) = parse_macroref(0, leadmac.string)
# having CLEAR_VARIABLE on a line and its arguments in the following lines
# leads to an args list with length 1
# leads to an args list with length 0
# skip the check and avoid a crash if that's the case
if len(args) > 1:
for arg in [x.lstrip() for x in args[1].split(',')]:
if len(args) > 0:
for arg in [x.lstrip() for x in args[0].split(',')]:
if arg in storedids:
del storedids[arg]
elif macname in whomacros:
(args, optional_args, brack, paren) = parse_macroref(0, leadmac.string)
present.append(args[whomacros[macname]])
(args, optional_args, is_unfinished) = parse_macroref(0, leadmac.string)
if len(args) >= whomacros[macname]:
present.append(args[whomacros[macname] - 1])
m = re.search("# *wmllint: recognize +(.*)", lines[i])
if m:
present.append(string_strip(m.group(1)).strip())