class LexerPython : public LexerBase {
public:
        LexerPython() {
        }
        void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
                try {
                        Accessor astyler(pAccess, &props);
                        ColourisePyDoc(startPos, length, initStyle, keyWordLists, astyler);
                        astyler.Flush();
                } catch (...) {
                        // Should not throw into caller as may be compiled with different compiler or options
                        pAccess->SetErrorStatus(SC_STATUS_FAILURE);
                }
        }
        void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
                try {
                        Accessor astyler(pAccess, &props);
                        FoldPyDoc(startPos, length, initStyle, keyWordLists, astyler);
                        astyler.Flush();
                } catch (...) {
                        // Should not throw into caller as may be compiled with different compiler or options
                        pAccess->SetErrorStatus(SC_STATUS_FAILURE);
                }
        }

        static ILexer *LexerFactoryPython() {
                try {
                        return new LexerPython();
                } catch (...) {
                        // Should not throw into caller as may be compiled with different compiler or options
                        return 0;
                }
        }
};

#ifdef BUILD_AS_EXTERNAL_LEXER

#ifdef _WIN32
#define EXT_LEXER_DECL __declspec( dllexport ) __stdcall
#else
#define EXT_LEXER_DECL
#endif

static const char *lexerName = "python";

extern "C" {

int EXT_LEXER_DECL GetLexerCount() {
        return 1;
}

void EXT_LEXER_DECL GetLexerName(unsigned int index, char *name, int buflength) {
        *name = 0;
        if ((index == 0) && (buflength > static_cast<int>(strlen(lexerName)))) {
                strcpy(name, lexerName);
        }
}

LexerFactoryFunction EXT_LEXER_DECL GetLexerFactory(unsigned int index) {
        if (index == 0)
                return LexerPython::LexerFactoryPython;
        else
                return 0;
}

}

#else

LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc, "python", FoldPyDoc, pythonWordListDesc);

#endif