LexerNoExceptions.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <stdarg.h>
  11. #include <assert.h>
  12. #include <ctype.h>
  13. #include "ILexer.h"
  14. #include "Scintilla.h"
  15. #include "SciLexer.h"
  16. #include "PropSetSimple.h"
  17. #include "WordList.h"
  18. #include "LexAccessor.h"
  19. #include "Accessor.h"
  20. #include "LexerModule.h"
  21. #include "LexerBase.h"
  22. #include "LexerNoExceptions.h"
  23. #ifdef SCI_NAMESPACE
  24. using namespace Scintilla;
  25. #endif
  26. Sci_Position SCI_METHOD LexerNoExceptions::PropertySet(const char *key, const char *val) {
  27. try {
  28. return LexerBase::PropertySet(key, val);
  29. } catch (...) {
  30. // Should not throw into caller as may be compiled with different compiler or options
  31. }
  32. return -1;
  33. }
  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. void SCI_METHOD LexerNoExceptions::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
  43. try {
  44. Accessor astyler(pAccess, &props);
  45. Lexer(startPos, length, initStyle, pAccess, astyler);
  46. astyler.Flush();
  47. } catch (...) {
  48. // Should not throw into caller as may be compiled with different compiler or options
  49. pAccess->SetErrorStatus(SC_STATUS_FAILURE);
  50. }
  51. }
  52. void SCI_METHOD LexerNoExceptions::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
  53. try {
  54. Accessor astyler(pAccess, &props);
  55. Folder(startPos, length, initStyle, pAccess, astyler);
  56. astyler.Flush();
  57. } catch (...) {
  58. // Should not throw into caller as may be compiled with different compiler or options
  59. pAccess->SetErrorStatus(SC_STATUS_FAILURE);
  60. }
  61. }