summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-04-10 19:14:59 (GMT)
committerGuido van Rossum <guido@python.org>1998-04-10 19:14:59 (GMT)
commitce73acf5e60fad088c762a30e4580cfef7393ce4 (patch)
tree73448d1321440f23f4f94f67076bc5c6e147099e
parentc9ea7572e97c959ef01c486d7f97da89c60f5db9 (diff)
downloadcpython-ce73acf5e60fad088c762a30e4580cfef7393ce4.zip
cpython-ce73acf5e60fad088c762a30e4580cfef7393ce4.tar.gz
cpython-ce73acf5e60fad088c762a30e4580cfef7393ce4.tar.bz2
Tim's version 4, with my mods
-rwxr-xr-xLib/tabnanny.py20
-rwxr-xr-xTools/idle/tabnanny.py20
-rwxr-xr-xTools/scripts/tabnanny.py20
3 files changed, 18 insertions, 42 deletions
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py
index b290fb6..a6cb94b 100755
--- a/Lib/tabnanny.py
+++ b/Lib/tabnanny.py
@@ -2,9 +2,9 @@
"""The Tab Nanny despises ambiguous indentation. She knows no mercy."""
-# Released to the public domain, by Tim Peters, 4 April 1998.
+# Released to the public domain, by Tim Peters, 6 April 1998.
-__version__ = "3"
+__version__ = "4"
import os
import sys
@@ -24,7 +24,7 @@ def main():
if o == '-v':
verbose = verbose + 1
if not args:
- print "Usage:", sys.argv[0], "file_or_directory ..."
+ print "Usage:", sys.argv[0], "[-v] file_or_directory ..."
return
for arg in args:
check(arg)
@@ -245,18 +245,10 @@ if hasattr(tokenize, 'NL'):
INDENT=tokenize.INDENT,
DEDENT=tokenize.DEDENT,
NEWLINE=tokenize.NEWLINE,
- COMMENT=tokenize.COMMENT,
- NL=tokenize.NL):
+ JUNK=(tokenize.COMMENT, tokenize.NL) ):
global indents, check_equal
- # test in decreasing order of frequency, although the check_equal
- # test *must* be last; INDENT and DEDENT appear equally often
-
- if type in (COMMENT, NL):
- # the indentation of these guys is meaningless
- pass
-
- elif type == NEWLINE:
+ if type == NEWLINE:
# a program statement, or ENDMARKER, will eventually follow,
# after some (possibly empty) run of tokens of the form
# (NL | COMMENT)* (INDENT | DEDENT+)?
@@ -281,7 +273,7 @@ if hasattr(tokenize, 'NL'):
assert check_equal # else no earlier NEWLINE, or an earlier INDENT
del indents[-1]
- elif check_equal:
+ elif check_equal and type not in JUNK:
# this is the first "real token" following a NEWLINE, so it
# must be the first token of the next program statement, or an
# ENDMARKER; the "line" argument exposes the leading whitespace
diff --git a/Tools/idle/tabnanny.py b/Tools/idle/tabnanny.py
index b290fb6..a6cb94b 100755
--- a/Tools/idle/tabnanny.py
+++ b/Tools/idle/tabnanny.py
@@ -2,9 +2,9 @@
"""The Tab Nanny despises ambiguous indentation. She knows no mercy."""
-# Released to the public domain, by Tim Peters, 4 April 1998.
+# Released to the public domain, by Tim Peters, 6 April 1998.
-__version__ = "3"
+__version__ = "4"
import os
import sys
@@ -24,7 +24,7 @@ def main():
if o == '-v':
verbose = verbose + 1
if not args:
- print "Usage:", sys.argv[0], "file_or_directory ..."
+ print "Usage:", sys.argv[0], "[-v] file_or_directory ..."
return
for arg in args:
check(arg)
@@ -245,18 +245,10 @@ if hasattr(tokenize, 'NL'):
INDENT=tokenize.INDENT,
DEDENT=tokenize.DEDENT,
NEWLINE=tokenize.NEWLINE,
- COMMENT=tokenize.COMMENT,
- NL=tokenize.NL):
+ JUNK=(tokenize.COMMENT, tokenize.NL) ):
global indents, check_equal
- # test in decreasing order of frequency, although the check_equal
- # test *must* be last; INDENT and DEDENT appear equally often
-
- if type in (COMMENT, NL):
- # the indentation of these guys is meaningless
- pass
-
- elif type == NEWLINE:
+ if type == NEWLINE:
# a program statement, or ENDMARKER, will eventually follow,
# after some (possibly empty) run of tokens of the form
# (NL | COMMENT)* (INDENT | DEDENT+)?
@@ -281,7 +273,7 @@ if hasattr(tokenize, 'NL'):
assert check_equal # else no earlier NEWLINE, or an earlier INDENT
del indents[-1]
- elif check_equal:
+ elif check_equal and type not in JUNK:
# this is the first "real token" following a NEWLINE, so it
# must be the first token of the next program statement, or an
# ENDMARKER; the "line" argument exposes the leading whitespace
diff --git a/Tools/scripts/tabnanny.py b/Tools/scripts/tabnanny.py
index b290fb6..a6cb94b 100755
--- a/Tools/scripts/tabnanny.py
+++ b/Tools/scripts/tabnanny.py
@@ -2,9 +2,9 @@
"""The Tab Nanny despises ambiguous indentation. She knows no mercy."""
-# Released to the public domain, by Tim Peters, 4 April 1998.
+# Released to the public domain, by Tim Peters, 6 April 1998.
-__version__ = "3"
+__version__ = "4"
import os
import sys
@@ -24,7 +24,7 @@ def main():
if o == '-v':
verbose = verbose + 1
if not args:
- print "Usage:", sys.argv[0], "file_or_directory ..."
+ print "Usage:", sys.argv[0], "[-v] file_or_directory ..."
return
for arg in args:
check(arg)
@@ -245,18 +245,10 @@ if hasattr(tokenize, 'NL'):
INDENT=tokenize.INDENT,
DEDENT=tokenize.DEDENT,
NEWLINE=tokenize.NEWLINE,
- COMMENT=tokenize.COMMENT,
- NL=tokenize.NL):
+ JUNK=(tokenize.COMMENT, tokenize.NL) ):
global indents, check_equal
- # test in decreasing order of frequency, although the check_equal
- # test *must* be last; INDENT and DEDENT appear equally often
-
- if type in (COMMENT, NL):
- # the indentation of these guys is meaningless
- pass
-
- elif type == NEWLINE:
+ if type == NEWLINE:
# a program statement, or ENDMARKER, will eventually follow,
# after some (possibly empty) run of tokens of the form
# (NL | COMMENT)* (INDENT | DEDENT+)?
@@ -281,7 +273,7 @@ if hasattr(tokenize, 'NL'):
assert check_equal # else no earlier NEWLINE, or an earlier INDENT
del indents[-1]
- elif check_equal:
+ elif check_equal and type not in JUNK:
# this is the first "real token" following a NEWLINE, so it
# must be the first token of the next program statement, or an
# ENDMARKER; the "line" argument exposes the leading whitespace