-static void ColourisePBDoc(unsigned int startPos, int length, int initStyle,WordList *keywordlists[],
- Accessor &styler) {
-
- WordList &keywords = *keywordlists[0];
-
- styler.StartAt(startPos);
-
- StyleContext sc(startPos, length, initStyle, styler);
-
- for (; sc.More(); sc.Forward()) {
-
- if (sc.state == SCE_B_OPERATOR)
- {
- sc.SetState(SCE_B_DEFAULT);
- }
- else if (sc.state == SCE_B_KEYWORD)
- {
- if (!IsAWordChar(sc.ch))
- {
- if (!IsTypeCharacter(sc.ch))
- {
- if (sc.ch == ']') {sc.Forward();}
- char s[100];
- sc.GetCurrentLowered(s, sizeof(s));
- if (keywords.InList(s))
- {
- if (strcmp(s, "rem") == 0)
- {
- sc.ChangeState(SCE_B_COMMENT);
- if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
- }
- else
- {
- sc.SetState(SCE_B_DEFAULT);
- }
- }
- else
- {
- sc.ChangeState(SCE_B_IDENTIFIER);
- sc.SetState(SCE_B_DEFAULT);
- }
- }
- }
- }
- else if (sc.state == SCE_B_NUMBER)
- {
- if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_B_DEFAULT);}
- }
- else if (sc.state == SCE_B_STRING)
- {
- // PB doubles quotes to preserve them, so just end this string
- // state now as a following quote will start again
- if (sc.ch == '\"')
- {
- if (tolower(sc.chNext) == 'c') {sc.Forward();}
- sc.ForwardSetState(SCE_B_DEFAULT);
- }
- }
- else if (sc.state == SCE_B_COMMENT)
- {
- if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
- }
-
- if (sc.state == SCE_B_DEFAULT)
- {
- if (sc.ch == '\'') {sc.SetState(SCE_B_COMMENT);}
- else if (sc.ch == '\"') {sc.SetState(SCE_B_STRING);}
- else if (sc.ch == '#')
- { int n = 1;
- int chSeek = ' ';
- while ((n < 100) && (chSeek == ' ' || chSeek == '\t'))
- {
- chSeek = sc.GetRelative(n);
- n++;
- }
- sc.SetState(SCE_B_OPERATOR);
- }
- else if (sc.ch == '&' && tolower(sc.chNext) == 'h') {sc.SetState(SCE_B_NUMBER);}
- else if (sc.ch == '&' && tolower(sc.chNext) == 'b') {sc.SetState(SCE_B_NUMBER);}
- else if (sc.ch == '&' && tolower(sc.chNext) == 'o') {sc.SetState(SCE_B_NUMBER);}
- else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_B_NUMBER);}
- else if (IsAWordStart(sc.ch) || (sc.ch == '[')) {sc.SetState(SCE_B_KEYWORD);}
- else if (isoperator(static_cast<char>(sc.ch)) || (sc.ch == '\\')) {sc.SetState(SCE_B_OPERATOR);}
- }
-
- }
- sc.Complete();
+static void ColourisePBDoc(unsigned int startPos, int length, int initStyle,WordList *keywordlists[],Accessor &styler) {
+
+ WordList &keywords = *keywordlists[0];
+
+ styler.StartAt(startPos);
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ for (; sc.More(); sc.Forward()) {
+ switch (sc.state)
+ {
+ case SCE_B_OPERATOR:
+ {
+ sc.SetState(SCE_B_DEFAULT);
+ break;
+ }
+ case SCE_B_KEYWORD:
+ {
+ if (!IsAWordChar(sc.ch))
+ {
+ if (!IsTypeCharacter(sc.ch))
+ {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywords.InList(s))
+ {
+ if (strcmp(s, "rem") == 0)
+ {
+ sc.ChangeState(SCE_B_COMMENT);
+ if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
+ }
+ else if (strcmp(s, "asm") == 0)
+ {
+ sc.ChangeState(SCE_B_ASM);
+ if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
+ }
+ else
+ {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ }
+ else
+ {
+ sc.ChangeState(SCE_B_IDENTIFIER);
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ }
+ }
+ break;
+ }
+ case SCE_B_NUMBER:
+ {
+ if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_B_DEFAULT);}
+ break;
+ }
+ case SCE_B_STRING:
+ {
+ if (sc.ch == '\"'){sc.ForwardSetState(SCE_B_DEFAULT);}
+ break;
+ }
+ case SCE_B_CONSTANT:
+ {
+ if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_B_DEFAULT);}
+ break;
+ }
+ case SCE_B_COMMENT:
+ {
+ if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
+ break;
+ }
+ case SCE_B_ASM:
+ {
+ if (sc.atLineEnd) {sc.SetState(SCE_B_DEFAULT);}
+ break;
+ }
+ } //switch (sc.state)
+
+ // Determine if a new state should be entered:
+ if (sc.state == SCE_B_DEFAULT)
+ {
+ if (sc.ch == '\'') {sc.SetState(SCE_B_COMMENT);}
+ else if (sc.ch == '\"') {sc.SetState(SCE_B_STRING);}
+ else if (sc.ch == '&' && tolower(sc.chNext) == 'h') {sc.SetState(SCE_B_NUMBER);}
+ else if (sc.ch == '&' && tolower(sc.chNext) == 'b') {sc.SetState(SCE_B_NUMBER);}
+ else if (sc.ch == '&' && tolower(sc.chNext) == 'o') {sc.SetState(SCE_B_NUMBER);}
+ else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_B_NUMBER);}
+ else if (IsAWordStart(sc.ch)) {sc.SetState(SCE_B_KEYWORD);}
+ else if (sc.ch == '%') {sc.SetState(SCE_B_CONSTANT);}
+ else if (sc.ch == '$') {sc.SetState(SCE_B_CONSTANT);}
+ else if (sc.ch == '#') {sc.SetState(SCE_B_KEYWORD);}
+ else if (sc.ch == '!') {sc.SetState(SCE_B_ASM);}
+ else if (isoperator(static_cast<char>(sc.ch)) || (sc.ch == '\\')) {sc.SetState(SCE_B_OPERATOR);}
+ }
+ } //for (; sc.More(); sc.Forward())
+ sc.Complete();