TQt conversion of scintilla for Qt3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KeyWords.h 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Scintilla source code edit control
  2. /** @file KeyWords.h
  3. ** Colourise for particular languages.
  4. **/
  5. // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
  6. // The License.txt file describes the conditions under which this software may be distributed.
  7. typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
  8. WordList *keywordlists[], Accessor &styler);
  9. /**
  10. * A LexerModule is responsible for lexing and folding a particular language.
  11. * The class maintains a list of LexerModules which can be searched to find a
  12. * module appropriate to a particular language.
  13. */
  14. class LexerModule {
  15. protected:
  16. const LexerModule *next;
  17. int language;
  18. LexerFunction fnLexer;
  19. LexerFunction fnFolder;
  20. const char * const * wordListDescriptions;
  21. int styleBits;
  22. static const LexerModule *base;
  23. static int nextLanguage;
  24. public:
  25. const char *languageName;
  26. LexerModule(int language_,
  27. LexerFunction fnLexer_,
  28. const char *languageName_=0,
  29. LexerFunction fnFolder_=0,
  30. const char * const wordListDescriptions_[] = NULL,
  31. int styleBits_=5);
  32. virtual ~LexerModule() {
  33. }
  34. int GetLanguage() const { return language; }
  35. // -1 is returned if no WordList information is available
  36. int GetNumWordLists() const;
  37. const char *GetWordListDescription(int index) const;
  38. int GetStyleBitsNeeded() const;
  39. virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
  40. WordList *keywordlists[], Accessor &styler) const;
  41. virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
  42. WordList *keywordlists[], Accessor &styler) const;
  43. static const LexerModule *Find(int language);
  44. static const LexerModule *Find(const char *languageName);
  45. };
  46. /**
  47. * Check if a character is a space.
  48. * This is ASCII specific but is safe with chars >= 0x80.
  49. */
  50. inline bool isspacechar(unsigned char ch) {
  51. return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
  52. }
  53. inline bool iswordchar(char ch) {
  54. return isascii(ch) && (isalnum(ch) || ch == '.' || ch == '_');
  55. }
  56. inline bool iswordstart(char ch) {
  57. return isascii(ch) && (isalnum(ch) || ch == '_');
  58. }
  59. inline bool isoperator(char ch) {
  60. if (isascii(ch) && isalnum(ch))
  61. return false;
  62. // '.' left out as it is used to make up numbers
  63. if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
  64. ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
  65. ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
  66. ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
  67. ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
  68. ch == '?' || ch == '!' || ch == '.' || ch == '~')
  69. return true;
  70. return false;
  71. }