Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Python lexer

<< < (2/3) > >>

Stevo:
wxScintella doesnt support documentation keywords for python :(

Ive located the bug in wxScintella for processing comments on Decorators, would i patch it and submit the patch here, or to wxScintella directly?

Attached are fixed up versions that im satisfied with for a python lexer.

lexer_python.xml

--- Code: ---<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_lexer_properties>
<CodeBlocks_lexer_properties>
        <Lexer name="Python"
                index="2"
                filemasks="*.py,*SConstruct,*SConscript">
                <Style name="Default"
index="0"
fg="0,0,0"
bg="255,255,255"
bold="0"
italics="0"
underlined="0"/>
                <Style name="Comment"
                        index="1"
                        fg="160,160,160"/>
                <Style name="Number"
                        index="2"
                        fg="240,0,240"/>
                <Style name="Double Quote String"
                        index="3"
                        fg="0,0,255"/>
                <Style name="Single Quote String"
                        index="4"
                        fg="224,160,0"/>
                <Style name="Keyword"
                        index="5"
                        fg="0,0,160"
                        bold="1"/>
                <Style name="Triple Single Quote String"
                        index="6"
                        fg="128,0,0"/>
                <Style name="Triple Double Quote String"
                        index="7"
                        fg="128,0,128"/>
                <Style name="Class name"
                        index="8"
                        fg="0,0,0"/>
                <Style name="Definiton name"
                        index="9"
                        fg="0,160,0"
                        bold="1"/>
                <Style name="Operator"
                        index="10"
                        fg="255,0,0"/>
                <Style name="Identifier"
                        index="11"/>
                <Style name="Comment block"
                        index="12"
                        fg="128,128,255"
                        bold="1"/>
                <Style name="String EOL"
                        index="13"/>
                <Style name="User Keyword"
                        index="14"/>
                <Style name="Decorator"
                        index="15"/>
                <Keywords>
                        <Language index="0"
                                value="and assert break class continue def del elif else except
                                       exec finally for from global if import in is lambda None
                                       not or pass print raise return try while yield

                                       __import__ abs basestring bool callable chr classmethod
                                       cmp compile complex delattr dict dir divmod enumerate
                                       eval execfile file filter float frozenset getattr globals
                                       hasattr hash help hex id input int isinstance issubclass
                                       iter len list locals long map max min object oct open
                                       ord pow property range raw_input reduce reload repr
                                       reversed round set setattr slice sorted staticmethod
                                       str sum super tuple type type unichr unicode vars xrange
                                       zip

                                       apply buffer coerce intern

                                       __dict__ Ellipsis False True NotImplemented
                                       __class__ __bases__ __name__

                                       exception Exception StandardError ArithmeticError
                                       LookupError EnvironmentError AssertionError
                                       AttributeError EOFError FloatingPointError IOError
                                       ImportError IndexError KeyError KeyboardInterrupt
                                       MemoryError NameError NotImplementedError OSError
                                       OverflowError ReferenceError RuntimeError
                                       StopIteration SyntaxError SystemError SystemExit
                                       TypeError UnboundLocalError UnicodeError
                                       UnicodeEncodeError UnicodeDecodeError
                                       UnicodeTranslateError ValueError WindowsError
                                       ZeroDivisionError Warning UserWarning
                                       DeprecationWarning PendingDeprecationWarning
                                       SyntaxWarning RuntimeWarning FutureWarning
                                      "/>
                        <User index="1"
                                value="sys gc weakref fpectl atexit types UserDict UserList UserString
                                    operator inspect traceback linecache pickle cPickle copy_reg
                                    shelve copy marshal warnings imp zipimport pkgutil modulefinder
                                    code codeop pprint repr new site user __builtin__ __main__
                                    __future__

                                    string re struct difflib fpformat StringIO cStringIO textwrap
                                    codecs encodings.idna unicodedata stringprep

                                    pydoc doctest unittest test test.test_support decimal math
                                    cmath random whrandom bisect collections heapq array sets
                                    itertools ConfigParser fileinput calendar cmd shlex

                                       os os.path dircache stat statcache statvfs filecmp subprocess
                                       popen2 datetime time sched mutex getpass curses curses.textpad
                                       curses.wrapper curses.ascii curses.panel getopt optparse tempfile
                                       errno glob fnmatch shutil locale gettext logging platform

                                       signal socket select thread threading dummy_thread dummy_threading
                                       Queue mmap anydbm dbhash whichdb bsddb dumbdbm zlib gzip bz2
                                       zipfile tarfile readline rlcompleter

                                       posix pwd grp crypt dl dbm gdbm termios tty pty fcntl pipes
                                       posixfile resource nis syslog commands

                                       hotshot timeit

                                       webbrowser cgi cgitb urllib urllib2 httplib ftplib gopherlib
                                       poplib imaplib nntplib smtplib smtpd telnetlib urlparse
                                       SocketServer BaseHTTPServer SimpleHTTPServer CGIHTTPServer
                                       cookielib Cookie xmlrpclib SimpleXMLRPCServer DocXMLRPCServer
                                       asyncore asynchat

                                       formatter email email.Message email.Parser email.Generator
                                       email.Header email.Charset email.Encoders email.Errors
                                       email.Utils email.Iterators mailcap mailbox mhlib mimetools
                                       mimetypes MimeWriter mimify multifile rfc822 base64 binascii
                                       binhex quopri uu xdrlib netrc robotparser csv

                                       HTMLParser sgmllib htmllib htmlentitydefs xml.parsers.expat
                                       xml.dom xml.dom.minidom xml.dom.pulldom xml.sax
                                       xml.sax.handler xml.sax.saxutils xml.sax.xmlreader xmllib

                                       audioop imageop aifc sunau wave chunk colorsys rgbimg imghdr
                                       sndhdr ossaudiodev

                                       hmac md5 sha

                                       Tkinter Tix ScrolledText turtle

                                       parser symbol token keyword tokenize tabnanny pyclbr
                                       py_compile compileall dis pickletools distutils

                                      "/>
                        <Documentation index="2"
                                value=""/>
                </Keywords>
                <SampleCode value="lexer_python.sample"/>
        </Lexer>
</CodeBlocks_lexer_properties>

--- End code ---

and lexer_python.sample

--- Code: ---# This is a comment
## This is a comment block

import sys, time, string

month_names = ['Januari', 'Februari', 'Maart',      # These are the
               'April',   'Mei',      'Juni',       # Dutch names
               "Juli",    "Augustus", "September",  # for the months
               "Oktober", "November", "December"]   # of the year

if len(sys.argv)!=2:
    print '''Usage: This is a 'Code::Blocks' Example'''
    print "This String goes to EOL
    sys.exit(0)

class ClassName:
  def perm(l):
  # Compute the list of all permutations of l
    if len(l) <= 1:
      return [l]
    r = []
    for i in range(len(l)):
      s = l[:i] + l[i+1:]
      p = perm(s)
      for x in p:
        r.append(l[i:i+1] + x)
    return r

@classmethod           # This is a decorator
@synchronized(lock)    # And so is this
def func(self):
  try:
    return  """A "Triple Double Quote" String\n"""
  except SystemExit:
    pass


--- End code ---

mandrav:

--- Quote from: Stevo on January 20, 2006, 03:27:52 am ---wxScintella doesnt support documentation keywords for python :(

Ive located the bug in wxScintella for processing comments on Decorators, would i patch it and submit the patch here, or to wxScintella directly?

--- End quote ---

If it is a wxScintilla issue and not a scintilla one, then:
Post it in our patch tracker so we can use it immediately and then post it at wxScintilla's patch tracker. I 'm sure Otto will apply it for the next version.

If on the other hand it is a scintilla issue, post it there directly.

sethjackson:
Hey this patch was accepted.  8) So could the two files (lexer_python.xml, lexer_python.sample) files be added to the .cbp projects now.   :wink:

sethjackson:
Here is a patch for the .cbp project. :)

[attachment deleted by admin]

sethjackson:
@Stevo are you sure it is a scintilla bug? Those decorators (in the sample) aren't highlighted because you did not specify a color for them. :) I have a patch that does.

http://sourceforge.net/tracker/index.php?func=detail&aid=1411504&group_id=126998&atid=707418



Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version