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 <[email protected]>
6 // The License.txt file describes the conditions under which this software may be distributed.
7
8 #include <cstdlib>
9 #include <cassert>
10
11 #include "ILexer.h"
12 #include "Scintilla.h"
13 #include "SciLexer.h"
14
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"
22
23 using namespace Scintilla;
24
PropertySet(const char * key,const char * val)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
30 }
31 return -1;
32 }
33
WordListSet(int n,const char * wl)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
39 }
40 return -1;
41 }
42
Lex(Sci_PositionU startPos,Sci_Position lengthDoc,int initStyle,IDocument * pAccess)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);
51 }
52 }
Fold(Sci_PositionU startPos,Sci_Position lengthDoc,int initStyle,IDocument * pAccess)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);
61 }
62 }
63