18 skipped lines |
19 | | 19 | | #include "KeyWords.h" |
|
20 | | 20 | | #include "Scintilla.h" |
|
21 | | 21 | | #include "SciLexer.h" |
|
| | 22 | | #include "StyleContext.h" |
|
| | 24 | | #define SCE_LISP_CHARACTER 29 |
| | 25 | | #define SCE_LISP_MACRO 30 |
| | 26 | | #define SCE_LISP_MACRO_DISPATCH 31 |
|
24 | | 28 | | static inline bool isLispoperator(char ch) { |
|
25 | | 29 | | if (isascii(ch) && isalnum(ch)) |
|
|
27 | | if (ch == '\'' || ch == '(' || ch == ')' ) | | 31 | | if (ch == '\'' || ch == '`' || ch == '(' || ch == ')' ) |
|
|
|
4 skipped lines |
|
|
|
38 | | static void classifyWordLisp(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { | | 42 | | static void classifyWordLisp(unsigned int start, unsigned int end, WordList &keywords, WordList &keywords_kw, Accessor &styler) { |
39 | | 43 | | PLATFORM_ASSERT(end >= start); |
|
|
|
9 skipped lines |
|
52 | | 56 | | if (keywords.InList(s)) { |
|
53 | | 57 | | chAttr = SCE_LISP_KEYWORD; |
|
| | 58 | | } else if (keywords_kw.InList(s)) { |
| | 59 | | chAttr = SCE_LISP_KEYWORD_KW; |
| | 60 | | } else if ((s[0] == '*' && s[i-1] == '*') || |
| | 61 | | (s[0] == '+' && s[i-1] == '+')) { |
| | 62 | | chAttr = SCE_LISP_SPECIAL; |
|
|
56 | | 65 | | styler.ColourTo(end, chAttr); |
|
5 skipped lines |
62 | | 71 | | Accessor &styler) { |
|
|
64 | | 73 | | WordList &keywords = *keywordlists[0]; |
|
| | 74 | | WordList &keywords_kw = *keywordlists[1]; |
|
66 | | 76 | | styler.StartAt(startPos); |
|
|
68 | | int state = initStyle; | | 78 | | int state = initStyle, radix = -1; |
69 | | 79 | | char chNext = styler[startPos]; |
|
70 | | 80 | | unsigned int lengthDoc = startPos + length; |
|
71 | | 81 | | styler.StartSegment(startPos); |
|
10 skipped lines |
|
|
84 | | 94 | | if (state == SCE_LISP_DEFAULT) { |
|
| | 95 | | if (ch == '#') { |
| | 96 | | styler.ColourTo(i - 1, state); |
| | 97 | | radix = -1; |
| | 98 | | state = SCE_LISP_MACRO_DISPATCH; |
85 | | if (isLispwordstart(ch)) { | | 99 | | } else if (isLispwordstart(ch)) { |
86 | | 100 | | styler.ColourTo(i - 1, state); |
|
87 | | 101 | | state = SCE_LISP_IDENTIFIER; |
|
|
4 skipped lines |
93 | | 107 | | else if (isLispoperator(ch) || ch=='\'') { |
|
94 | | 108 | | styler.ColourTo(i - 1, state); |
|
95 | | 109 | | styler.ColourTo(i, SCE_LISP_OPERATOR); |
|
| | 110 | | if (ch=='\'' && isLispwordstart(chNext)) { |
| | 111 | | state = SCE_LISP_SYMBOL; |
| | 112 | | } |
|
97 | | 114 | | else if (ch == '\"') { |
|
98 | | 115 | | styler.ColourTo(i - 1, state); |
|
99 | | 116 | | state = SCE_LISP_STRING; |
|
|
101 | | } else if (state == SCE_LISP_IDENTIFIER) { | | 118 | | } else if (state == SCE_LISP_IDENTIFIER || state == SCE_LISP_SYMBOL) { |
102 | | 119 | | if (!isLispwordstart(ch)) { |
|
| | 120 | | if (state == SCE_LISP_IDENTIFIER) { |
103 | | classifyWordLisp(styler.GetStartSegment(), i - 1, keywords, styler); | | 121 | | classifyWordLisp(styler.GetStartSegment(), i - 1, keywords, keywords_kw, styler); |
| | 122 | | } else { |
| | 123 | | styler.ColourTo(i - 1, state); |
| | 124 | | } |
104 | | 125 | | state = SCE_LISP_DEFAULT; |
|
|
106 | | 127 | | if (isLispoperator(ch) || ch=='\'') { |
|
107 | | 128 | | styler.ColourTo(i - 1, state); |
|
108 | | 129 | | styler.ColourTo(i, SCE_LISP_OPERATOR); |
|
| | 130 | | if (ch=='\'' && isLispwordstart(chNext)) { |
| | 131 | | state = SCE_LISP_SYMBOL; |
| | 132 | | } |
| | 133 | | } |
| | 134 | | } else if (state == SCE_LISP_MACRO_DISPATCH) { |
55 skipped lines |
| | 190 | | styler.ColourTo(i - 1, state); |
| | 191 | | styler.ColourTo(i, SCE_LISP_OPERATOR); |
| | 192 | | if (ch=='\'' && isLispwordstart(chNext)) { |
| | 193 | | state = SCE_LISP_SYMBOL; |
| | 194 | | } |
|
110 | | | | |
|
112 | | 197 | | if (state == SCE_LISP_COMMENT) { |
|
|
114 | | 199 | | styler.ColourTo(i - 1, state); |
|
115 | | 200 | | state = SCE_LISP_DEFAULT; |
|
|
| | 202 | | } else if (state == SCE_LISP_MULTI_COMMENT) { |
| | 203 | | if (ch == '|' && chNext == '#') { |
| | 204 | | i++; |
| | 205 | | chNext = styler.SafeGetCharAt(i + 1); |
| | 206 | | styler.ColourTo(i, state); |
| | 207 | | state = SCE_LISP_DEFAULT; |
| | 208 | | } |
117 | | 209 | | } else if (state == SCE_LISP_STRING) { |
|
118 | | 210 | | if (ch == '\\') { |
|
119 | | 211 | | if (chNext == '\"' || chNext == '\'' || chNext == '\\') { |
|
55 skipped lines |
|
|
177 | | 269 | | static const char * const lispWordListDesc[] = { |
|
| | 270 | | "Functions and special operators", |
|
|
|
3 skipped lines |