| 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 <string> |
| 12 |
#include <string_view> |
| 13 |
|
| 14 |
#include "ILexer.h" |
| 15 |
#include "Scintilla.h" |
| 16 |
#include "SciLexer.h" |
| 17 |
|
| 18 |
#include "PropSetSimple.h" |
| 19 |
#include "WordList.h" |
| 20 |
#include "LexAccessor.h" |
| 21 |
#include "Accessor.h" |
| 22 |
#include "LexerModule.h" |
| 23 |
#include "LexerBase.h" |
| 24 |
#include "LexerNoExceptions.h" |
| 25 |
|
| 26 |
using namespace Lexilla; |
| 27 |
|
| 28 |
Sci_Position SCI_METHOD LexerNoExceptions::PropertySet(const char *key, const char *val) { |
| 29 |
try { |
| 30 |
return LexerBase::PropertySet(key, val); |
| 31 |
} catch (...) { |
| 32 |
// Should not throw into caller as may be compiled with different compiler or options |
| 33 |
} |
| 34 |
return -1; |
| 35 |
} |
| 36 |
|
| 37 |
Sci_Position SCI_METHOD LexerNoExceptions::WordListSet(int n, const char *wl) { |
| 38 |
try { |
| 39 |
return LexerBase::WordListSet(n, wl); |
| 40 |
} catch (...) { |
| 41 |
// Should not throw into caller as may be compiled with different compiler or options |
| 42 |
} |
| 43 |
return -1; |
| 44 |
} |
| 45 |
|
| 46 |
void SCI_METHOD LexerNoExceptions::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Scintilla::IDocument *pAccess) { |
| 47 |
try { |
| 48 |
Accessor astyler(pAccess, &props); |
| 49 |
Lexer(startPos, lengthDoc, initStyle, pAccess, astyler); |
| 50 |
astyler.Flush(); |
| 51 |
} catch (...) { |
| 52 |
// Should not throw into caller as may be compiled with different compiler or options |
| 53 |
pAccess->SetErrorStatus(SC_STATUS_FAILURE); |
| 54 |
} |
| 55 |
} |
| 56 |
void SCI_METHOD LexerNoExceptions::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Scintilla::IDocument *pAccess) { |
| 57 |
try { |
| 58 |
Accessor astyler(pAccess, &props); |
| 59 |
Folder(startPos, lengthDoc, initStyle, pAccess, astyler); |
| 60 |
astyler.Flush(); |
| 61 |
} catch (...) { |
| 62 |
// Should not throw into caller as may be compiled with different compiler or options |
| 63 |
pAccess->SetErrorStatus(SC_STATUS_FAILURE); |
| 64 |
} |
| 65 |
} |