LexerBase.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Scintilla source code edit control
  2. /** @file LexerBase.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 "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. #ifdef SCI_NAMESPACE
  23. using namespace Scintilla;
  24. #endif
  25. LexerBase::LexerBase() {
  26. for (int wl = 0; wl < numWordLists; wl++)
  27. keyWordLists[wl] = new WordList;
  28. keyWordLists[numWordLists] = 0;
  29. }
  30. LexerBase::~LexerBase() {
  31. for (int wl = 0; wl < numWordLists; wl++) {
  32. delete keyWordLists[wl];
  33. keyWordLists[wl] = 0;
  34. }
  35. keyWordLists[numWordLists] = 0;
  36. }
  37. void SCI_METHOD LexerBase::Release() {
  38. delete this;
  39. }
  40. int SCI_METHOD LexerBase::Version() const {
  41. return lvOriginal;
  42. }
  43. const char * SCI_METHOD LexerBase::PropertyNames() {
  44. return "";
  45. }
  46. int SCI_METHOD LexerBase::PropertyType(const char *) {
  47. return SC_TYPE_BOOLEAN;
  48. }
  49. const char * SCI_METHOD LexerBase::DescribeProperty(const char *) {
  50. return "";
  51. }
  52. Sci_Position SCI_METHOD LexerBase::PropertySet(const char *key, const char *val) {
  53. const char *valOld = props.Get(key);
  54. if (strcmp(val, valOld) != 0) {
  55. props.Set(key, val);
  56. return 0;
  57. } else {
  58. return -1;
  59. }
  60. }
  61. const char * SCI_METHOD LexerBase::DescribeWordListSets() {
  62. return "";
  63. }
  64. Sci_Position SCI_METHOD LexerBase::WordListSet(int n, const char *wl) {
  65. if (n < numWordLists) {
  66. WordList wlNew;
  67. wlNew.Set(wl);
  68. if (*keyWordLists[n] != wlNew) {
  69. keyWordLists[n]->Set(wl);
  70. return 0;
  71. }
  72. }
  73. return -1;
  74. }
  75. void * SCI_METHOD LexerBase::PrivateCall(int, void *) {
  76. return 0;
  77. }