_perl.py :  » GUI » wxPython » wxPython-src-2.8.11.0 » wxPython » wx » tools » Editra » src » syntax » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » GUI » wxPython 
wxPython » wxPython src 2.8.11.0 » wxPython » wx » tools » Editra » src » syntax » _perl.py
###############################################################################
# Name: perl.py                                                               #
# Purpose: Define Perl syntax for highlighting and other features             #
# Author: Cody Precord <cprecord@editra.org>                                  #
# Copyright: (c) 2008 Cody Precord <staff@editra.org>                         #
# License: wxWindows License                                                  #
###############################################################################

"""
FILE: perl.py
AUTHOR: Cody Precord
@summary: Lexer configuration module for Perl.

"""

__author__ = "Cody Precord <cprecord@editra.org>"
__svnid__ = "$Id: _perl.py 63834 2010-04-03 06:04:33Z CJP $"
__revision__ = "$Revision: 63834 $"

#-----------------------------------------------------------------------------#
# Imports
import wx.stc as stc

# Local Imports
import synglob
import syndata

#-----------------------------------------------------------------------------#

#---- Keyword Specifications ----#

# Perl Keywords
PERL_KW = (0, "if elseif unless else switch eq ne gt lt ge le cmp not and or "
              "xor while for foreach do until continue defined undef and or "
              "not bless ref BEGIN END my local our goto return last next redo "
              "chomp chop chr crypt index lc lcfirst length org pack reverse "
              "rindex sprintf substr uc ucfirst pos quotemet split study abs "
              "atan2 cos exp hex int log oct rand sin sqrt srand spice unshift "
              "shift push pop split join reverse grep map sort unpack each "
              "exists keys values tie tied untie carp confess croak dbmclose "
              "dbmopen die syscall binmode close closedir eof fileno getc "
              "lstat print printf readdir readline readpipe rewinddir select "
              "stat tell telldir write fcntl flock ioctl open opendir read "
              "seek seekdir sysopen sysread sysseek syswrite truncate pack vec "
              "chdir chmod chown chroot glob link mkdir readlink rename rmdir "
              "symlink umask ulink utime caller dump eval exit wanarray "
              "import alarm exec fork getpgrp getppid getpriority kill pipe "
              "setpgrp setpriority sleep system times wait waitpid accept "
              "bind connect getpeername getsockname getsockopt listen recv "
              "send setsockopt shutdown socket socketpair msgctl msgget msgrcv "
              "msgsnd semctl semget semop shmctl shmget shmread shmwrite "
              "endhostent endnetent endprooent endservent gethostbyaddr "
              "gethostbyname gethostent getnetbyaddr getnetbyname getnetent "
              "getprotobyname getprotobynumber getprotoent getervbyname time "
              "getservbyport getservent sethostent setnetent setprotoent "
              "setservent getpwuid getpwnam getpwent setpwent endpwent "
              "getgrgid getlogin getgrnam setgrent endgrent gtime localtime "
              "times warn formline reset scalar delete prototype lock new "
              "NULL __FILE__ __LINE__ __PACKAGE__ __DATA__ __END__ AUTOLOAD "
              "BEGIN CORE DESTROY END EQ GE GT INIT LE LT NE CHECK use sub "
              "elsif require getgrent ")

#---- Syntax Style Specs ----#
SYNTAX_ITEMS = [ (stc.STC_PL_DEFAULT, 'default_style'),
                 (stc.STC_PL_ARRAY, 'array_style'),
                 (stc.STC_PL_BACKTICKS, 'btick_style'),
                 (stc.STC_PL_CHARACTER, 'char_style'),
                 (stc.STC_PL_COMMENTLINE, 'comment_style'),
                 (stc.STC_PL_DATASECTION, 'default_style'), # STYLE ME
                 (stc.STC_PL_ERROR, 'error_style'),
                 (stc.STC_PL_HASH, 'global_style'),
                 (stc.STC_PL_HERE_DELIM, 'here_style'),
                 (stc.STC_PL_HERE_Q, 'here_style'),
                 (stc.STC_PL_HERE_QQ, 'here_style'),
                 (stc.STC_PL_HERE_QX, 'here_style'),
                 (stc.STC_PL_IDENTIFIER, 'default_style'),
                 (stc.STC_PL_LONGQUOTE, 'default_style'), # STYLE ME
                 (stc.STC_PL_NUMBER, 'number_style'),
                 (stc.STC_PL_OPERATOR, 'operator_style'),
                 (stc.STC_PL_POD, 'comment_style'),
                 (stc.STC_PL_PREPROCESSOR,  'pre_style' ),
                 (stc.STC_PL_PUNCTUATION, 'default_style'), # STYLE ME
                 (stc.STC_PL_REGEX, 'regex_style'),
                 (stc.STC_PL_REGSUBST, 'regex_style'),
                 (stc.STC_PL_SCALAR, 'scalar_style'),
                 (stc.STC_PL_STRING, 'string_style'),
                 (stc.STC_PL_STRING_Q, 'string_style'),
                 (stc.STC_PL_STRING_QQ, 'string_style'),
                 (stc.STC_PL_STRING_QR, 'string_style'),
                 (stc.STC_PL_STRING_QW, 'string_style'),
                 (stc.STC_PL_STRING_QX, 'string_style'),
                 (stc.STC_PL_SYMBOLTABLE, 'default_style'), # STYLE ME
                 (stc.STC_PL_WORD, 'keyword_style') ]

#---- Extra Properties ----#
FOLD = ("fold", "1")
FLD_COMPACT = ("fold.compact", "1")
FLD_COMMENT = ("fold.comment", "1")
FLD_POD = ("fold.perl.pod", "1")
FLD_PKG = ("fold.perl.package", "1")

#-----------------------------------------------------------------------------#

class SyntaxData(syndata.SyntaxDataBase):
    """SyntaxData object for Perl""" 
    def __init__(self, langid):
        syndata.SyntaxDataBase.__init__(self, langid)

        # Setup
        self.SetLexer(stc.STC_LEX_PERL)

    def GetKeywords(self):
        """Returns Specified Keywords List """
        return [PERL_KW]

    def GetSyntaxSpec(self):
        """Syntax Specifications """
        return SYNTAX_ITEMS

    def GetProperties(self):
        """Returns a list of Extra Properties to set """
        return [FOLD]

    def GetCommentPattern(self):
        """Returns a list of characters used to comment a block of code """
        return [u'#']

#---- Syntax Modules Internal Functions ----#
def KeywordString(option=0):
    """Returns the specified Keyword String
    @note: not used by most modules

    """
    if option == synglob.ID_LANG_PERL:
        return PERL_KW[1]
    else:
        return u''

#---- End Syntax Modules Internal Functions ----#

#-----------------------------------------------------------------------------#
w__w__w__._j___a___v__a__2_s___._c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.