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