LexerSimple.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Scintilla source code edit control
  2. /** @file LexerSimple.cxx
  3. ** A simple lexer with no state.
  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 <string>
  14. #include "ILexer.h"
  15. #include "Scintilla.h"
  16. #include "SciLexer.h"
  17. #include "PropSetSimple.h"
  18. #include "WordList.h"
  19. #include "LexAccessor.h"
  20. #include "Accessor.h"
  21. #include "LexerModule.h"
  22. #include "LexerBase.h"
  23. #include "LexerSimple.h"
  24. #ifdef SCI_NAMESPACE
  25. using namespace Scintilla;
  26. #endif
  27. LexerSimple::LexerSimple(const LexerModule *module_) : module(module_) {
  28. for (int wl = 0; wl < module->GetNumWordLists(); wl++) {
  29. if (!wordLists.empty())
  30. wordLists += "\n";
  31. wordLists += module->GetWordListDescription(wl);
  32. }
  33. }
  34. const char * SCI_METHOD LexerSimple::DescribeWordListSets() {
  35. return wordLists.c_str();
  36. }
  37. void SCI_METHOD LexerSimple::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
  38. Accessor astyler(pAccess, &props);
  39. module->Lex(startPos, lengthDoc, initStyle, keyWordLists, astyler);
  40. astyler.Flush();
  41. }
  42. void SCI_METHOD LexerSimple::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
  43. if (props.GetInt("fold")) {
  44. Accessor astyler(pAccess, &props);
  45. module->Fold(startPos, lengthDoc, initStyle, keyWordLists, astyler);
  46. astyler.Flush();
  47. }
  48. }