2 /*************************************************************************************
5 * Author: Roberto Rossi (rsoftware@altervista.org)
6 * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/highlighter)
7 * Release Version: 1.0.8.4
8 * Date Started: 2004/08/30
10 * Python language file for GeSHi.
15 * - Added missing functions and keywords. Also added two new Python 3.0 types. SF#2441839
17 * - Modifications by Tim (tim@skreak.com): added more keyword categories, tweaked colors
19 * - Added support for multiple object splitters
23 * TODO (updated 2004/11/27)
24 * -------------------------
26 *************************************************************************************
28 * This file is part of GeSHi.
30 * GeSHi is free software; you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation; either version 2 of the License, or
33 * (at your option) any later version.
35 * GeSHi is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 * GNU General Public License for more details.
40 * You should have received a copy of the GNU General Public License
41 * along with GeSHi; if not, write to the Free Software
42 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44 ************************************************************************************/
46 $language_data = array (
47 'LANG_NAME' => 'Python',
48 'COMMENT_SINGLE' => array(1 => '#'),
49 'COMMENT_MULTI' => array(),
50 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE
,
51 //Longest quotemarks ALWAYS first
52 'QUOTEMARKS' => array('"""', '"', "'"),
53 'ESCAPE_CHAR' => '\\',
57 ** Set 1: reserved words
58 ** http://python.org/doc/current/ref/keywords.html
61 'and', 'del', 'for', 'is', 'raise', 'assert', 'elif', 'from', 'lambda', 'return', 'break',
62 'else', 'global', 'not', 'try', 'class', 'except', 'if', 'or', 'while', 'continue', 'exec',
63 'import', 'pass', 'yield', 'def', 'finally', 'in', 'print', 'with', 'as'
68 ** http://python.org/doc/current/lib/built-in-funcs.html
71 '__import__', 'abs', 'basestring', 'bool', 'callable', 'chr', 'classmethod', 'cmp',
72 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile',
73 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help',
74 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals',
75 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range',
76 'raw_input', 'reduce', 'reload', 'reversed', 'round', 'set', 'setattr', 'slice',
77 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode',
78 'vars', 'xrange', 'zip',
79 // Built-in constants: http://python.org/doc/current/lib/node35.html
80 'False', 'True', 'None', 'NotImplemented', 'Ellipsis',
81 // Built-in Exceptions: http://python.org/doc/current/lib/module-exceptions.html
82 'Exception', 'StandardError', 'ArithmeticError', 'LookupError', 'EnvironmentError',
83 'AssertionError', 'AttributeError', 'EOFError', 'FloatingPointError', 'IOError',
84 'ImportError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'MemoryError', 'NameError',
85 'NotImplementedError', 'OSError', 'OverflowError', 'ReferenceError', 'RuntimeError',
86 'StopIteration', 'SyntaxError', 'SystemError', 'SystemExit', 'TypeError',
87 'UnboundlocalError', 'UnicodeError', 'UnicodeEncodeError', 'UnicodeDecodeError',
88 'UnicodeTranslateError', 'ValueError', 'WindowsError', 'ZeroDivisionError', 'Warning',
89 'UserWarning', 'DeprecationWarning', 'PendingDeprecationWarning', 'SyntaxWarning',
90 'RuntimeWarning', 'FutureWarning',
91 // self: this is a common python convention (but not a reserved word)
98 ** Set 3: standard library
99 ** http://python.org/doc/current/lib/modindex.html
102 '__builtin__', '__future__', '__main__', '_winreg', 'aifc', 'AL', 'al', 'anydbm',
103 'array', 'asynchat', 'asyncore', 'atexit', 'audioop', 'base64', 'BaseHTTPServer',
104 'Bastion', 'binascii', 'binhex', 'bisect', 'bsddb', 'bz2', 'calendar', 'cd', 'cgi',
105 'CGIHTTPServer', 'cgitb', 'chunk', 'cmath', 'cmd', 'code', 'codecs', 'codeop',
106 'collections', 'colorsys', 'commands', 'compileall', 'compiler',
107 'ConfigParser', 'Cookie', 'cookielib', 'copy', 'copy_reg', 'cPickle', 'crypt',
108 'cStringIO', 'csv', 'curses', 'datetime', 'dbhash', 'dbm', 'decimal', 'DEVICE',
109 'difflib', 'dircache', 'dis', 'distutils', 'dl', 'doctest', 'DocXMLRPCServer', 'dumbdbm',
110 'dummy_thread', 'dummy_threading', 'email', 'encodings', 'errno', 'exceptions', 'fcntl',
111 'filecmp', 'fileinput', 'FL', 'fl', 'flp', 'fm', 'fnmatch', 'formatter', 'fpectl',
112 'fpformat', 'ftplib', 'gc', 'gdbm', 'getopt', 'getpass', 'gettext', 'GL', 'gl', 'glob',
113 'gopherlib', 'grp', 'gzip', 'heapq', 'hmac', 'hotshot', 'htmlentitydefs', 'htmllib',
114 'HTMLParser', 'httplib', 'imageop', 'imaplib', 'imgfile', 'imghdr', 'imp', 'inspect',
115 'itertools', 'jpeg', 'keyword', 'linecache', 'locale', 'logging', 'mailbox', 'mailcap',
116 'marshal', 'math', 'md5', 'mhlib', 'mimetools', 'mimetypes', 'MimeWriter', 'mimify',
117 'mmap', 'msvcrt', 'multifile', 'mutex', 'netrc', 'new', 'nis', 'nntplib', 'operator',
118 'optparse', 'os', 'ossaudiodev', 'parser', 'pdb', 'pickle', 'pickletools', 'pipes',
119 'pkgutil', 'platform', 'popen2', 'poplib', 'posix', 'posixfile', 'pprint', 'profile',
120 'pstats', 'pty', 'pwd', 'py_compile', 'pyclbr', 'pydoc', 'Queue', 'quopri', 'random',
121 're', 'readline', 'repr', 'resource', 'rexec', 'rfc822', 'rgbimg', 'rlcompleter',
122 'robotparser', 'sched', 'ScrolledText', 'select', 'sets', 'sgmllib', 'sha', 'shelve',
123 'shlex', 'shutil', 'signal', 'SimpleHTTPServer', 'SimpleXMLRPCServer', 'site', 'smtpd',
124 'smtplib', 'sndhdr', 'socket', 'SocketServer', 'stat', 'statcache', 'statvfs', 'string',
125 'StringIO', 'stringprep', 'struct', 'subprocess', 'sunau', 'SUNAUDIODEV', 'sunaudiodev',
126 'symbol', 'sys', 'syslog', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', 'termios',
127 'test', 'textwrap', 'thread', 'threading', 'time', 'timeit', 'Tix', 'Tkinter', 'token',
128 'tokenize', 'traceback', 'tty', 'turtle', 'types', 'unicodedata', 'unittest', 'urllib2',
129 'urllib', 'urlparse', 'user', 'UserDict', 'UserList', 'UserString', 'uu', 'warnings',
130 'wave', 'weakref', 'webbrowser', 'whichdb', 'whrandom', 'winsound', 'xdrlib', 'xml',
131 'xmllib', 'xmlrpclib', 'zipfile', 'zipimport', 'zlib',
137 ** Set 4: special methods
138 ** http://python.org/doc/current/ref/specialnames.html
142 // Iterator types: http://python.org/doc/current/lib/typeiter.html
144 // String types: http://python.org/doc/current/lib/string-methods.html
145 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs',
146 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle',
147 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust',
148 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title',
149 'translate', 'upper', 'zfill',
151 // Basic customization: http://python.org/doc/current/ref/customization.html
152 '__new__', '__init__', '__del__', '__repr__', '__str__',
153 '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__cmp__', '__rcmp__',
154 '__hash__', '__nonzero__', '__unicode__', '__dict__',
155 // Attribute access: http://python.org/doc/current/ref/attribute-access.html
156 '__setattr__', '__delattr__', '__getattr__', '__getattribute__', '__get__', '__set__',
157 '__delete__', '__slots__',
158 // Class creation, callable objects
159 '__metaclass__', '__call__',
160 // Container types: http://python.org/doc/current/ref/sequence-types.html
161 '__len__', '__getitem__', '__setitem__', '__delitem__', '__iter__', '__contains__',
162 '__getslice__', '__setslice__', '__delslice__',
163 // Numeric types: http://python.org/doc/current/ref/numeric-types.html
164 '__abs__','__add__','__and__','__coerce__','__div__','__divmod__','__float__',
165 '__hex__','__iadd__','__isub__','__imod__','__idiv__','__ipow__','__iand__',
166 '__ior__','__ixor__', '__ilshift__','__irshift__','__invert__','__int__',
167 '__long__','__lshift__',
168 '__mod__','__mul__','__neg__','__oct__','__or__','__pos__','__pow__',
169 '__radd__','__rdiv__','__rdivmod__','__rmod__','__rpow__','__rlshift__','__rrshift__',
170 '__rshift__','__rsub__','__rmul__','__rand__','__rxor__','__ror__',
175 '(', ')', '[', ']', '{', '}', '*', '&', '%', '!', ';', '<', '>', '?', '`'
177 'CASE_SENSITIVE' => array(
178 GESHI_COMMENTS
=> false,
186 1 => 'color: #ff7700;font-weight:bold;', // Reserved
187 2 => 'color: #008000;', // Built-ins + self
188 3 => 'color: #dc143c;', // Standard lib
189 4 => 'color: #0000cd;' // Special methods
192 1 => 'color: #808080; font-style: italic;',
193 'MULTI' => 'color: #808080; font-style: italic;'
195 'ESCAPE_CHAR' => array(
196 0 => 'color: #000099; font-weight: bold;'
202 0 => 'color: #483d8b;'
205 0 => 'color: #ff4500;'
211 0 => 'color: #66cc66;'
225 'OBJECT_SPLITTERS' => array(
230 'STRICT_MODE_APPLIES' => GESHI_NEVER
,
231 'SCRIPT_DELIMITERS' => array(
233 'HIGHLIGHT_STRICT_BLOCK' => array(