aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2004-03-27 10:22:45 +0000
committernyamatongwe <unknown>2004-03-27 10:22:45 +0000
commit86f4f39767c54295cf1103bdfb596da4d6676285 (patch)
tree9268f9374b606bdaaba6d5d897c2f194e307ee74 /src
parent93ae9c7f3dc276628d162c53267b65b89685ead2 (diff)
downloadscintilla-mirror-86f4f39767c54295cf1103bdfb596da4d6676285.tar.gz
Added AutoIt 3 and APDL lexers.
MSSQL lexer entended with STORED_PROCEDURE, DEFAULT_PREF_DATATYPE, and COLUMN_NAME_2 style classes.
Diffstat (limited to 'src')
-rw-r--r--src/KeyWords.cxx2
-rw-r--r--src/LexAPDL.cxx174
-rw-r--r--src/LexAU3.cxx218
-rw-r--r--src/LexMSSQL.cxx231
4 files changed, 528 insertions, 97 deletions
diff --git a/src/KeyWords.cxx b/src/KeyWords.cxx
index cc9c4afcc..717d251f7 100644
--- a/src/KeyWords.cxx
+++ b/src/KeyWords.cxx
@@ -130,7 +130,9 @@ int Scintilla_LinkLexers() {
//++Autogenerated -- run src/LexGen.py to regenerate
//**\(\tLINK_LEXER(\*);\n\)
LINK_LEXER(lmAda);
+ LINK_LEXER(lmAPDL);
LINK_LEXER(lmAsm);
+ LINK_LEXER(lmAU3);
LINK_LEXER(lmAVE);
LINK_LEXER(lmBaan);
LINK_LEXER(lmBullant);
diff --git a/src/LexAPDL.cxx b/src/LexAPDL.cxx
new file mode 100644
index 000000000..b739e9a7c
--- /dev/null
+++ b/src/LexAPDL.cxx
@@ -0,0 +1,174 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+
+static inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '/' || ch == '*');
+}
+
+inline bool IsABlank(unsigned int ch) {
+ return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ;
+}
+
+
+
+static void ColouriseAPDLDoc(unsigned int startPos, int length, int initStyle,
+ WordList *keywordlists[], Accessor &styler)
+{
+
+ //~ FILE *fp;
+ //~ fp = fopen("myoutput.txt", "w");
+
+ WordList &commands = *keywordlists[0];
+ WordList &processors = *keywordlists[1];
+ WordList &functions = *keywordlists[2];
+
+
+ // backtrack to the beginning of the document, this may be slow for big documents.
+ initStyle = SCE_APDL_DEFAULT;
+ StyleContext sc(0, startPos+length, initStyle, styler);
+
+ // backtrack to the nearest keyword
+ //~ while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_APDL_WORD)) {
+ //~ startPos--;
+ //~ }
+ //~ startPos = styler.LineStart(styler.GetLine(startPos));
+ //~ initStyle = styler.StyleAt(startPos - 1);
+ //~ StyleContext sc(startPos, endPos-startPos, initStyle, styler);
+
+ bool firstInLine = true;
+ bool atEOL;
+
+ for (; sc.More(); sc.Forward()) {
+
+ atEOL = (sc.ch == '\r' && sc.chNext == '\n') || (sc.ch == '\n');
+
+ //~ if (sc.ch == '\r') {
+ //~ fprintf(fp,"CR\t%d\t%d", atEOL, firstInLine);
+ //~ } else if (sc.ch == '\n') {
+ //~ fprintf(fp,"LF\t%d\t%d", atEOL, firstInLine);
+ //~ } else {
+ //~ fprintf(fp,"%c\t%d\t%d", sc.ch, atEOL, firstInLine);
+ //~ }
+
+ // Determine if the current state should terminate.
+ if (sc.state == SCE_APDL_COMMENT) {
+ //~ fprintf(fp,"\tCOMMENT");
+ if (atEOL) {
+ sc.SetState(SCE_APDL_DEFAULT);
+ }
+ } else if (sc.state == SCE_APDL_COMMENTBLOCK) {
+ //~ fprintf(fp,"\tCOMMENTBLOCK");
+ if (atEOL) {
+ if (sc.ch == '\r') {
+ sc.Forward();
+ }
+ sc.ForwardSetState(SCE_APDL_DEFAULT);
+ }
+ } else if (sc.state == SCE_APDL_NUMBER) {
+ //~ fprintf(fp,"\tNUMBER");
+ if (isdigit(sc.ch)) {
+ } else if ((sc.ch == 'e' || sc.ch == 'E') && (isdigit(sc.chNext) || sc.chNext == '+' || sc.chNext == '-')) {
+ } else if (sc.ch == '.') {
+ } else if ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')) {
+ } else {
+ sc.SetState(SCE_APDL_DEFAULT);
+ }
+ } else if (sc.state == SCE_APDL_STRING) {
+ //~ fprintf(fp,"\tSTRING");
+ if (sc.ch == '\"') {
+ //~ sc.ForwardSetState(SCE_APDL_DEFAULT);
+ sc.Forward();
+ atEOL = (sc.ch == '\r' && sc.chNext == '\n') || (sc.ch == '\n');
+ if (atEOL) {
+ firstInLine = true;
+ }
+ sc.SetState(SCE_APDL_DEFAULT);
+ }
+ } else if (sc.state == SCE_APDL_WORD) {
+ //~ fprintf(fp,"\tWORD");
+ if (!IsAWordChar(sc.ch) || sc.ch == '%') {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (commands.InList(s) && firstInLine) {
+ if (IsABlank(sc.ch) || sc.ch == ',' || atEOL) {
+ sc.ChangeState(SCE_APDL_COMMAND);
+ }
+ if (sc.ch != '\n') {
+ firstInLine = false;
+ }
+ } else if (processors.InList(s)) {
+ if (IsABlank(sc.ch) || atEOL) {
+ sc.ChangeState(SCE_APDL_PROCESSOR);
+ while (sc.ch != '\n') {
+ sc.Forward();
+ }
+ sc.Forward();
+ }
+ } else if (functions.InList(s)) {
+ sc.ChangeState(SCE_APDL_FUNCTION);
+ if (sc.ch != '\n') {
+ firstInLine = false;
+ }
+ } else {
+ if (sc.ch != '\n') {
+ firstInLine = false;
+ }
+ }
+ sc.SetState(SCE_APDL_DEFAULT);
+ }
+ }
+
+ // Determine if a new state should be entered.
+ if (sc.state == SCE_APDL_DEFAULT) {
+ if (sc.ch == '!' && sc.chNext != '!') {
+ sc.SetState(SCE_APDL_COMMENT);
+ } else if (sc.ch == '!' && sc.chNext == '!') {
+ sc.SetState(SCE_APDL_COMMENTBLOCK);
+ } else if (IsADigit(sc.ch) && !IsAWordChar(sc.chPrev)) {
+ sc.SetState(SCE_APDL_NUMBER);
+ } else if (sc.ch == '.' && (isoperator(static_cast<char>(sc.chPrev)) ||
+ IsABlank(sc.chPrev) || sc.chPrev == '\n' || sc.chPrev == '\r')) {
+ sc.SetState(SCE_APDL_NUMBER);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_APDL_STRING);
+ } else if (IsAWordStart(sc.ch) && (!IsADigit(sc.chPrev))) {
+ sc.SetState(SCE_APDL_WORD);
+ }
+
+ }
+ //~ fprintf(fp,"\n");
+
+ if (atEOL) {
+ firstInLine = true;
+ }
+
+ }
+ sc.Complete();
+}
+
+static const char * const apdlWordListDesc[] = {
+ "Commands",
+ "Processors",
+ "Functions",
+ 0
+};
+
+LexerModule lmAPDL(SCLEX_APDL, ColouriseAPDLDoc, "apdl", 0, apdlWordListDesc);
diff --git a/src/LexAU3.cxx b/src/LexAU3.cxx
new file mode 100644
index 000000000..0ed51ec47
--- /dev/null
+++ b/src/LexAU3.cxx
@@ -0,0 +1,218 @@
+// Scintilla source code edit control
+// @file LexAU3.cxx
+// Lexer for AutoIt3 http://www.hiddensoft.com/autoit3
+// by Jos van der Zande, jvdzande@yahoo.com
+//
+// Changes:
+//
+// Copyright for Scintilla: 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+// Scintilla source code edit control
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+static inline bool IsTypeCharacter(const int ch)
+{
+ return ch == '$';
+}
+static inline bool IsAWordChar(const int ch)
+{
+ return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '-');
+}
+
+static inline bool IsAWordStart(const int ch)
+{
+ return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '@' || ch == '#' || ch == '{' || ch == '+' || ch == '!' || ch == '#' || ch == '^');
+}
+
+static void ColouriseAU3Doc(unsigned int startPos,
+ int length, int initStyle,
+ WordList *keywordlists[],
+ Accessor &styler) {
+
+ WordList &keywords = *keywordlists[0];
+ WordList &keywords2 = *keywordlists[1];
+ WordList &keywords3 = *keywordlists[2];
+ WordList &keywords4 = *keywordlists[3];
+ styler.StartAt(startPos);
+
+ StyleContext sc(startPos, length, initStyle, styler);
+ char si,sk;
+ si=0;
+ sk=0;
+ for (; sc.More(); sc.Forward()) {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ switch (sc.state)
+ {
+ case SCE_AU3_COMMENTBLOCK:
+ {
+ if (sc.ch == '#') {sc.SetState(SCE_AU3_DEFAULT);}
+ break;
+ }
+ case SCE_AU3_COMMENT:
+ {
+ if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
+ break;
+ }
+ case SCE_AU3_OPERATOR:
+ {
+ sc.SetState(SCE_AU3_DEFAULT);
+ break;
+ }
+ case SCE_AU3_KEYWORD:
+ {
+ if (!IsAWordChar(sc.ch))
+ {
+ if (!IsTypeCharacter(sc.ch))
+ {
+ if (strcmp(s, "#cs")==0 || strcmp(s, "#comments_start")==0)
+ {
+ sc.ChangeState(SCE_AU3_COMMENTBLOCK);
+ sc.SetState(SCE_AU3_COMMENTBLOCK);
+ }
+ else if (strcmp(s, "#ce")==0 || strcmp(s, "#comments_end")==0)
+ {
+ sc.ChangeState(SCE_AU3_COMMENTBLOCK);
+ sc.SetState(SCE_AU3_DEFAULT);
+ }
+ else if (keywords.InList(s)) {
+ sc.ChangeState(SCE_AU3_KEYWORD);
+ sc.SetState(SCE_AU3_DEFAULT);
+ //sc.SetState(SCE_AU3_KEYWORD);
+ }
+ else if (keywords2.InList(s)) {
+ sc.ChangeState(SCE_AU3_FUNCTION);
+ sc.SetState(SCE_AU3_DEFAULT);
+ //sc.SetState(SCE_AU3_FUNCTION);
+ }
+ else if (keywords3.InList(s)) {
+ sc.ChangeState(SCE_AU3_MACRO);
+ sc.SetState(SCE_AU3_DEFAULT);
+ }
+ else if (!IsAWordChar(sc.ch)) {
+ sc.ChangeState(SCE_AU3_DEFAULT);
+ sc.SetState(SCE_AU3_DEFAULT);
+ }
+ }
+ }
+ if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
+ break;
+ }
+ case SCE_AU3_NUMBER:
+ {
+ if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_AU3_DEFAULT);}
+ break;
+ }
+ case SCE_AU3_VARIABLE:
+ {
+ if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_AU3_DEFAULT);}
+ break;
+ }
+ case SCE_AU3_STRING:
+ {
+ sk = 0;
+ // check for " in and single qouted string
+ if (si == 1){
+ if (sc.ch == '\"'){sc.ForwardSetState(SCE_AU3_DEFAULT);}}
+ // check for ' in and double qouted string
+ if (si == 2){
+ if (sc.ch == '\''){sc.ForwardSetState(SCE_AU3_DEFAULT);}}
+ if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
+ // find Sendkeys in an STRING
+ if (sc.ch == '{') {sc.SetState(SCE_AU3_SENT);}
+ if (sc.ch == '+' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
+ if (sc.ch == '!' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
+ if (sc.ch == '^' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
+ if (sc.ch == '#' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
+ break;
+ }
+
+ case SCE_AU3_SENT:
+ {
+ // Sent key string ended
+ if (sk == 1)
+ {
+ // set color to SENTKEY when valid sentkey .. else set to comment to show its wrong
+ if (keywords4.InList(s))
+ {
+ sc.ChangeState(SCE_AU3_SENT);
+ }
+ else
+ {
+ sc.ChangeState(SCE_AU3_STRING);
+ }
+ sc.SetState(SCE_AU3_STRING);
+ sk=0;
+ }
+ // check if next portion is again a sentkey
+ if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
+ if (sc.ch == '{') {sc.SetState(SCE_AU3_SENT);}
+ if (sc.ch == '+' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
+ if (sc.ch == '!' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
+ if (sc.ch == '^' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
+ if (sc.ch == '#' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);}
+ // check to see if the string ended...
+ // check for " in and single qouted string
+ if (si == 1){
+ if (sc.ch == '\"'){sc.ForwardSetState(SCE_AU3_DEFAULT);}}
+ // check for ' in and double qouted string
+ if (si == 2){
+ if (sc.ch == '\''){sc.ForwardSetState(SCE_AU3_DEFAULT);}}
+ break;
+ }
+ } //switch (sc.state)
+
+ // Determine if a new state should be entered:
+ if (sc.state == SCE_AU3_SENT)
+ {
+ if (sc.ch == '}' && sc.chNext != '}')
+ {
+ sk = 1;
+ }
+ }
+ if (sc.state == SCE_AU3_DEFAULT)
+ {
+ if (sc.ch == ';') {sc.SetState(SCE_AU3_COMMENT);}
+ else if (sc.ch == '#') {sc.SetState(SCE_AU3_KEYWORD);}
+ else if (IsAWordStart(sc.ch)) {sc.SetState(SCE_AU3_KEYWORD);}
+ else if (sc.ch == '@') {sc.SetState(SCE_AU3_KEYWORD);}
+ else if (sc.ch == '\"') {
+ sc.SetState(SCE_AU3_STRING);
+ si = 1; }
+ else if (sc.ch == '\'') {
+ sc.SetState(SCE_AU3_STRING);
+ si = 2; }
+ else if (sc.ch == '$') {sc.SetState(SCE_AU3_VARIABLE);}
+ else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_AU3_NUMBER);}
+ //else if (IsAWordStart(sc.ch)) {sc.SetState(SCE_AU3_KEYWORD);}
+ else if (isoperator(static_cast<char>(sc.ch)) || (sc.ch == '\\')) {sc.SetState(SCE_AU3_OPERATOR);}
+ else if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);}
+ }
+ } //for (; sc.More(); sc.Forward())
+ sc.Complete();
+}
+
+//
+
+static const char * const AU3WordLists[] = {
+ "#autoit keywords",
+ "#autoit functions",
+ "#autoit macros",
+ "#autoit Sent keys",
+ 0
+};
+LexerModule lmAU3(SCLEX_AU3, ColouriseAU3Doc, "au3", NULL , AU3WordLists);
diff --git a/src/LexMSSQL.cxx b/src/LexMSSQL.cxx
index c36e5170a..6019f24d3 100644
--- a/src/LexMSSQL.cxx
+++ b/src/LexMSSQL.cxx
@@ -24,6 +24,8 @@
#define KW_MSSQL_SYSTEM_TABLES 2
#define KW_MSSQL_GLOBAL_VARIABLES 3
#define KW_MSSQL_FUNCTIONS 4
+#define KW_MSSQL_STORED_PROCEDURES 5
+#define KW_MSSQL_OPERATORS 6
//~ val SCE_MSSQL_DEFAULT=0
//~ val SCE_MSSQL_COMMENT=1
@@ -39,6 +41,9 @@
//~ val SCE_MSSQL_SYSTABLE=11
//~ val SCE_MSSQL_GLOBAL_VARIABLE=12
//~ val SCE_MSSQL_FUNCTION=13
+//~ val SCE_MSSQL_STORED_PROCEDURE=14
+//~ val SCE_MSSQL_DEFAULT_PREF_DATATYPE 15
+//~ val SCE_MSSQL_COLUMN_NAME_2 16
static bool isMSSQLOperator(char ch) {
if (isascii(ch) && isalnum(ch))
@@ -47,17 +52,19 @@ static bool isMSSQLOperator(char ch) {
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
ch == '-' || ch == '+' || ch == '=' || ch == '|' ||
ch == '<' || ch == '>' || ch == '/' ||
- ch == '!' || ch == '~')
+ ch == '!' || ch == '~' || ch == '(' || ch == ')' ||
+ ch == ',')
return true;
return false;
}
-static void classifyWordSQL(unsigned int start,
+static char classifyWordSQL(unsigned int start,
unsigned int end,
WordList *keywordlists[],
Accessor &styler,
- unsigned int actualState) {
- char s[100];
+ unsigned int actualState,
+ unsigned int prevState) {
+ char s[256];
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
WordList &kwStatements = *keywordlists[KW_MSSQL_STATEMENTS];
@@ -65,30 +72,56 @@ static void classifyWordSQL(unsigned int start,
WordList &kwSystemTables = *keywordlists[KW_MSSQL_SYSTEM_TABLES];
WordList &kwGlobalVariables = *keywordlists[KW_MSSQL_GLOBAL_VARIABLES];
WordList &kwFunctions = *keywordlists[KW_MSSQL_FUNCTIONS];
+ WordList &kwStoredProcedures = *keywordlists[KW_MSSQL_STORED_PROCEDURES];
+ WordList &kwOperators = *keywordlists[KW_MSSQL_OPERATORS];
- if (actualState == SCE_MSSQL_GLOBAL_VARIABLE)
- start += 2;
-
- for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+ for (unsigned int i = 0; i < end - start + 1 && i < 128; i++) {
s[i] = static_cast<char>(tolower(styler[start + i]));
s[i + 1] = '\0';
}
char chAttr = SCE_MSSQL_IDENTIFIER;
- if (wordIsNumber)
+
+ if (actualState == SCE_MSSQL_GLOBAL_VARIABLE) {
+
+ if (kwGlobalVariables.InList(&s[2]))
+ chAttr = SCE_MSSQL_GLOBAL_VARIABLE;
+
+ } else if (wordIsNumber) {
chAttr = SCE_MSSQL_NUMBER;
- else {
- if (kwStatements.InList(s))
- chAttr = SCE_MSSQL_STATEMENT;
+
+ } else if (prevState == SCE_MSSQL_DEFAULT_PREF_DATATYPE) {
+ // Look first in datatypes
if (kwDataTypes.InList(s))
chAttr = SCE_MSSQL_DATATYPE;
- if (kwSystemTables.InList(s))
- chAttr = SCE_MSSQL_SYSTABLE;
- if (kwGlobalVariables.InList(s))
- chAttr = SCE_MSSQL_GLOBAL_VARIABLE;
- if (kwFunctions.InList(s))
+ else if (kwOperators.InList(s))
+ chAttr = SCE_MSSQL_OPERATOR;
+ else if (kwStatements.InList(s))
+ chAttr = SCE_MSSQL_STATEMENT;
+ else if (kwSystemTables.InList(s))
+ chAttr = SCE_MSSQL_SYSTABLE;
+ else if (kwFunctions.InList(s))
chAttr = SCE_MSSQL_FUNCTION;
+ else if (kwStoredProcedures.InList(s))
+ chAttr = SCE_MSSQL_STORED_PROCEDURE;
+
+ } else {
+ if (kwOperators.InList(s))
+ chAttr = SCE_MSSQL_OPERATOR;
+ else if (kwStatements.InList(s))
+ chAttr = SCE_MSSQL_STATEMENT;
+ else if (kwSystemTables.InList(s))
+ chAttr = SCE_MSSQL_SYSTABLE;
+ else if (kwFunctions.InList(s))
+ chAttr = SCE_MSSQL_FUNCTION;
+ else if (kwStoredProcedures.InList(s))
+ chAttr = SCE_MSSQL_STORED_PROCEDURE;
+ else if (kwDataTypes.InList(s))
+ chAttr = SCE_MSSQL_DATATYPE;
}
+
styler.ColourTo(end, chAttr);
+
+ return chAttr;
}
static void ColouriseMSSQLDoc(unsigned int startPos, int length,
@@ -117,6 +150,7 @@ static void ColouriseMSSQLDoc(unsigned int startPos, int length,
iixx += 2;
*/
int state = initStyle;
+ int prevState = initStyle;
char chPrev = ' ';
char chNext = styler[startPos];
styler.StartSegment(startPos);
@@ -147,134 +181,135 @@ static void ColouriseMSSQLDoc(unsigned int startPos, int length,
continue;
}
- if (state == SCE_MSSQL_DEFAULT) {
- if (iswordstart(ch)) {
+ // When the last char isn't part of the state (have to deal with it too)...
+ if ( (state == SCE_MSSQL_IDENTIFIER) ||
+ (state == SCE_MSSQL_STORED_PROCEDURE) ||
+ (state == SCE_MSSQL_DATATYPE) ||
+ //~ (state == SCE_MSSQL_COLUMN_NAME) ||
+ (state == SCE_MSSQL_FUNCTION) ||
+ //~ (state == SCE_MSSQL_GLOBAL_VARIABLE) ||
+ (state == SCE_MSSQL_VARIABLE)) {
+ if (!iswordchar(ch)) {
+ int stateTmp;
+
+ if ((state == SCE_MSSQL_VARIABLE) || (state == SCE_MSSQL_COLUMN_NAME)) {
+ styler.ColourTo(i - 1, state);
+ stateTmp = state;
+ } else
+ stateTmp = classifyWordSQL(styler.GetStartSegment(), i - 1, keywordlists, styler, state, prevState);
+
+ prevState = state;
+
+ if (stateTmp == SCE_MSSQL_IDENTIFIER || stateTmp == SCE_MSSQL_VARIABLE)
+ state = SCE_MSSQL_DEFAULT_PREF_DATATYPE;
+ else
+ state = SCE_MSSQL_DEFAULT;
+ }
+ } else if (state == SCE_MSSQL_LINE_COMMENT) {
+ if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
+ prevState = state;
+ state = SCE_MSSQL_DEFAULT;
+ }
+ } else if (state == SCE_MSSQL_GLOBAL_VARIABLE) {
+ if ((ch != '@') && !iswordchar(ch)) {
+ classifyWordSQL(styler.GetStartSegment(), i - 1, keywordlists, styler, state, prevState);
+ prevState = state;
+ state = SCE_MSSQL_DEFAULT;
+ }
+ }
+
+ // If is the default or one of the above succeeded
+ if (state == SCE_MSSQL_DEFAULT || state == SCE_MSSQL_DEFAULT_PREF_DATATYPE) {
+ if (iswordstart(ch)) {
+ styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
+ prevState = state;
state = SCE_MSSQL_IDENTIFIER;
} else if (ch == '/' && chNext == '*') {
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
+ prevState = state;
state = SCE_MSSQL_COMMENT;
} else if (ch == '-' && chNext == '-') {
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
+ prevState = state;
state = SCE_MSSQL_LINE_COMMENT;
} else if (ch == '\'') {
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
+ prevState = state;
state = SCE_MSSQL_STRING;
- } else if ((ch == '"') || (ch == '[')) {
- styler.ColourTo(i - 1, state);
+ } else if (ch == '"') {
+ styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
+ prevState = state;
state = SCE_MSSQL_COLUMN_NAME;
+ } else if (ch == '[') {
+ styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
+ prevState = state;
+ state = SCE_MSSQL_COLUMN_NAME_2;
} else if (isMSSQLOperator(ch)) {
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
styler.ColourTo(i, SCE_MSSQL_OPERATOR);
//~ style = SCE_MSSQL_DEFAULT;
+ prevState = state;
+ state = SCE_MSSQL_DEFAULT;
} else if (ch == '@') {
- styler.ColourTo(i - 1, state);
+ styler.ColourTo(i - 1, SCE_MSSQL_DEFAULT);
+ prevState = state;
if (chNext == '@') {
state = SCE_MSSQL_GLOBAL_VARIABLE;
// i += 2;
} else
state = SCE_MSSQL_VARIABLE;
}
- } else if ( (state == SCE_MSSQL_IDENTIFIER) ||
- (state == SCE_MSSQL_DATATYPE) ||
- //~ (state == SCE_MSSQL_COLUMN_NAME) ||
- (state == SCE_MSSQL_FUNCTION) ||
-// (state == SCE_MSSQL_GLOBAL_VARIABLE) ||
- (state == SCE_MSSQL_VARIABLE)) {
- if (!iswordchar(ch)) {
- if ((state == SCE_MSSQL_VARIABLE) || (state == SCE_MSSQL_COLUMN_NAME))
- styler.ColourTo(i - 1, state);
- else
- classifyWordSQL(styler.GetStartSegment(), i - 1, keywordlists, styler, state);
- state = SCE_MSSQL_DEFAULT;
- if (ch == '/' && chNext == '*') {
- state = SCE_MSSQL_COMMENT;
- } else if (ch == '-' && chNext == '-') {
- state = SCE_MSSQL_LINE_COMMENT;
- } else if (ch == '\'') {
- state = SCE_MSSQL_STRING;
- } else if ((ch == '"') || (ch == '[')) {
- state = SCE_MSSQL_COLUMN_NAME;
- } else if (isMSSQLOperator(ch)) {
- styler.ColourTo(i, SCE_MSSQL_OPERATOR);
- } else if (ch == '@')
- state = (chNext == '@') ? SCE_MSSQL_GLOBAL_VARIABLE : SCE_MSSQL_VARIABLE;
- }
- } else {
- if (state == SCE_MSSQL_COMMENT) {
+
+ // When the last char is part of the state...
+ } else if (state == SCE_MSSQL_COMMENT) {
if (ch == '/' && chPrev == '*') {
if (((i > (styler.GetStartSegment() + 2)) || ((initStyle == SCE_MSSQL_COMMENT) &&
(styler.GetStartSegment() == startPos)))) {
styler.ColourTo(i, state);
//~ state = SCE_MSSQL_COMMENT;
+ prevState = state;
state = SCE_MSSQL_DEFAULT;
}
}
- } else if (state == SCE_MSSQL_LINE_COMMENT) {
- if (ch == '\r' || ch == '\n') {
- styler.ColourTo(i - 1, state);
- state = SCE_MSSQL_DEFAULT;
- }
} else if (state == SCE_MSSQL_STRING) {
if (ch == '\'') {
if ( chNext == '\'' ) {
i++;
+ ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
} else {
styler.ColourTo(i, state);
+ prevState = state;
state = SCE_MSSQL_DEFAULT;
- i++;
+ //i++;
}
- ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
+ //ch = chNext;
+ //chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_MSSQL_COLUMN_NAME) {
if (ch == '"') {
if (chNext == '"') {
i++;
- } else {
- styler.ColourTo(i, state);
- state = SCE_MSSQL_DEFAULT;
- //i++;
- }
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
- } else if (ch == ']') {
+ } else {
styler.ColourTo(i, state);
- state = SCE_MSSQL_DEFAULT;
- //i++;
+ prevState = state;
+ state = SCE_MSSQL_DEFAULT_PREF_DATATYPE;
+ //i++;
}
- } else if (state == SCE_MSSQL_GLOBAL_VARIABLE) {
- if ((ch != '@') && !iswordchar(ch)) {
- classifyWordSQL(styler.GetStartSegment(), i - 1, keywordlists, styler, state);
- state = SCE_MSSQL_DEFAULT;
- }
- }
- if (state == SCE_MSSQL_DEFAULT) { // One of the above succeeded
- if (iswordstart(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_MSSQL_IDENTIFIER;
- } else if (ch == '/' && chNext == '*') {
- styler.ColourTo(i - 1, state);
- state = SCE_MSSQL_COMMENT;
- } else if (ch == '-' && chNext == '-') {
- styler.ColourTo(i - 1, state);
- state = SCE_MSSQL_LINE_COMMENT;
- } else if (ch == '\'') {
- styler.ColourTo(i - 1, state);
- state = SCE_MSSQL_STRING;
- } else if ((ch == '"') || (ch == '[')) {
- styler.ColourTo(i - 1, state);
- state = SCE_MSSQL_COLUMN_NAME;
- } else if (isMSSQLOperator(ch) && !((ch == '/') && (chPrev == '*'))) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_MSSQL_OPERATOR);
- } else if (ch == '@') {
- styler.ColourTo(i - 1, state);
- state = (chNext == '@') ? SCE_MSSQL_GLOBAL_VARIABLE : SCE_MSSQL_VARIABLE;
}
+ } else if (state == SCE_MSSQL_COLUMN_NAME_2) {
+ if (ch == ']') {
+ styler.ColourTo(i, state);
+ prevState = state;
+ state = SCE_MSSQL_DEFAULT_PREF_DATATYPE;
+ //i++;
}
}
+
chPrev = ch;
}
styler.ColourTo(lengthDoc - 1, state);
@@ -286,6 +321,8 @@ static const char * const sqlWordListDesc[] = {
"System tables",
"Global variables",
"Functions",
+ "System Stored Procedures",
+ "Operators",
0,
};