Another wmllint hack around the macro processor.

This commit is contained in:
Eric S. Raymond 2008-10-14 23:14:35 +00:00
parent c1ed694a9a
commit 48cadae1ad
3 changed files with 29 additions and 6 deletions

View file

@ -31,6 +31,8 @@
# These are used in scenarios, to include the carryover-defining keys into
# [endlevel]s and to show the carryover details in the objectives dialog.
# wmlscope: start conditionals
#ifdef NEW_GOLD_CARRYOVER_USED
#define NEW_GOLD_CARRYOVER PERCENTAGE
carryover_add=yes
@ -62,6 +64,7 @@
# wmlscope: stop ignoring
#endif
# wmlscope: stop conditionals
# wmlscope: prune NEW_GOLD_CARRYOVER
# wmlscope: prune NEW_GOLD_CARRYOVER_NOTE_20
# wmlscope: prune NEW_GOLD_CARRYOVER_NOTE_40

View file

@ -307,6 +307,7 @@ class CrossRef:
self.properties = {}
self.unit_ids = {}
ignoreflag = False
conditionalsflag = False
if warnlevel >=2:
print "*** Beginning definition-gathering pass..."
for (namespace, filename) in self.filelist.generator():
@ -348,6 +349,16 @@ class CrossRef:
else:
self.xref[name] = self.xref[name][:1]
continue
if "# wmlscope: start conditionals" in line:
if warnlevel > 1:
print '"%s", line %d: starting conditionals' \
% (filename, n+1)
conditionalsflag = True
elif "# wmlscope: stop conditionals" in line:
if warnlevel > 1:
print '"%s", line %d: stopping conditionals' \
% (filename, n+1)
conditionalsflag = False
if "# wmlscope: start ignoring" in line:
if warnlevel > 1:
print '"%s", line %d: starting ignoring' \
@ -375,6 +386,8 @@ class CrossRef:
for defn in self.xref[name]:
if not self.visible_from(defn, filename, n+1):
continue
elif conditionalsflag:
continue
elif defn.hash != here.hash:
print >>sys.stderr, \
"%s: overrides different %s definition at %s" \

View file

@ -32,17 +32,18 @@
# property, then treat it as non-exporting.
#
# You can tell wmlscope to ignore stretches of config files
# with the following magic comments?
# with the following magic comments:
#
# # wmlscope: start ignoring
# # wmlscope: stop ignoring
#
# This tool does catch one kind of implicit reference: if an attack name
# is specified but no icon is given, the attack icon will default to
# a name generated from the attack name. This behavior can be suppressed
# by adding a magic comment containing the string "no-icon" to the name= line.
# Similarly, you can tell wmlscope to ignore multiple or duplicate macro
# definitions in a range of lines with the following magic comments:
#
# The collowing magic comment:
# # wmlscope: start conditionals
# # wmlscope: stop conditionals
#
# The following magic comment:
#
# # prune FOOBAR
#
@ -50,6 +51,12 @@
# it has seen. This will be useful mainly for symbols that have different
# definitions enabled by an #ifdef.
#
#
# This tool does catch one kind of implicit reference: if an attack name
# is specified but no icon is given, the attack icon will default to
# a name generated from the attack name. This behavior can be suppressed
# by adding a magic comment containing the string "no-icon" to the name= line.
#
# The checking done by this tool has a couple of flaws:
#
# (1) It doesn't actually evaluate file inclusions. Instead, any