aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2000-07-08 13:51:28 +0000
committernyamatongwe <unknown>2000-07-08 13:51:28 +0000
commit7092c2cf13f9a9a7598e93bc2652de2f82c04b1e (patch)
tree21c5fa7d4bfbb8e44e3ed5af9d5f0c35d4d2afc5 /src
parent74d9308207e9f567f5912edee10245e2c69fee87 (diff)
downloadscintilla-mirror-7092c2cf13f9a9a7598e93bc2652de2f82c04b1e.tar.gz
Included Steve Lhomme's PHP updates for the HTML lexer.
Diffstat (limited to 'src')
-rw-r--r--src/LexHTML.cxx742
1 files changed, 532 insertions, 210 deletions
diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx
index e9451383b..506f9a491 100644
--- a/src/LexHTML.cxx
+++ b/src/LexHTML.cxx
@@ -17,15 +17,15 @@
#include "Scintilla.h"
#include "SciLexer.h"
-enum { eScriptNone, eScriptJS, eScriptVBS, eScriptPython };
+enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML };
static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
- char s[100];
+ char s[30 + 1];
s[0] = '\0';
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = static_cast<char>(tolower(styler[start + i]));
s[i + 1] = '\0';
}
-//Platform::DebugPrintf("Scripting indicator [%s]\n", s);
+ //Platform::DebugPrintf("Scripting indicator [%s]\n", s);
if (strstr(s, "vbs"))
return eScriptVBS;
if (strstr(s, "pyth"))
@@ -34,10 +34,29 @@ static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigne
return eScriptJS;
if (strstr(s, "jscr"))
return eScriptJS;
-
+ if (strstr(s, "php"))
+ return eScriptPHP;
+ if (strstr(s, "xml"))
+ return eScriptXML;
+
return prevValue;
}
+static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, unsigned int end) {
+ int iResult = 0;
+ char s[30 + 1];
+ s[0] = '\0';
+ for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+ s[i] = static_cast<char>(tolower(styler[start + i]));
+ s[i + 1] = '\0';
+ }
+ if (0 == strncmp(s, "php", 3)) {
+ iResult = 3;
+ }
+
+ return iResult;
+}
+
static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.') ||
(styler[start] == '-') || (styler[start] == '#');
@@ -45,7 +64,7 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k
if (wordIsNumber) {
chAttr = SCE_H_NUMBER;
} else {
- char s[100];
+ char s[30 + 1];
s[0] = '\0';
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = static_cast<char>(tolower(styler[start + i]));
@@ -61,11 +80,11 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k
}
static int classifyTagHTML(unsigned int start, unsigned int end,
- WordList &keywords, Accessor &styler) {
- char s[100];
+ WordList &keywords, Accessor &styler) {
+ char s[30 + 1];
// Copy after the '<'
unsigned int i = 0;
- for (unsigned int cPos=start; cPos <= end && i < 30; cPos++) {
+ for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) {
char ch = styler[cPos];
if (ch != '<')
s[i++] = static_cast<char>(tolower(ch));
@@ -82,8 +101,9 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
} else {
if (keywords.InList(s)) {
chAttr = SCE_H_TAG;
- if (0 == strcmp(s, "script"))
- chAttr = SCE_H_SCRIPT;
+ }
+ if (0 == strcmp(s, "script")) {
+ chAttr = SCE_H_SCRIPT;
}
}
if ((chAttr == SCE_H_TAGUNKNOWN) && !keywords)
@@ -95,16 +115,16 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
static void classifyWordHTJS(unsigned int start, unsigned int end,
WordList &keywords, Accessor &styler) {
- char s[100];
- bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
- for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
- s[i] = styler[start + i];
- s[i + 1] = '\0';
- }
char chAttr = SCE_HJ_WORD;
+ bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber)
chAttr = SCE_HJ_NUMBER;
else {
+ char s[30 + 1];
+ for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+ s[i] = styler[start + i];
+ s[i + 1] = '\0';
+ }
if (keywords.InList(s))
chAttr = SCE_HJ_KEYWORD;
}
@@ -112,17 +132,17 @@ static void classifyWordHTJS(unsigned int start, unsigned int end,
}
static void classifyWordHTJSA(unsigned int start, unsigned int end,
- WordList &keywords, Accessor &styler) {
- char s[100];
- bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
- for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
- s[i] = styler[start + i];
- s[i + 1] = '\0';
- }
+ WordList &keywords, Accessor &styler) {
char chAttr = SCE_HJA_WORD;
+ bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber)
chAttr = SCE_HJA_NUMBER;
else {
+ char s[30 + 1];
+ for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+ s[i] = styler[start + i];
+ s[i + 1] = '\0';
+ }
if (keywords.InList(s))
chAttr = SCE_HJA_KEYWORD;
}
@@ -130,16 +150,16 @@ static void classifyWordHTJSA(unsigned int start, unsigned int end,
}
static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
- char s[100];
- bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
- for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
- s[i] = static_cast<char>(tolower(styler[start + i]));
- s[i + 1] = '\0';
- }
char chAttr = SCE_HB_IDENTIFIER;
+ bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber)
chAttr = SCE_HB_NUMBER;
else {
+ char s[30 + 1];
+ for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+ s[i] = static_cast<char>(tolower(styler[start + i]));
+ s[i + 1] = '\0';
+ }
if (keywords.InList(s)) {
chAttr = SCE_HB_WORD;
if (strcmp(s, "rem") == 0)
@@ -154,16 +174,16 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
}
static int classifyWordHTVBA(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
- char s[100];
- bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
- for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
- s[i] = static_cast<char>(tolower(styler[start + i]));
- s[i + 1] = '\0';
- }
char chAttr = SCE_HBA_IDENTIFIER;
+ bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber)
chAttr = SCE_HBA_NUMBER;
else {
+ char s[30 + 1];
+ for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+ s[i] = static_cast<char>(tolower(styler[start + i]));
+ s[i + 1] = '\0';
+ }
if (keywords.InList(s)) {
chAttr = SCE_HBA_WORD;
if (strcmp(s, "rem") == 0)
@@ -178,8 +198,8 @@ static int classifyWordHTVBA(unsigned int start, unsigned int end, WordList &key
}
static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
- char s[100];
bool wordIsNumber = isdigit(styler[start]);
+ char s[30 + 1];
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
@@ -198,8 +218,8 @@ static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &key
}
static void classifyWordHTPyA(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
- char s[100];
bool wordIsNumber = isdigit(styler[start]);
+ char s[30 + 1];
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
@@ -217,30 +237,72 @@ static void classifyWordHTPyA(unsigned int start, unsigned int end, WordList &ke
strcpy(prevWord, s);
}
+// Update the word colour to default or keyword
+// Called when in a PHP word
+static void classifyWordHTPHPA(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
+ char chAttr = SCE_HPHP_DEFAULT;
+ bool wordIsNumber = isdigit(styler[start]);
+ if (wordIsNumber)
+ chAttr = SCE_HPHP_NUMBER;
+ else {
+ char s[30 + 1];
+ for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
+ s[i] = styler[start + i];
+ s[i + 1] = '\0';
+ }
+ if (keywords.InList(s))
+ chAttr = SCE_HPHP_WORD;
+ }
+ styler.ColourTo(end, chAttr);
+}
+
+// Return the first state to reach when entering a scripting language
+static int StateForScript(int scriptLanguage, int inScriptTag) {
+ switch (scriptLanguage) {
+ case eScriptVBS:
+ if (inScriptTag)
+ return SCE_HB_START;
+ else
+ return SCE_HBA_START;
+ case eScriptPython:
+ if (inScriptTag)
+ return SCE_HP_START;
+ else
+ return SCE_HPA_START;
+ case eScriptPHP:
+ return SCE_HPHP_DEFAULT;
+ case eScriptXML:
+ return SCE_H_TAGUNKNOWN;
+ default :
+ return SCE_HJ_START;
+ }
+}
+
inline bool ishtmlwordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
}
static bool InTagState(int state) {
return state == SCE_H_TAG || state == SCE_H_TAGUNKNOWN ||
- state == SCE_H_SCRIPT ||
- state == SCE_H_ATTRIBUTE || state == SCE_H_ATTRIBUTEUNKNOWN ||
- state == SCE_H_NUMBER || state == SCE_H_OTHER ||
- state == SCE_H_DOUBLESTRING || state == SCE_H_SINGLESTRING;
+ state == SCE_H_SCRIPT ||
+ state == SCE_H_ATTRIBUTE || state == SCE_H_ATTRIBUTEUNKNOWN ||
+ state == SCE_H_NUMBER || state == SCE_H_OTHER ||
+ state == SCE_H_DOUBLESTRING || state == SCE_H_SINGLESTRING;
}
static bool isLineEnd(char ch) {
return ch == '\r' || ch == '\n';
}
-static void ColouriseHyperTextDoc(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];
-
+static void ColouriseHyperTextDoc(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];
+ WordList &keywords5 = *keywordlists[4];
+
// Lexer for HTML requires more lexical states (7 bits worth) than most lexers
styler.StartAt(startPos, 127);
bool lastTagWasScript = false;
@@ -248,7 +310,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
prevWord[0] = '\0';
int scriptLanguage = eScriptJS;
int state = initStyle;
- // If inside a tag, it may be a script tage, so reread from the start to ensure any language tas are seen
+
+ // If inside a tag, it may be a script tag, so reread from the start to ensure any language tags are seen
if (InTagState(state)) {
while ((startPos > 1) && (InTagState(styler.StyleAt(startPos - 1)))) {
startPos--;
@@ -261,10 +324,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0)
lineState = styler.GetLineState(lineCurrent);
- int defaultScript = lineState &0xff;
- int beforeASP = (lineState >> 8) &0xff;
- int inASP = (lineState >> 16) &0xff;
-
+ int beforeNonHTML = (lineState & 0x01) >> 0;
+ int inNonHTML = (lineState & 0x02) >> 1;
+ int inScriptTag = (lineState & 0x04) >> 2;
+ int defaultScript = (lineState & 0xF0) >> 4;
+
char chPrev = ' ';
char chPrev2 = ' ';
styler.StartSegment(startPos);
@@ -274,6 +338,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
char chNext = styler.SafeGetCharAt(i + 1);
char chNext2 = styler.SafeGetCharAt(i + 2);
+ // Handle DBCS codepages
if (styler.IsLeadByte(ch)) {
chPrev2 = ' ';
chPrev = ' ';
@@ -284,84 +349,191 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
// New line -> record any line state onto /next/ line
lineCurrent++;
- styler.SetLineState(lineCurrent,
- defaultScript | (beforeASP << 8) | (inASP << 16));
+ styler.SetLineState(lineCurrent,
+ (beforeNonHTML & 0x01) | ((inNonHTML & 0x01) << 1) | ((inScriptTag & 0x01) << 2) | ((defaultScript & 0x0F) << 4));
}
-
- // Handle ASP even within other constructs as it is a preprocessor
+
+ if (inScriptTag && (ch == '<') && (chNext == '/')) {
+ // Check if it's the end of the script tag (or any other HTML tag)
+ switch (state) {
+ // in these cases, you can embed HTML tags (to confirm !!!!!!!!!!!!!!!!!!!!!!)
+ case SCE_H_DOUBLESTRING:
+ case SCE_H_SINGLESTRING:
+ case SCE_HJ_COMMENTLINE:
+ case SCE_HJ_DOUBLESTRING:
+ case SCE_HJ_SINGLESTRING:
+ case SCE_HJA_COMMENTLINE:
+ case SCE_HJA_DOUBLESTRING:
+ case SCE_HJA_SINGLESTRING:
+ case SCE_HB_COMMENTLINE:
+ case SCE_HB_STRING:
+ case SCE_HBA_COMMENTLINE:
+ case SCE_HBA_STRING:
+ case SCE_HP_COMMENTLINE:
+ case SCE_HP_STRING:
+ case SCE_HP_TRIPLE:
+ case SCE_HP_TRIPLEDOUBLE:
+ case SCE_HPA_COMMENTLINE:
+ case SCE_HPA_STRING:
+ case SCE_HPA_TRIPLE:
+ case SCE_HPA_TRIPLEDOUBLE:
+ break;
+ default :
+ // maybe we should check here if it's a tag and if it's SCRIPT
+
+ styler.ColourTo(i - 1, state);
+ state = SCE_H_TAGUNKNOWN;
+ inNonHTML = 0;
+ inScriptTag = 0;
+ i++;
+ continue;
+ break;
+ }
+ }
+
+ /////////////////////////////////////
+ // handle the start of PHP pre-processor = Non-HTML
+ if ((ch == '<') && (chNext == '?')) {
+ styler.ColourTo(i - 1, state);
+ beforeNonHTML = state;
+ scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i + 10, eScriptPHP);
+ i += 1 + PrintScriptingIndicatorOffset(styler, i + 2, i + 10);
+ if (scriptLanguage == eScriptXML)
+ styler.ColourTo(i, SCE_H_XMLSTART);
+ else
+ styler.ColourTo(i, SCE_H_QUESTION);
+ state = StateForScript(scriptLanguage, inScriptTag);
+ inNonHTML = 1;
+ continue;
+ }
+ // handle the start of ASP pre-processor = Non-HTML
if ((ch == '<') && (chNext == '%')) {
- beforeASP = state;
styler.ColourTo(i - 1, state);
+ beforeNonHTML = state;
if (chNext2 == '@') {
- styler.ColourTo(i + 2, SCE_H_ASP);
+ i += 2; // place as if it was the second next char treated
state = SCE_H_ASPAT;
- i+=2;
} else {
- if (defaultScript == eScriptVBS)
- state = SCE_HBA_START;
- else if (defaultScript == eScriptPython)
- state = SCE_HPA_START;
- else
- state = SCE_HJA_START;
if (chNext2 == '=') {
- styler.ColourTo(i + 2, SCE_H_ASP);
- i+=2;
- } else {
- styler.ColourTo(i + 1, SCE_H_ASP);
- i++;
+ i += 2; // place as if it was the second next char treated
+ }
+ else {
+ i++; // place as if it was the next char treated
}
+
+ state = StateForScript(defaultScript, inScriptTag);
}
- inASP = 1;
+ styler.ColourTo(i, SCE_H_ASP);
+ inNonHTML = 1;
+ inScriptTag = 0;
continue;
}
- if (inASP && (ch == '%') && (chNext == '>')) {
- if (state == SCE_H_ASPAT)
- defaultScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i-1, defaultScript);
+ /////////////////////////////////////
+ /////////////////////////////////////
+ // handle of end of a pre-processor = Non-HTML
+ /* this code is probably un-used (kept for safety)
+ if (inNonHTML && inScriptTag && (ch == '<') && (chNext == '/')) {
+ // Bounce out of any ASP mode
+ switch (state)
+ {
+ case SCE_HJA_WORD:
+ classifyWordHTJSA(styler.GetStartSegment(), i - 1, keywords2, styler);
+ break;
+ case SCE_HBA_WORD:
+ classifyWordHTVBA(styler.GetStartSegment(), i - 1, keywords3, styler);
+ break;
+ case SCE_HPA_WORD:
+ classifyWordHTPyA(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord);
+ break;
+ case SCE_HPHP_WORD:
+ classifyWordHTPHPA(styler.GetStartSegment(), i - 1, keywords5, styler);
+ break;
+ default :
+ styler.ColourTo(i - 1, state);
+ break;
+ }
+ if ((ch == '<') && (chNext == '/')) {
+ state = SCE_H_TAGUNKNOWN;
+ } else {
+ i++;
+ if (ch == '%')
+ styler.ColourTo(i, SCE_H_ASP);
+ else
+ // styler.ColourTo(i, SCE_H_XMLEND);
+ styler.ColourTo(i, SCE_HPHP_);
+ state = beforeNonHTML;
+ }
+ beforeNonHTML = SCE_H_DEFAULT;
+ inNonHTML = 0;
+ inScriptTag = 0;
+ continue;
+ }
+ */
+ // handle the end of a pre-processor = Non-HTML
+ if (inNonHTML && ((ch == '?') || (ch == '%')) && (chNext == '>')) {
+ if (state == SCE_H_ASPAT) {
+ defaultScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, defaultScript);
+ }
// Bounce out of any ASP mode
- if (state == SCE_HJA_WORD) {
+ switch (state) {
+ case SCE_HJA_WORD:
classifyWordHTJSA(styler.GetStartSegment(), i - 1, keywords2, styler);
- } else if (state == SCE_HBA_WORD) {
+ break;
+ case SCE_HBA_WORD:
classifyWordHTVBA(styler.GetStartSegment(), i - 1, keywords3, styler);
- } else if (state == SCE_HPA_WORD) {
+ break;
+ case SCE_HPA_WORD:
classifyWordHTPyA(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord);
- } else {
+ break;
+ case SCE_HPHP_WORD:
+ classifyWordHTPHPA(styler.GetStartSegment(), i - 1, keywords5, styler);
+ break;
+ default :
styler.ColourTo(i - 1, state);
+ break;
+ }
+ if ((ch == '<') && (chNext == '/')) {
+ state = SCE_H_TAGUNKNOWN;
+ } else {
+ i++;
+ if (ch == '%')
+ styler.ColourTo(i, SCE_H_ASP);
+ else if (scriptLanguage == eScriptXML)
+ styler.ColourTo(i, SCE_H_XMLEND);
+ else
+ styler.ColourTo(i, SCE_H_QUESTION);
+ state = beforeNonHTML;
}
- //if (state == SCE_H_ASPAT)
- // styler.ColourTo(i+1, SCE_H_ASPAT);
- //else
- styler.ColourTo(i+1, SCE_H_ASP);
- i++;
- state = beforeASP;
- beforeASP = SCE_H_DEFAULT;
- inASP = 0;
+ beforeNonHTML = SCE_H_DEFAULT;
+ inNonHTML = 0;
+ inScriptTag = 0;
continue;
}
-
- if (state == SCE_H_DEFAULT) {
+ /////////////////////////////////////
+
+ switch (state) {
+ case SCE_H_DEFAULT:
if (ch == '<') {
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
- if (chNext == '?') {
- styler.ColourTo(i + 1, SCE_H_XMLSTART);
- i++;
- ch = chNext;
- }
} else if (ch == '&') {
styler.ColourTo(i - 1, SCE_H_DEFAULT);
state = SCE_H_ENTITY;
}
- } else if (state == SCE_H_COMMENT) {
+ break;
+ case SCE_H_COMMENT:
if ((ch == '>') && (chPrev == '-')) {
styler.ColourTo(i, state);
state = SCE_H_DEFAULT;
}
- } else if (state == SCE_H_CDATA) {
+ break;
+ case SCE_H_CDATA:
if ((ch == '>') && (chPrev == ']') && (chPrev2 == ']')) {
styler.ColourTo(i, state);
state = SCE_H_DEFAULT;
}
- } else if (state == SCE_H_ENTITY) {
+ break;
+ case SCE_H_ENTITY:
if (ch == ';') {
styler.ColourTo(i, state);
state = SCE_H_DEFAULT;
@@ -370,23 +542,20 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, SCE_H_TAGUNKNOWN);
state = SCE_H_DEFAULT;
}
- } else if (state == SCE_H_TAGUNKNOWN) {
+ break;
+ case SCE_H_TAGUNKNOWN:
if (!ishtmlwordchar(ch) && ch != '/' && ch != '-' && ch != '[') {
int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler);
lastTagWasScript = eClass == SCE_H_SCRIPT;
if (lastTagWasScript) {
- scriptLanguage = eScriptJS;
+ inScriptTag = 1;
+ scriptLanguage = eScriptJS; // default to javascript
eClass = SCE_H_TAG;
}
if ((ch == '>') && (eClass != SCE_H_COMMENT)) {
styler.ColourTo(i, SCE_H_TAG);
if (lastTagWasScript) {
- if (scriptLanguage == eScriptVBS)
- state = SCE_HB_START;
- else if (scriptLanguage == eScriptPython)
- state = SCE_HP_START;
- else
- state = SCE_HJ_START;
+ state = StateForScript(scriptLanguage, inScriptTag);
} else {
state = SCE_H_DEFAULT;
}
@@ -400,20 +569,17 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
}
}
}
- } else if (state == SCE_H_ATTRIBUTE) {
+ break;
+ case SCE_H_ATTRIBUTE:
if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') {
- if (lastTagWasScript)
- scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i-1, scriptLanguage);
+ if (lastTagWasScript) {
+ scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
+ }
classifyAttribHTML(styler.GetStartSegment(), i - 1, keywords, styler);
if (ch == '>') {
styler.ColourTo(i, SCE_H_TAG);
if (lastTagWasScript) {
- if (scriptLanguage == eScriptVBS)
- state = SCE_HB_START;
- else if (scriptLanguage == eScriptPython)
- state = SCE_HP_START;
- else
- state = SCE_HJ_START;
+ state = StateForScript(scriptLanguage, inScriptTag);
} else {
state = SCE_H_DEFAULT;
}
@@ -421,27 +587,13 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_H_OTHER;
}
}
- } else if (state == SCE_H_ASP) {
- if ((ch == '>') && (chPrev == '%')) {
- styler.ColourTo(i, state);
- state = SCE_H_DEFAULT;
- }
- } else if (state == SCE_H_ASPAT) {
- if ((ch == '>') && (chPrev == '%')) {
- styler.ColourTo(i, state);
- state = SCE_H_DEFAULT;
- }
- } else if (state == SCE_H_OTHER) {
+ break;
+ case SCE_H_OTHER:
if (ch == '>') {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_H_TAG);
if (lastTagWasScript) {
- if (scriptLanguage == eScriptVBS)
- state = SCE_HB_START;
- else if (scriptLanguage == eScriptPython)
- state = SCE_HP_START;
- else
- state = SCE_HJ_START;
+ state = StateForScript(scriptLanguage, inScriptTag);
} else {
state = SCE_H_DEFAULT;
}
@@ -467,21 +619,28 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i - 1, state);
state = SCE_H_ATTRIBUTE;
}
- } else if (state == SCE_H_DOUBLESTRING) {
+ break;
+ case SCE_H_DOUBLESTRING:
if (ch == '\"') {
- if (lastTagWasScript)
+ if (lastTagWasScript) {
scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i, scriptLanguage);
+ }
styler.ColourTo(i, SCE_H_DOUBLESTRING);
state = SCE_H_OTHER;
}
- } else if (state == SCE_H_SINGLESTRING) {
+ break;
+ case SCE_H_SINGLESTRING:
if (ch == '\'') {
- if (lastTagWasScript)
+ if (lastTagWasScript) {
scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i, scriptLanguage);
+ }
styler.ColourTo(i, SCE_H_SINGLESTRING);
state = SCE_H_OTHER;
}
- } else if (state == SCE_HJ_DEFAULT || state == SCE_HJ_START) {
+ break;
+ case SCE_HJ_DEFAULT:
+ case SCE_HJ_START:
+ case SCE_HJ_SYMBOLS:
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HJ_WORD;
@@ -503,10 +662,15 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if ((ch == '<') && (chNext == '/')) {
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
} else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') &&
- styler.SafeGetCharAt(i + 3) == '-') {
+ styler.SafeGetCharAt(i + 3) == '-') {
styler.ColourTo(i - 1, state);
state = SCE_HJ_COMMENTLINE;
+ } else if ((ch == '-') && (chNext == '-') && (chNext2 == '>')) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_HJ_COMMENTLINE;
+ i += 2;
} else if (isoperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_HJ_SYMBOLS);
@@ -517,7 +681,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJ_DEFAULT;
}
}
- } else if (state == SCE_HJ_WORD) {
+ break;
+ case SCE_HJ_WORD:
if (!iswordchar(ch)) {
classifyWordHTJS(styler.GetStartSegment(), i - 1, keywords2, styler);
//styler.ColourTo(i - 1, eHTJSKeyword);
@@ -533,34 +698,31 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJ_DOUBLESTRING;
} else if (ch == '\'') {
state = SCE_HJ_SINGLESTRING;
+ } else if ((ch == '-') && (chNext == '-') && (chNext2 == '>')) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_HJ_COMMENTLINE;
+ i += 2;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_HJ_SYMBOLS);
state = SCE_HJ_DEFAULT;
}
}
- } else if (state == SCE_HJ_COMMENT) {
- if (ch == '/' && chPrev == '*') {
- state = SCE_HJ_DEFAULT;
- styler.ColourTo(i, SCE_HJ_COMMENT);
- } else if ((ch == '<') && (chNext == '/')) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i + 1, SCE_H_TAGEND);
- i++;
- ch = chNext;
- state = SCE_H_DEFAULT;
- }
- } else if (state == SCE_HJ_COMMENTDOC) {
+ break;
+ case SCE_HJ_COMMENT:
+ case SCE_HJ_COMMENTDOC:
if (ch == '/' && chPrev == '*') {
+ styler.ColourTo(i, state);
state = SCE_HJ_DEFAULT;
- styler.ColourTo(i, SCE_HJ_COMMENTDOC);
} else if ((ch == '<') && (chNext == '/')) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i + 1, SCE_H_TAGEND);
i++;
ch = chNext;
state = SCE_H_DEFAULT;
+ inScriptTag = 0;
}
- } else if (state == SCE_HJ_COMMENTLINE) {
+ break;
+ case SCE_HJ_COMMENTLINE:
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, SCE_HJ_COMMENTLINE);
state = SCE_HJ_DEFAULT;
@@ -568,8 +730,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
// Common to hide end script tag in comment
styler.ColourTo(i - 1, SCE_HJ_COMMENTLINE);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
}
- } else if (state == SCE_HJ_DOUBLESTRING) {
+ break;
+ case SCE_HJ_DOUBLESTRING:
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
@@ -580,10 +744,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
i++;
ch = chNext;
} else if (isLineEnd(ch)) {
- styler.ColourTo(i-1, state);
+ styler.ColourTo(i - 1, state);
state = SCE_HJ_STRINGEOL;
}
- } else if (state == SCE_HJ_SINGLESTRING) {
+ break;
+ case SCE_HJ_SINGLESTRING:
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
@@ -594,10 +759,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
i++;
ch = chNext;
} else if (isLineEnd(ch)) {
- styler.ColourTo(i-1, state);
+ styler.ColourTo(i - 1, state);
state = SCE_HJ_STRINGEOL;
}
- } else if (state == SCE_HJ_STRINGEOL) {
+ break;
+ case SCE_HJ_STRINGEOL:
if (!isLineEnd(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HJ_DEFAULT;
@@ -605,7 +771,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, state);
state = SCE_HJ_DEFAULT;
}
- } else if (state == SCE_HJA_DEFAULT || state == SCE_HJA_START) {
+ break;
+ case SCE_HJA_DEFAULT:
+ case SCE_HJA_START:
+ case SCE_HJA_SYMBOLS:
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HJA_WORD;
@@ -627,10 +796,15 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if ((ch == '<') && (chNext == '/')) {
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
} else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') &&
- styler.SafeGetCharAt(i + 3) == '-') {
+ styler.SafeGetCharAt(i + 3) == '-') {
styler.ColourTo(i - 1, state);
state = SCE_HJA_COMMENTLINE;
+ } else if ((ch == '-') && (chNext == '-') && (chNext2 == '>')) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_HJA_COMMENTLINE;
+ i += 2;
} else if (isoperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_HJA_SYMBOLS);
@@ -641,7 +815,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJA_DEFAULT;
}
}
- } else if (state == SCE_HJA_WORD) {
+ break;
+ case SCE_HJA_WORD:
if (!iswordchar(ch)) {
classifyWordHTJSA(styler.GetStartSegment(), i - 1, keywords2, styler);
//styler.ColourTo(i - 1, eHTJSKeyword);
@@ -657,34 +832,31 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJA_DOUBLESTRING;
} else if (ch == '\'') {
state = SCE_HJA_SINGLESTRING;
+ } else if ((ch == '-') && (chNext == '-') && (chNext2 == '>')) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_HJA_COMMENTLINE;
+ i += 2;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_HJA_SYMBOLS);
state = SCE_HJA_DEFAULT;
}
}
- } else if (state == SCE_HJA_COMMENT) {
- if (ch == '/' && chPrev == '*') {
- state = SCE_HJA_DEFAULT;
- styler.ColourTo(i, SCE_HJA_COMMENT);
- } else if ((ch == '<') && (chNext == '/')) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i + 1, SCE_H_TAGEND);
- i++;
- ch = chNext;
- state = SCE_H_DEFAULT;
- }
- } else if (state == SCE_HJA_COMMENTDOC) {
+ break;
+ case SCE_HJA_COMMENT:
+ case SCE_HJA_COMMENTDOC:
if (ch == '/' && chPrev == '*') {
+ styler.ColourTo(i, state);
state = SCE_HJA_DEFAULT;
- styler.ColourTo(i, SCE_HJA_COMMENTDOC);
} else if ((ch == '<') && (chNext == '/')) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i + 1, SCE_H_TAGEND);
i++;
ch = chNext;
state = SCE_H_DEFAULT;
+ inScriptTag = 0;
}
- } else if (state == SCE_HJA_COMMENTLINE) {
+ break;
+ case SCE_HJA_COMMENTLINE:
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, SCE_HJA_COMMENTLINE);
state = SCE_HJA_DEFAULT;
@@ -692,8 +864,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
// Common to hide end script tag in comment
styler.ColourTo(i - 1, SCE_HJA_COMMENTLINE);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
}
- } else if (state == SCE_HJA_DOUBLESTRING) {
+ break;
+ case SCE_HJA_DOUBLESTRING:
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
@@ -703,11 +877,16 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJA_DEFAULT;
i++;
ch = chNext;
+ } else if ((ch == '-') && (chNext == '-') && (chNext2 == '>')) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_HJA_COMMENTLINE;
+ i += 2;
} else if (isLineEnd(ch)) {
- styler.ColourTo(i-1, state);
+ styler.ColourTo(i - 1, state);
state = SCE_HJA_STRINGEOL;
}
- } else if (state == SCE_HJA_SINGLESTRING) {
+ break;
+ case SCE_HJA_SINGLESTRING:
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
@@ -717,11 +896,16 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJA_DEFAULT;
i++;
ch = chNext;
+ } else if ((ch == '-') && (chNext == '-') && (chNext2 == '>')) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_HJA_COMMENTLINE;
+ i += 2;
} else if (isLineEnd(ch)) {
- styler.ColourTo(i-1, state);
+ styler.ColourTo(i - 1, state);
state = SCE_HJA_STRINGEOL;
}
- } else if (state == SCE_HJA_STRINGEOL) {
+ break;
+ case SCE_HJA_STRINGEOL:
if (!isLineEnd(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HJA_DEFAULT;
@@ -729,7 +913,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, state);
state = SCE_HJA_DEFAULT;
}
- } else if (state == SCE_HB_DEFAULT || state == SCE_HB_START) {
+ break;
+ case SCE_HB_DEFAULT:
+ case SCE_HB_START:
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HB_WORD;
@@ -742,8 +928,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if ((ch == '<') && (chNext == '/')) {
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
} else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') &&
- styler.SafeGetCharAt(i + 3) == '-') {
+ styler.SafeGetCharAt(i + 3) == '-') {
styler.ColourTo(i - 1, state);
state = SCE_HB_COMMENTLINE;
} else if (isoperator(ch)) {
@@ -756,7 +943,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HB_DEFAULT;
}
}
- } else if (state == SCE_HB_WORD) {
+ break;
+ case SCE_HB_WORD:
if (!iswordchar(ch)) {
state = classifyWordHTVB(styler.GetStartSegment(), i - 1, keywords3, styler);
if (state == SCE_HB_DEFAULT) {
@@ -770,17 +958,19 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
}
}
}
- } else if (state == SCE_HB_STRING) {
+ break;
+ case SCE_HB_STRING:
if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_HB_DEFAULT;
i++;
ch = chNext;
} else if (ch == '\r' || ch == '\n') {
- styler.ColourTo(i-1, state);
+ styler.ColourTo(i - 1, state);
state = SCE_HB_STRINGEOL;
}
- } else if (state == SCE_HB_COMMENTLINE) {
+ break;
+ case SCE_HB_COMMENTLINE:
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_HB_DEFAULT;
@@ -788,8 +978,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
// Common to hide end script tag in comment
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
}
- } else if (state == SCE_HB_STRINGEOL) {
+ break;
+ case SCE_HB_STRINGEOL:
if (!isLineEnd(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HB_DEFAULT;
@@ -797,7 +989,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, state);
state = SCE_HB_DEFAULT;
}
- } else if (state == SCE_HBA_DEFAULT || state == SCE_HBA_START) {
+ break;
+ case SCE_HBA_DEFAULT:
+ case SCE_HBA_START:
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HBA_WORD;
@@ -810,8 +1004,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if ((ch == '<') && (chNext == '/')) {
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
} else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') &&
- styler.SafeGetCharAt(i + 3) == '-') {
+ styler.SafeGetCharAt(i + 3) == '-') {
styler.ColourTo(i - 1, state);
state = SCE_HBA_COMMENTLINE;
} else if (isoperator(ch)) {
@@ -824,7 +1019,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HBA_DEFAULT;
}
}
- } else if (state == SCE_HBA_WORD) {
+ break;
+ case SCE_HBA_WORD:
if (!iswordchar(ch)) {
state = classifyWordHTVBA(styler.GetStartSegment(), i - 1, keywords3, styler);
if (state == SCE_HBA_DEFAULT) {
@@ -838,17 +1034,19 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
}
}
}
- } else if (state == SCE_HBA_STRING) {
+ break;
+ case SCE_HBA_STRING:
if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_HBA_DEFAULT;
i++;
ch = chNext;
} else if (ch == '\r' || ch == '\n') {
- styler.ColourTo(i-1, state);
+ styler.ColourTo(i - 1, state);
state = SCE_HBA_STRINGEOL;
}
- } else if (state == SCE_HBA_COMMENTLINE) {
+ break;
+ case SCE_HBA_COMMENTLINE:
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_HBA_DEFAULT;
@@ -856,8 +1054,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
// Common to hide end script tag in comment
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
}
- } else if (state == SCE_HBA_STRINGEOL) {
+ break;
+ case SCE_HBA_STRINGEOL:
if (!isLineEnd(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HBA_DEFAULT;
@@ -865,15 +1065,18 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, state);
state = SCE_HBA_DEFAULT;
}
- } else if (state == SCE_HP_DEFAULT || state == SCE_HP_START) {
+ break;
+ case SCE_HP_DEFAULT:
+ case SCE_HP_START:
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HP_WORD;
} else if ((ch == '<') && (chNext == '/')) {
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
} else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') &&
- styler.SafeGetCharAt(i + 3) == '-') {
+ styler.SafeGetCharAt(i + 3) == '-') {
styler.ColourTo(i - 1, state);
state = SCE_HP_COMMENTLINE;
} else if (ch == '#') {
@@ -910,7 +1113,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HP_DEFAULT;
}
}
- } else if (state == SCE_HP_WORD) {
+ break;
+ case SCE_HP_WORD:
if (!iswordchar(ch)) {
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord);
state = SCE_HP_DEFAULT;
@@ -940,12 +1144,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, SCE_HP_OPERATOR);
}
}
- } else if (state == SCE_HP_COMMENTLINE) {
+ break;
+ case SCE_HP_COMMENTLINE:
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_HP_DEFAULT;
}
- } else if (state == SCE_HP_STRING) {
+ break;
+ case SCE_HP_STRING:
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
@@ -956,7 +1162,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, state);
state = SCE_HP_DEFAULT;
}
- } else if (state == SCE_HP_CHARACTER) {
+ break;
+ case SCE_HP_CHARACTER:
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
@@ -967,25 +1174,30 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, state);
state = SCE_HP_DEFAULT;
}
- } else if (state == SCE_HP_TRIPLE) {
+ break;
+ case SCE_HP_TRIPLE:
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
styler.ColourTo(i, state);
state = SCE_HP_DEFAULT;
}
- } else if (state == SCE_HP_TRIPLEDOUBLE) {
+ break;
+ case SCE_HP_TRIPLEDOUBLE:
if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
styler.ColourTo(i, state);
state = SCE_HP_DEFAULT;
}
- } else if (state == SCE_HPA_DEFAULT || state == SCE_HPA_START) {
+ break;
+ case SCE_HPA_DEFAULT:
+ case SCE_HPA_START:
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_HPA_WORD;
} else if ((ch == '<') && (chNext == '/')) {
styler.ColourTo(i - 1, state);
state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
} else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') &&
- styler.SafeGetCharAt(i + 3) == '-') {
+ styler.SafeGetCharAt(i + 3) == '-') {
styler.ColourTo(i - 1, state);
state = SCE_HPA_COMMENTLINE;
} else if (ch == '#') {
@@ -1022,7 +1234,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HPA_DEFAULT;
}
}
- } else if (state == SCE_HPA_WORD) {
+ break;
+ case SCE_HPA_WORD:
if (!iswordchar(ch)) {
classifyWordHTPyA(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord);
state = SCE_HPA_DEFAULT;
@@ -1052,12 +1265,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, SCE_HPA_OPERATOR);
}
}
- } else if (state == SCE_HPA_COMMENTLINE) {
+ break;
+ case SCE_HPA_COMMENTLINE:
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_HPA_DEFAULT;
}
- } else if (state == SCE_HPA_STRING) {
+ break;
+ case SCE_HPA_STRING:
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
@@ -1068,7 +1283,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, state);
state = SCE_HPA_DEFAULT;
}
- } else if (state == SCE_HPA_CHARACTER) {
+ break;
+ case SCE_HPA_CHARACTER:
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
@@ -1079,17 +1295,122 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, state);
state = SCE_HPA_DEFAULT;
}
- } else if (state == SCE_HPA_TRIPLE) {
+ break;
+ case SCE_HPA_TRIPLE:
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
styler.ColourTo(i, state);
state = SCE_HPA_DEFAULT;
}
- } else if (state == SCE_HPA_TRIPLEDOUBLE) {
+ break;
+ case SCE_HPA_TRIPLEDOUBLE:
if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
styler.ColourTo(i, state);
state = SCE_HPA_DEFAULT;
}
+ break;
+ ///////////// start - PHP state handling
+ case SCE_HPHP_WORD:
+ if (!iswordchar(ch)) {
+ if (ch == '/' && chNext == '*') {
+ state = SCE_HPHP_COMMENT;
+ } else if (ch == '/' && chNext == '/') {
+ state = SCE_HPHP_COMMENTLINE;
+ } else if (ch == '\"') {
+ state = SCE_HPHP_HSTRING;
+ } else if (ch == '\'') {
+ state = SCE_HPHP_SIMPLESTRING;
+ } else if (ch == '$') {
+ state = SCE_HPHP_VARIABLE;
+ } else if (isoperator(ch)) {
+ state = SCE_HPHP_DEFAULT;
+ } else {
+ state = SCE_HPHP_DEFAULT;
+ }
+ classifyWordHTPHPA(styler.GetStartSegment(), i - 1, keywords5, styler);
+ } else if ((ch == '<') && (chNext == '/')) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_H_TAGUNKNOWN;
+ inScriptTag = 0;
+ }
+ break;
+ case SCE_HPHP_NUMBER:
+ if (!isdigit(ch)) {
+ styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
+ state = SCE_HPHP_DEFAULT;
+ }
+ break;
+ case SCE_HPHP_VARIABLE:
+ if (!iswordchar(ch)) {
+ styler.ColourTo(i - 1, SCE_HPHP_VARIABLE);
+ state = SCE_HPHP_DEFAULT;
+ }
+ break;
+ case SCE_HPHP_COMMENT:
+ if (ch == '/' && chPrev == '*') {
+ styler.ColourTo(i, state);
+ state = SCE_HPHP_DEFAULT;
+ }
+ break;
+ case SCE_HPHP_COMMENTLINE:
+ if (ch == '\r' || ch == '\n') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_HPHP_DEFAULT;
+ }
+ break;
+ case SCE_HPHP_HSTRING:
+ if (ch == '\\') {
+ if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
+ i++;
+ ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ }
+ } else if (ch == '\"') {
+ styler.ColourTo(i, state);
+ state = SCE_HPHP_DEFAULT;
+ } else if (chNext == '\r' || chNext == '\n') {
+ styler.ColourTo(i - 1, SCE_HPHP_STRINGEOL);
+ state = SCE_HPHP_STRINGEOL;
+ }
+ break;
+ case SCE_HPHP_SIMPLESTRING:
+ if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
+ styler.ColourTo(i - 1, SCE_HPHP_STRINGEOL);
+ state = SCE_HPHP_STRINGEOL;
+ } else if (ch == '\\') {
+ if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
+ i++;
+ ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ }
+ } else if (ch == '\'') {
+ styler.ColourTo(i, state);
+ state = SCE_HPHP_DEFAULT;
+ }
+ break;
+ case SCE_HPHP_STRINGEOL:
+ break;
+ case SCE_HPHP_DEFAULT:
+ styler.ColourTo(i - 1, state);
+ if (isdigit(ch)) {
+ state = SCE_HPHP_NUMBER;
+ } else if (iswordstart(ch)) {
+ state = SCE_HPHP_WORD;
+ } else if (ch == '/' && chNext == '*') {
+ state = SCE_HPHP_COMMENT;
+ } else if (ch == '/' && chNext == '/') {
+ state = SCE_HPHP_COMMENTLINE;
+ } else if (ch == '\"') {
+ state = SCE_HPHP_HSTRING;
+ } else if (ch == '\'') {
+ state = SCE_HPHP_SIMPLESTRING;
+ } else if (ch == '$') {
+ state = SCE_HPHP_VARIABLE;
+ }
+ break;
+ ///////////// end - PHP state handling
}
+
+
if (state == SCE_HB_DEFAULT) { // One of the above succeeded
if (ch == '\"') {
state = SCE_HB_STRING;
@@ -1151,6 +1472,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
chPrev2 = chPrev;
chPrev = ch;
}
+
styler.ColourTo(lengthDoc - 1, state);
}