Scintilla 4.0.3
[TortoiseGit.git] / ext / scintilla / lexlib / LexerNoExceptions.cxx
blob5389618d7a819954df8bf100febb8504a171bf54
1 // Scintilla source code edit control
2 /** @file LexerNoExceptions.cxx
3 ** A simple lexer with no state which does not throw exceptions so can be used in an external lexer.
4 **/
5 // Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #include <cstdlib>
9 #include <cassert>
11 #include "ILexer.h"
12 #include "Scintilla.h"
13 #include "SciLexer.h"
15 #include "PropSetSimple.h"
16 #include "WordList.h"
17 #include "LexAccessor.h"
18 #include "Accessor.h"
19 #include "LexerModule.h"
20 #include "LexerBase.h"
21 #include "LexerNoExceptions.h"
23 using namespace Scintilla;
25 Sci_Position SCI_METHOD LexerNoExceptions::PropertySet(const char *key, const char *val) {
26 try {
27 return LexerBase::PropertySet(key, val);
28 } catch (...) {
29 // Should not throw into caller as may be compiled with different compiler or options
31 return -1;
34 Sci_Position SCI_METHOD LexerNoExceptions::WordListSet(int n, const char *wl) {
35 try {
36 return LexerBase::WordListSet(n, wl);
37 } catch (...) {
38 // Should not throw into caller as may be compiled with different compiler or options
40 return -1;
43 void SCI_METHOD LexerNoExceptions::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
44 try {
45 Accessor astyler(pAccess, &props);
46 Lexer(startPos, lengthDoc, initStyle, pAccess, astyler);
47 astyler.Flush();
48 } catch (...) {
49 // Should not throw into caller as may be compiled with different compiler or options
50 pAccess->SetErrorStatus(SC_STATUS_FAILURE);
53 void SCI_METHOD LexerNoExceptions::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
54 try {
55 Accessor astyler(pAccess, &props);
56 Folder(startPos, lengthDoc, initStyle, pAccess, astyler);
57 astyler.Flush();
58 } catch (...) {
59 // Should not throw into caller as may be compiled with different compiler or options
60 pAccess->SetErrorStatus(SC_STATUS_FAILURE);