[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/geshi/geshi/src/geshi/ -> python.php (source)

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