diff options
author | Guido van Rossum <guido@python.org> | 1997-10-22 21:00:49 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-22 21:00:49 (GMT) |
commit | 9694fcab5332f27dc28b195ba1391e5491d2eaef (patch) | |
tree | 23dc3d9a7d1cc4b138ac2bffd028a519cba93b30 /Lib/token.py | |
parent | 426916e50e1209d8ecc12678855dc531863a48c5 (diff) | |
download | cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.zip cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.gz cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.bz2 |
Convert all remaining *simple* cases of regex usage to re usage.
Diffstat (limited to 'Lib/token.py')
-rwxr-xr-x | Lib/token.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Lib/token.py b/Lib/token.py index 3d358a3..888bb41 100755 --- a/Lib/token.py +++ b/Lib/token.py @@ -7,10 +7,7 @@ # To update the symbols in this file, 'cd' to the top directory of # the python source tree after building the interpreter and run: # -# PYTHONPATH=./Lib ./python Lib/token.py -# -# (this path allows the import of string.py and regexmodule.so -# for a site with no installation in place) +# python Lib/token.py #--start constants-- ENDMARKER = 0 @@ -73,7 +70,7 @@ def ISEOF(x): def main(): - import regex + import re import string import sys args = sys.argv[1:] @@ -88,13 +85,14 @@ def main(): sys.exit(1) lines = string.splitfields(fp.read(), "\n") fp.close() - re = regex.compile( - "#define[ \t][ \t]*\([A-Z][A-Z_]*\)[ \t][ \t]*\([0-9][0-9]*\)", - regex.casefold) + prog = re.compile( + "#define[ \t][ \t]*([A-Z][A-Z_]*)[ \t][ \t]*([0-9][0-9]*)", + re.IGNORECASE) tokens = {} for line in lines: - if re.match(line) > -1: - name, val = re.group(1, 2) + match = prog.match(line) + if match: + name, val = match.group(1, 2) val = string.atoi(val) tokens[val] = name # reverse so we can sort them... keys = tokens.keys() |