+++ /dev/null
-#! /usr/bin/env python\r
-\r
-"""Keywords (from "graminit.c")\r
-\r
-This file is automatically generated; please don't muck it up!\r
-\r
-To update the symbols in this file, 'cd' to the top directory of\r
-the python source tree after building the interpreter and run:\r
-\r
- ./python Lib/keyword.py\r
-"""\r
-\r
-__all__ = ["iskeyword", "kwlist"]\r
-\r
-kwlist = [\r
-#--start keywords--\r
- 'and',\r
- 'as',\r
- 'assert',\r
- 'break',\r
- 'class',\r
- 'continue',\r
- 'def',\r
- 'del',\r
- 'elif',\r
- 'else',\r
- 'except',\r
- 'exec',\r
- 'finally',\r
- 'for',\r
- 'from',\r
- 'global',\r
- 'if',\r
- 'import',\r
- 'in',\r
- 'is',\r
- 'lambda',\r
- 'not',\r
- 'or',\r
- 'pass',\r
- 'print',\r
- 'raise',\r
- 'return',\r
- 'try',\r
- 'while',\r
- 'with',\r
- 'yield',\r
-#--end keywords--\r
- ]\r
-\r
-iskeyword = frozenset(kwlist).__contains__\r
-\r
-def main():\r
- import sys, re\r
-\r
- args = sys.argv[1:]\r
- iptfile = args and args[0] or "Python/graminit.c"\r
- if len(args) > 1: optfile = args[1]\r
- else: optfile = "Lib/keyword.py"\r
-\r
- # scan the source file for keywords\r
- fp = open(iptfile)\r
- strprog = re.compile('"([^"]+)"')\r
- lines = []\r
- for line in fp:\r
- if '{1, "' in line:\r
- match = strprog.search(line)\r
- if match:\r
- lines.append(" '" + match.group(1) + "',\n")\r
- fp.close()\r
- lines.sort()\r
-\r
- # load the output skeleton from the target\r
- fp = open(optfile)\r
- format = fp.readlines()\r
- fp.close()\r
-\r
- # insert the lines of keywords\r
- try:\r
- start = format.index("#--start keywords--\n") + 1\r
- end = format.index("#--end keywords--\n")\r
- format[start:end] = lines\r
- except ValueError:\r
- sys.stderr.write("target does not contain format markers\n")\r
- sys.exit(1)\r
-\r
- # write the output file\r
- fp = open(optfile, 'w')\r
- fp.write(''.join(format))\r
- fp.close()\r
-\r
-if __name__ == "__main__":\r
- main()\r