PageRenderTime 58ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/code/ryzom/client/src/lua_ide_dll_nevrax/source/scintilla/LexOthers.cxx

https://bitbucket.org/mattraykowski/ryzomcore_demoshard
C++ | 576 lines | 484 code | 31 blank | 61 comment | 326 complexity | b007a02a6767be4c3e140302ffdae1d3 MD5 | raw file
Possible License(s): AGPL-3.0, GPL-3.0, LGPL-2.1
  1. // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
  2. // Copyright (C) 2010 Winch Gate Property Limited
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as
  6. // published by the Free Software Foundation, either version 3 of the
  7. // License, or (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. // Scintilla source code edit control
  17. /** @file LexOthers.cxx
  18. ** Lexers for batch files, diff results, properties files, make files and error lists.
  19. ** Also lexer for LaTeX documents.
  20. **/
  21. // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
  22. // The License.txt file describes the conditions under which this software may be distributed.
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <ctype.h>
  26. #include <stdio.h>
  27. #include <stdarg.h>
  28. #include "Platform.h"
  29. #include "PropSet.h"
  30. #include "Accessor.h"
  31. #include "KeyWords.h"
  32. #include "Scintilla.h"
  33. #include "SciLexer.h"
  34. static inline bool AtEOL(Accessor &styler, unsigned int i) {
  35. return (styler[i] == '\n') ||
  36. ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
  37. }
  38. static void ColouriseBatchLine(
  39. char *lineBuffer,
  40. unsigned int lengthLine,
  41. unsigned int startLine,
  42. unsigned int endPos,
  43. WordList &keywords,
  44. Accessor &styler) {
  45. unsigned int i = 0;
  46. unsigned int state = SCE_BAT_DEFAULT;
  47. while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip initial spaces
  48. i++;
  49. }
  50. if (lineBuffer[i] == '@') { // Hide command (ECHO OFF)
  51. styler.ColourTo(startLine + i, SCE_BAT_HIDE);
  52. i++;
  53. while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip next spaces
  54. i++;
  55. }
  56. }
  57. if (lineBuffer[i] == ':') {
  58. // Label
  59. if (lineBuffer[i + 1] == ':') {
  60. // :: is a fake label, similar to REM, see http://content.techweb.com/winmag/columns/explorer/2000/21.htm
  61. styler.ColourTo(endPos, SCE_BAT_COMMENT);
  62. } else { // Real label
  63. styler.ColourTo(endPos, SCE_BAT_LABEL);
  64. }
  65. } else {
  66. // Check if initial word is a keyword
  67. char wordBuffer[21];
  68. unsigned int wbl = 0, offset = i;
  69. // Copy word in buffer
  70. for (; offset < lengthLine && wbl < 20 &&
  71. !isspacechar(lineBuffer[offset]); wbl++, offset++) {
  72. wordBuffer[wbl] = static_cast<char>(tolower(lineBuffer[offset]));
  73. }
  74. wordBuffer[wbl] = '\0';
  75. // Check if it is a comment
  76. if (CompareCaseInsensitive(wordBuffer, "rem") == 0) {
  77. styler.ColourTo(endPos, SCE_BAT_COMMENT);
  78. return ;
  79. }
  80. // Check if it is in the list
  81. if (keywords.InList(wordBuffer)) {
  82. styler.ColourTo(startLine + offset - 1, SCE_BAT_WORD); // Regular keyword
  83. } else {
  84. // Search end of word (can be a long path)
  85. while (offset < lengthLine &&
  86. !isspacechar(lineBuffer[offset])) {
  87. offset++;
  88. }
  89. styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); // External command / program
  90. }
  91. // Remainder of the line: colourise the variables.
  92. while (offset < lengthLine) {
  93. if (state == SCE_BAT_DEFAULT && lineBuffer[offset] == '%') {
  94. styler.ColourTo(startLine + offset - 1, state);
  95. if (isdigit(lineBuffer[offset + 1])) {
  96. styler.ColourTo(startLine + offset + 1, SCE_BAT_IDENTIFIER);
  97. offset += 2;
  98. } else if (lineBuffer[offset + 1] == '%' &&
  99. !isspacechar(lineBuffer[offset + 2])) {
  100. // Should be safe, as there is CRLF at the end of the line...
  101. styler.ColourTo(startLine + offset + 2, SCE_BAT_IDENTIFIER);
  102. offset += 3;
  103. } else {
  104. state = SCE_BAT_IDENTIFIER;
  105. }
  106. } else if (state == SCE_BAT_IDENTIFIER && lineBuffer[offset] == '%') {
  107. styler.ColourTo(startLine + offset, state);
  108. state = SCE_BAT_DEFAULT;
  109. } else if (state == SCE_BAT_DEFAULT &&
  110. (lineBuffer[offset] == '*' ||
  111. lineBuffer[offset] == '?' ||
  112. lineBuffer[offset] == '=' ||
  113. lineBuffer[offset] == '<' ||
  114. lineBuffer[offset] == '>' ||
  115. lineBuffer[offset] == '|')) {
  116. styler.ColourTo(startLine + offset - 1, state);
  117. styler.ColourTo(startLine + offset, SCE_BAT_OPERATOR);
  118. }
  119. offset++;
  120. }
  121. // if (endPos > startLine + offset - 1) {
  122. styler.ColourTo(endPos, SCE_BAT_DEFAULT); // Remainder of line, currently not lexed
  123. // }
  124. }
  125. }
  126. // ToDo: (not necessarily at beginning of line) GOTO, [IF] NOT, ERRORLEVEL
  127. // IF [NO] (test) (command) -- test is EXIST (filename) | (string1)==(string2) | ERRORLEVEL (number)
  128. // FOR %%(variable) IN (set) DO (command) -- variable is [a-zA-Z] -- eg for %%X in (*.txt) do type %%X
  129. // ToDo: %n (parameters), %EnvironmentVariable% colourising
  130. // ToDo: Colourise = > >> < | "
  131. static void ColouriseBatchDoc(
  132. unsigned int startPos,
  133. int length,
  134. int /*initStyle*/,
  135. WordList *keywordlists[],
  136. Accessor &styler) {
  137. char lineBuffer[1024];
  138. WordList &keywords = *keywordlists[0];
  139. styler.StartAt(startPos);
  140. styler.StartSegment(startPos);
  141. unsigned int linePos = 0;
  142. unsigned int startLine = startPos;
  143. for (unsigned int i = startPos; i < startPos + length; i++) {
  144. lineBuffer[linePos++] = styler[i];
  145. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  146. // End of line (or of line buffer) met, colourise it
  147. lineBuffer[linePos] = '\0';
  148. ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler);
  149. linePos = 0;
  150. startLine = i + 1;
  151. }
  152. }
  153. if (linePos > 0) { // Last line does not have ending characters
  154. ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
  155. keywords, styler);
  156. }
  157. }
  158. static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
  159. // It is needed to remember the current state to recognize starting
  160. // comment lines before the first "diff " or "--- ". If a real
  161. // difference starts then each line starting with ' ' is a whitespace
  162. // otherwise it is considered a comment (Only in..., Binary file...)
  163. if (0 == strncmp(lineBuffer, "diff ", 3)) {
  164. styler.ColourTo(endLine, SCE_DIFF_COMMAND);
  165. } else if (0 == strncmp(lineBuffer, "--- ", 3)) {
  166. styler.ColourTo(endLine, SCE_DIFF_HEADER);
  167. } else if (0 == strncmp(lineBuffer, "+++ ", 3)) {
  168. styler.ColourTo(endLine, SCE_DIFF_HEADER);
  169. } else if (0 == strncmp(lineBuffer, "***", 3)) {
  170. styler.ColourTo(endLine, SCE_DIFF_HEADER);
  171. } else if (lineBuffer[0] == '@') {
  172. styler.ColourTo(endLine, SCE_DIFF_POSITION);
  173. } else if (lineBuffer[0] == '-') {
  174. styler.ColourTo(endLine, SCE_DIFF_DELETED);
  175. } else if (lineBuffer[0] == '+') {
  176. styler.ColourTo(endLine, SCE_DIFF_ADDED);
  177. } else if (lineBuffer[0] != ' ') {
  178. styler.ColourTo(endLine, SCE_DIFF_COMMENT);
  179. } else {
  180. styler.ColourTo(endLine, SCE_DIFF_DEFAULT);
  181. }
  182. }
  183. static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
  184. char lineBuffer[1024];
  185. styler.StartAt(startPos);
  186. styler.StartSegment(startPos);
  187. unsigned int linePos = 0;
  188. for (unsigned int i = startPos; i < startPos + length; i++) {
  189. lineBuffer[linePos++] = styler[i];
  190. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  191. // End of line (or of line buffer) met, colourise it
  192. lineBuffer[linePos] = '\0';
  193. ColouriseDiffLine(lineBuffer, i, styler);
  194. linePos = 0;
  195. }
  196. }
  197. if (linePos > 0) { // Last line does not have ending characters
  198. ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
  199. }
  200. }
  201. static void ColourisePropsLine(
  202. char *lineBuffer,
  203. unsigned int lengthLine,
  204. unsigned int startLine,
  205. unsigned int endPos,
  206. Accessor &styler) {
  207. unsigned int i = 0;
  208. while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
  209. i++;
  210. if (i < lengthLine) {
  211. if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
  212. styler.ColourTo(endPos, SCE_PROPS_COMMENT);
  213. } else if (lineBuffer[i] == '[') {
  214. styler.ColourTo(endPos, SCE_PROPS_SECTION);
  215. } else if (lineBuffer[i] == '@') {
  216. styler.ColourTo(startLine + i, SCE_PROPS_DEFVAL);
  217. if (lineBuffer[++i] == '=')
  218. styler.ColourTo(startLine + i, SCE_PROPS_ASSIGNMENT);
  219. styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
  220. } else {
  221. // Search for the '=' character
  222. while ((i < lengthLine) && (lineBuffer[i] != '='))
  223. i++;
  224. if ((i < lengthLine) && (lineBuffer[i] == '=')) {
  225. styler.ColourTo(startLine + i - 1, SCE_PROPS_DEFAULT);
  226. styler.ColourTo(startLine + i, 3);
  227. styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
  228. } else {
  229. styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
  230. }
  231. }
  232. } else {
  233. styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
  234. }
  235. }
  236. static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
  237. char lineBuffer[1024];
  238. styler.StartAt(startPos);
  239. styler.StartSegment(startPos);
  240. unsigned int linePos = 0;
  241. unsigned int startLine = startPos;
  242. for (unsigned int i = startPos; i < startPos + length; i++) {
  243. lineBuffer[linePos++] = styler[i];
  244. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  245. // End of line (or of line buffer) met, colourise it
  246. lineBuffer[linePos] = '\0';
  247. ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
  248. linePos = 0;
  249. startLine = i + 1;
  250. }
  251. }
  252. if (linePos > 0) { // Last line does not have ending characters
  253. ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
  254. }
  255. }
  256. static void ColouriseMakeLine(
  257. char *lineBuffer,
  258. unsigned int lengthLine,
  259. unsigned int startLine,
  260. unsigned int endPos,
  261. Accessor &styler) {
  262. unsigned int i = 0;
  263. unsigned int lastNonSpace = 0;
  264. unsigned int state = SCE_MAKE_DEFAULT;
  265. bool bSpecial = false;
  266. // Skip initial spaces
  267. while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
  268. i++;
  269. }
  270. if (lineBuffer[i] == '#') { // Comment
  271. styler.ColourTo(endPos, SCE_MAKE_COMMENT);
  272. return;
  273. }
  274. if (lineBuffer[i] == '!') { // Special directive
  275. styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
  276. return;
  277. }
  278. while (i < lengthLine) {
  279. if (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(') {
  280. styler.ColourTo(startLine + i - 1, state);
  281. state = SCE_MAKE_IDENTIFIER;
  282. } else if (state == SCE_MAKE_IDENTIFIER && lineBuffer[i] == ')') {
  283. styler.ColourTo(startLine + i, state);
  284. state = SCE_MAKE_DEFAULT;
  285. }
  286. if (!bSpecial) {
  287. if (lineBuffer[i] == ':') {
  288. // We should check that no colouring was made since the beginning of the line,
  289. // to avoid colouring stuff like /OUT:file
  290. styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
  291. styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
  292. styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
  293. bSpecial = true; // Only react to the first ':' of the line
  294. state = SCE_MAKE_DEFAULT;
  295. } else if (lineBuffer[i] == '=') {
  296. styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_IDENTIFIER);
  297. styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
  298. styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
  299. bSpecial = true; // Only react to the first '=' of the line
  300. state = SCE_MAKE_DEFAULT;
  301. }
  302. }
  303. if (!isspacechar(lineBuffer[i])) {
  304. lastNonSpace = i;
  305. }
  306. i++;
  307. }
  308. if (state == SCE_MAKE_IDENTIFIER) {
  309. styler.ColourTo(endPos, SCE_MAKE_IDEOL); // Error, variable reference not ended
  310. } else {
  311. styler.ColourTo(endPos, SCE_MAKE_DEFAULT);
  312. }
  313. }
  314. static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
  315. char lineBuffer[1024];
  316. styler.StartAt(startPos);
  317. styler.StartSegment(startPos);
  318. unsigned int linePos = 0;
  319. unsigned int startLine = startPos;
  320. for (unsigned int i = startPos; i < startPos + length; i++) {
  321. lineBuffer[linePos++] = styler[i];
  322. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  323. // End of line (or of line buffer) met, colourise it
  324. lineBuffer[linePos] = '\0';
  325. ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
  326. linePos = 0;
  327. startLine = i + 1;
  328. }
  329. }
  330. if (linePos > 0) { // Last line does not have ending characters
  331. ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
  332. }
  333. }
  334. static void ColouriseErrorListLine(
  335. char *lineBuffer,
  336. unsigned int lengthLine,
  337. // unsigned int startLine,
  338. unsigned int endPos,
  339. Accessor &styler) {
  340. if (lineBuffer[0] == '>') {
  341. // Command or return status
  342. styler.ColourTo(endPos, SCE_ERR_CMD);
  343. } else if (lineBuffer[0] == '!') {
  344. styler.ColourTo(endPos, SCE_ERR_DIFF_CHANGED);
  345. } else if (lineBuffer[0] == '+') {
  346. styler.ColourTo(endPos, SCE_ERR_DIFF_ADDITION);
  347. } else if (lineBuffer[0] == '-' && lineBuffer[1] == '-' && lineBuffer[2] == '-') {
  348. styler.ColourTo(endPos, SCE_ERR_DIFF_MESSAGE);
  349. } else if (lineBuffer[0] == '-') {
  350. styler.ColourTo(endPos, SCE_ERR_DIFF_DELETION);
  351. } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
  352. styler.ColourTo(endPos, SCE_ERR_PYTHON);
  353. } else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) {
  354. // Borland error message
  355. styler.ColourTo(endPos, SCE_ERR_BORLAND);
  356. } else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) {
  357. // Borland warning message
  358. styler.ColourTo(endPos, SCE_ERR_BORLAND);
  359. } else if (strstr(lineBuffer, "at line " ) &&
  360. (strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
  361. strstr(lineBuffer, "file ") &&
  362. (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
  363. // Lua error message
  364. styler.ColourTo(endPos, SCE_ERR_LUA);
  365. } else if (strstr(lineBuffer, " at " ) &&
  366. (strstr(lineBuffer, " at " ) < (lineBuffer + lengthLine)) &&
  367. strstr(lineBuffer, " line ") &&
  368. (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine))) {
  369. // perl error message
  370. styler.ColourTo(endPos, SCE_ERR_PERL);
  371. } else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
  372. strstr(lineBuffer, ":line ")) {
  373. // A .NET traceback
  374. styler.ColourTo(endPos, SCE_ERR_NET);
  375. } else {
  376. // Look for <filename>:<line>:message
  377. // Look for <filename>(line)message
  378. // Look for <filename>(line,pos)message
  379. int state = 0;
  380. for (unsigned int i = 0; i < lengthLine; i++) {
  381. if ((state == 0) && (lineBuffer[i] == ':') && isdigit(lineBuffer[i + 1])) {
  382. state = 1;
  383. } else if ((state == 0) && (lineBuffer[i] == '(')) {
  384. state = 10;
  385. } else if ((state == 0) && (lineBuffer[i] == '\t')) {
  386. state = 20;
  387. } else if ((state == 1) && isdigit(lineBuffer[i])) {
  388. state = 2;
  389. } else if ((state == 2) && (lineBuffer[i] == ':')) {
  390. state = 3;
  391. break;
  392. } else if ((state == 2) && !isdigit(lineBuffer[i])) {
  393. state = 99;
  394. } else if ((state == 10) && isdigit(lineBuffer[i])) {
  395. state = 11;
  396. } else if ((state == 11) && (lineBuffer[i] == ',')) {
  397. state = 14;
  398. } else if ((state == 11) && (lineBuffer[i] == ')')) {
  399. state = 12;
  400. } else if ((state == 12) && (lineBuffer[i] == ':')) {
  401. state = 13;
  402. } else if ((state == 14) && (lineBuffer[i] == ')')) {
  403. state = 15;
  404. break;
  405. } else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
  406. state = 99;
  407. } else if ((state == 20) && isdigit(lineBuffer[i])) {
  408. state = 24;
  409. break;
  410. } else if ((state == 20) && ((lineBuffer[i] == '/') && (lineBuffer[i+1] == '^'))) {
  411. state = 21;
  412. } else if ((state == 21) && ((lineBuffer[i] == '$') && (lineBuffer[i+1] == '/'))) {
  413. state = 22;
  414. break;
  415. }
  416. }
  417. if (state == 3) {
  418. styler.ColourTo(endPos, SCE_ERR_GCC);
  419. } else if ((state == 13) || (state == 14) || (state == 15)) {
  420. styler.ColourTo(endPos, SCE_ERR_MS);
  421. } else if (((state == 22) || (state == 24)) && (lineBuffer[0] != '\t')) {
  422. styler.ColourTo(endPos, SCE_ERR_CTAG);
  423. } else {
  424. styler.ColourTo(endPos, SCE_ERR_DEFAULT);
  425. }
  426. }
  427. }
  428. static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
  429. char lineBuffer[1024];
  430. styler.StartAt(startPos);
  431. styler.StartSegment(startPos);
  432. unsigned int linePos = 0;
  433. for (unsigned int i = startPos; i < startPos + length; i++) {
  434. lineBuffer[linePos++] = styler[i];
  435. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  436. // End of line (or of line buffer) met, colourise it
  437. lineBuffer[linePos] = '\0';
  438. ColouriseErrorListLine(lineBuffer, linePos, i, styler);
  439. linePos = 0;
  440. }
  441. }
  442. if (linePos > 0) { // Last line does not have ending characters
  443. ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
  444. }
  445. }
  446. static int isSpecial(char s) {
  447. return (s == '\\') || (s == ',') || (s == ';') || (s == '\'') || (s == ' ') ||
  448. (s == '\"') || (s == '`') || (s == '^') || (s == '~');
  449. }
  450. static int isTag(int start, Accessor &styler) {
  451. char s[6];
  452. unsigned int i = 0, e = 1;
  453. while (i < 5 && e) {
  454. s[i] = styler[start + i];
  455. i++;
  456. e = styler[start + i] != '{';
  457. }
  458. s[i] = '\0';
  459. return (strcmp(s, "begin") == 0) || (strcmp(s, "end") == 0);
  460. }
  461. static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
  462. WordList *[], Accessor &styler) {
  463. styler.StartAt(startPos);
  464. int state = initStyle;
  465. char chNext = styler[startPos];
  466. styler.StartSegment(startPos);
  467. int lengthDoc = startPos + length;
  468. for (int i = startPos; i < lengthDoc; i++) {
  469. char ch = chNext;
  470. chNext = styler.SafeGetCharAt(i + 1);
  471. if (styler.IsLeadByte(ch)) {
  472. chNext = styler.SafeGetCharAt(i + 2);
  473. i++;
  474. continue;
  475. }
  476. switch (state) {
  477. case SCE_L_DEFAULT :
  478. switch (ch) {
  479. case '\\' :
  480. styler.ColourTo(i - 1, state);
  481. if (isSpecial(styler[i + 1])) {
  482. styler.ColourTo(i + 1, SCE_L_COMMAND);
  483. i++;
  484. chNext = styler.SafeGetCharAt(i + 1);
  485. } else {
  486. if (isTag(i + 1, styler))
  487. state = SCE_L_TAG;
  488. else
  489. state = SCE_L_COMMAND;
  490. }
  491. break;
  492. case '$' :
  493. styler.ColourTo(i - 1, state);
  494. state = SCE_L_MATH;
  495. if (chNext == '$') {
  496. i++;
  497. chNext = styler.SafeGetCharAt(i + 1);
  498. }
  499. break;
  500. case '%' :
  501. styler.ColourTo(i - 1, state);
  502. state = SCE_L_COMMENT;
  503. break;
  504. }
  505. break;
  506. case SCE_L_COMMAND :
  507. if (chNext == '[' || chNext == '{' || chNext == '}' ||
  508. chNext == ' ' || chNext == '\r' || chNext == '\n') {
  509. styler.ColourTo(i, state);
  510. state = SCE_L_DEFAULT;
  511. i++;
  512. chNext = styler.SafeGetCharAt(i + 1);
  513. }
  514. break;
  515. case SCE_L_TAG :
  516. if (ch == '}') {
  517. styler.ColourTo(i, state);
  518. state = SCE_L_DEFAULT;
  519. }
  520. break;
  521. case SCE_L_MATH :
  522. if (ch == '$') {
  523. if (chNext == '$') {
  524. i++;
  525. chNext = styler.SafeGetCharAt(i + 1);
  526. }
  527. styler.ColourTo(i, state);
  528. state = SCE_L_DEFAULT;
  529. }
  530. break;
  531. case SCE_L_COMMENT :
  532. if (ch == '\r' || ch == '\n') {
  533. styler.ColourTo(i - 1, state);
  534. state = SCE_L_DEFAULT;
  535. }
  536. }
  537. }
  538. styler.ColourTo(lengthDoc, state);
  539. }
  540. LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch");
  541. LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff");
  542. LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props");
  543. LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile");
  544. LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist");
  545. LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex");