Commit | Line | Data |
---|---|---|
6a1aa64f DV |
1 | /* Python 2.3 syntax contributed by Gheorghe Milas */ |
2 | dp.sh.Brushes.Python = function() | |
3 | { | |
4 | var keywords = 'and assert break class continue def del elif else except exec ' + | |
5 | 'finally for from global if import in is lambda not or object pass print ' + | |
6 | 'raise return try yield while'; | |
7 | ||
8 | var builtins = 'self __builtin__ __dict__ __future__ __methods__ __members__ __author__ __email__ __version__' + | |
9 | '__class__ __bases__ __import__ __main__ __name__ __doc__ __self__ __debug__ __slots__ ' + | |
10 | 'abs append apply basestring bool buffer callable chr classmethod clear close cmp coerce compile complex ' + | |
11 | 'conjugate copy count delattr dict dir divmod enumerate Ellipsis eval execfile extend False file fileno filter float flush ' + | |
12 | 'get getattr globals has_key hasarttr hash hex id index input insert int intern isatty isinstance isubclass ' + | |
13 | 'items iter keys len list locals long map max min mode oct open ord pop pow property range ' + | |
14 | 'raw_input read readline readlines reduce reload remove repr reverse round seek setattr slice sum ' + | |
15 | 'staticmethod str super tell True truncate tuple type unichr unicode update values write writelines xrange zip'; | |
16 | ||
17 | var magicmethods = '__abs__ __add__ __and__ __call__ __cmp__ __coerce__ __complex__ __concat__ __contains__ __del__ __delattr__ __delitem__ ' + | |
18 | '__delslice__ __div__ __divmod__ __float__ __getattr__ __getitem__ __getslice__ __hash__ __hex__ __eq__ __le__ __lt__ __gt__ __ge__ ' + | |
19 | '__iadd__ __isub__ __imod__ __idiv__ __ipow__ __iand__ __ior__ __ixor__ __ilshift__ __irshift__ ' + | |
20 | '__invert__ __init__ __int__ __inv__ __iter__ __len__ __long__ __lshift__ __mod__ __mul__ __new__ __neg__ __nonzero__ __oct__ __or__ ' + | |
21 | '__pos__ __pow__ __radd__ __rand__ __rcmp__ __rdiv__ __rdivmod__ __repeat__ __repr__ __rlshift__ __rmod__ __rmul__ ' + | |
22 | '__ror__ __rpow__ __rrshift__ __rshift__ __rsub__ __rxor__ __setattr__ __setitem__ __setslice__ __str__ __sub__ __xor__'; | |
23 | ||
24 | var exceptions = 'Exception StandardError ArithmeticError LookupError EnvironmentError AssertionError AttributeError EOFError ' + | |
25 | 'FutureWarning IndentationError OverflowWarning PendingDeprecationWarning ReferenceError RuntimeWarning ' + | |
26 | 'SyntaxWarning TabError UnicodeDecodeError UnicodeEncodeError UnicodeTranslateError UserWarning Warning ' + | |
27 | 'IOError ImportError IndexError KeyError KeyboardInterrupt MemoryError NameError NotImplementedError OSError ' + | |
28 | 'RuntimeError StopIteration SyntaxError SystemError SystemExit TypeError UnboundLocalError UnicodeError ValueError ' + | |
29 | 'FloatingPointError OverflowError WindowsError ZeroDivisionError'; | |
30 | ||
31 | var types = 'NoneType TypeType IntType LongType FloatType ComplexType StringType UnicodeType BufferType TupleType ListType ' + | |
32 | 'DictType FunctionType LambdaType CodeType ClassType UnboundMethodType InstanceType MethodType BuiltinFunctionType BuiltinMethodType ' + | |
33 | 'ModuleType FileType XRangeType TracebackType FrameType SliceType EllipsisType'; | |
34 | ||
35 | var commonlibs = 'anydbm array asynchat asyncore AST base64 binascii binhex bisect bsddb buildtools bz2 ' + | |
36 | 'BaseHTTPServer Bastion calendar cgi cmath cmd codecs codeop commands compiler copy copy_reg ' + | |
37 | 'cPickle crypt cStringIO csv curses Carbon CGIHTTPServer ConfigParser Cookie datetime dbhash ' + | |
38 | 'dbm difflib dircache distutils doctest DocXMLRPCServer email encodings errno exceptions fcntl ' + | |
39 | 'filecmp fileinput ftplib gc gdbm getopt getpass glob gopherlib gzip heapq htmlentitydefs ' + | |
40 | 'htmllib httplib HTMLParser imageop imaplib imgfile imghdr imp inspect itertools jpeg keyword ' + | |
41 | 'linecache locale logging mailbox mailcap marshal math md5 mhlib mimetools mimetypes mimify mmap ' + | |
42 | 'mpz multifile mutex MimeWriter netrc new nis nntplib nsremote operator optparse os parser pickle pipes ' + | |
43 | 'popen2 poplib posix posixfile pprint preferences profile pstats pwd pydoc pythonprefs quietconsole ' + | |
44 | 'quopri Queue random re readline resource rexec rfc822 rgbimg sched select sets sgmllib sha shelve shutil ' + | |
45 | 'signal site smtplib socket stat statcache string struct symbol sys syslog SimpleHTTPServer ' + | |
46 | 'SimpleXMLRPCServer SocketServer StringIO tabnanny tarfile telnetlib tempfile termios textwrap ' + | |
47 | 'thread threading time timeit token tokenize traceback tty types Tkinter unicodedata unittest ' + | |
48 | 'urllib urllib2 urlparse user UserDict UserList UserString warnings weakref webbrowser whichdb ' + | |
49 | 'xml xmllib xmlrpclib xreadlines zipfile zlib'; | |
50 | ||
51 | this.regexList = [ | |
52 | { regex: new RegExp('#.*$', 'gm'), css: 'comment' }, // comments | |
53 | { regex: new RegExp('^\\s*"""(.|\n)*?"""\\s*$', 'gm'), css: 'docstring' }, // documentation string " | |
54 | { regex: new RegExp('^\\s*\'\'\'(.|\n)*?\'\'\'\\s*$', 'gm'), css: 'docstring' }, // documentation string ' | |
55 | { regex: new RegExp('"""(.|\n)*?"""', 'g'), css: 'string' }, // multi-line strings " | |
56 | { regex: new RegExp('\'\'\'(.|\n)*?\'\'\'', 'g'), css: 'string' }, // multi-line strings ' | |
57 | { regex: new RegExp('"(?:\\.|[^\\""])*"', 'g'), css: 'string' }, // strings " | |
58 | { regex: new RegExp('\'(?:\\.|[^\\\'\'])*\'', 'g'), css: 'string' }, // strings ' | |
59 | { regex: new RegExp(this.GetKeywords(keywords), 'gm'), css: 'keyword' }, // keywords | |
60 | { regex: new RegExp(this.GetKeywords(builtins), 'gm'), css: 'builtins' }, // builtin objects, functions, methods, magic attributes | |
61 | { regex: new RegExp(this.GetKeywords(magicmethods), 'gm'), css: 'magicmethods' }, // special methods | |
62 | { regex: new RegExp(this.GetKeywords(exceptions), 'gm'), css: 'exceptions' }, // standard exception classes | |
63 | { regex: new RegExp(this.GetKeywords(types), 'gm'), css: 'types' }, // types from types.py | |
64 | { regex: new RegExp(this.GetKeywords(commonlibs), 'gm'), css: 'commonlibs' } // common standard library modules | |
65 | ]; | |
66 | ||
67 | this.CssClass = 'dp-py'; | |
68 | } | |
69 | ||
70 | dp.sh.Brushes.Python.prototype = new dp.sh.Highlighter(); | |
71 | dp.sh.Brushes.Python.Aliases = ['py', 'python']; |