Add an "alignment" type check to wmllint.

This commit is contained in:
Eric S. Raymond 2008-03-20 20:26:51 +00:00
parent 9baf085293
commit c978a28d52
2 changed files with 8 additions and 4 deletions

View file

@ -112,6 +112,8 @@ def formaltype(f):
ftype = "span"
elif f in ("RANGE",):
ftype = "range"
elif f in ("ALIGN",):
ftype = "alignment"
elif f in ("TERRAIN",):
ftype = "terrain_code"
elif f in ("NAME", "VAR", "IMAGESTEM", "ID") or f.endswith("_NAME"):
@ -135,6 +137,8 @@ def formaltype(f):
return ftype
def actualtype(a):
if a is None:
return None
# Deduce the type of the actual
if a.isdigit() or a.startswith("-") and a[1:].isdigit():
atype = "numeric"
@ -144,6 +148,8 @@ def actualtype(a):
atype = "span"
elif a in ("melee", "ranged"):
atype = "range"
elif a in ("lawful", "neutral", "chaotic"):
atype = "alignment"
elif a.startswith("{") and a.endswith("}") or a.startswith("$"):
atype = None # Can't tell -- it's a macro expansion
elif re.match(image_reference, a):

View file

@ -160,10 +160,8 @@ class CrossRefLister(CrossRef):
print "%s: macro %s(%s) has mismatches:" % (m, n, ", ".join(map(lambda x: "%s=%s" % (x, formaltype(x)), m.args)))
for (file, refs) in m.references.items():
for (ln, args) in refs:
try:
print '"%s", line %d: %s(%s) with signature (%s)' % (file, ln, n, ", ".join(args), ", ".join(map(lambda f, a: "%s=%s" % (f, actualtype(a)), m.args, args)))
except AttributeError:
print '"%s", line %d: internal error in reporter' % (file, ln)
print '"%s", line %d: %s(%s) with signature (%s)' % (file, ln, n, ", ".join(args), ", ".join(map(lambda f, a: "%s=%s" % (f, actualtype(a)), m.args, args)))
def duplicates(self, exportonly):
"Dump duplicate unit IDs."
duplicate_latch = False