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