diff options
author | Neil <nyamatongwe@gmail.com> | 2015-02-24 10:17:39 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2015-02-24 10:17:39 +1100 |
commit | fe3a578229d51a8e277c879e75b02dd676ad0999 (patch) | |
tree | 1ffb23707d1a20c46dce2f670ca19bfa80c0c139 | |
parent | 1aeafe1e0a9896f5db86cdcccee919db1eb86702 (diff) | |
download | scintilla-mirror-fe3a578229d51a8e277c879e75b02dd676ad0999.tar.gz |
Reindented file consistently with tabs using astyle.
The file had become a mixture of tab indenting and space indenting.
No other changes were made in this change set.
-rw-r--r-- | lexers/LexTCL.cxx | 372 |
1 files changed, 185 insertions, 187 deletions
diff --git a/lexers/LexTCL.cxx b/lexers/LexTCL.cxx index 004dab113..17414e7df 100644 --- a/lexers/LexTCL.cxx +++ b/lexers/LexTCL.cxx @@ -30,7 +30,7 @@ using namespace Scintilla; // Extended to accept accented characters static inline bool IsAWordChar(int ch) { return ch >= 0x80 || - (isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator + (isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator } static inline bool IsAWordStart(int ch) { @@ -49,17 +49,18 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k #define isComment(s) (s==SCE_TCL_COMMENT || s==SCE_TCL_COMMENTLINE || s==SCE_TCL_COMMENT_BOX || s==SCE_TCL_BLOCK_COMMENT) bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool commentLevel = false; - bool subBrace = false; // substitution begin with a brace ${.....} + bool subBrace = false; // substitution begin with a brace ${.....} enum tLineState {LS_DEFAULT, LS_OPEN_COMMENT, LS_OPEN_DOUBLE_QUOTE, LS_COMMENT_BOX, LS_MASK_STATE = 0xf, - LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32 } lineState = LS_DEFAULT; + LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32 + } lineState = LS_DEFAULT; bool prevSlash = false; int currentLevel = 0; - bool expected = 0; - bool subParen = 0; + bool expected = 0; + bool subParen = 0; int currentLine = styler.GetLine(startPos); - if (currentLine > 0) - currentLine--; + if (currentLine > 0) + currentLine--; length += startPos - styler.LineStart(currentLine); // make sure lines overlap startPos = styler.LineStart(currentLine); @@ -71,14 +72,14 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k WordList &keywords5 = *keywordlists[4]; WordList &keywords6 = *keywordlists[5]; WordList &keywords7 = *keywordlists[6]; - WordList &keywords8 = *keywordlists[7]; - WordList &keywords9 = *keywordlists[8]; + WordList &keywords8 = *keywordlists[7]; + WordList &keywords9 = *keywordlists[8]; if (currentLine > 0) { - int ls = styler.GetLineState(currentLine - 1); + int ls = styler.GetLineState(currentLine - 1); lineState = tLineState(ls & LS_MASK_STATE); expected = LS_COMMAND_EXPECTED == tLineState(ls & LS_COMMAND_EXPECTED); - subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY); + subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY); currentLevel = styler.LevelAt(currentLine - 1) >> 17; commentLevel = (styler.LevelAt(currentLine - 1) >> 16) & 1; } else @@ -86,105 +87,104 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k bool visibleChars = false; int previousLevel = currentLevel; - StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler); + StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler); for (; ; sc.Forward()) { next: - if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac - continue; - bool atEnd = !sc.More(); // make sure we coloured the last word - if (lineState != LS_DEFAULT) { - sc.SetState(SCE_TCL_DEFAULT); - if (lineState == LS_OPEN_COMMENT) - sc.SetState(SCE_TCL_COMMENTLINE); - else if (lineState == LS_OPEN_DOUBLE_QUOTE) - sc.SetState(SCE_TCL_IN_QUOTE); - else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#'))) - sc.SetState(SCE_TCL_COMMENT_BOX); - lineState = LS_DEFAULT; - } - if (subBrace) { // ${ overrides every thing even \ except } - if (sc.ch == '}') { - subBrace = false; - sc.SetState(SCE_TCL_OPERATOR); - sc.ForwardSetState(SCE_TCL_DEFAULT); - goto next; - } - else - sc.SetState(SCE_TCL_SUB_BRACE); - if (!sc.atLineEnd) - continue; - } else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) { - expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#'; - } else if (sc.state == SCE_TCL_SUBSTITUTION) { - switch(sc.ch) { - case '(': - subParen=true; - sc.SetState(SCE_TCL_OPERATOR); - sc.ForwardSetState(SCE_TCL_SUBSTITUTION); - continue; - case ')': - sc.SetState(SCE_TCL_OPERATOR); - subParen=false; - continue; - case '$': - continue; - case ',': - sc.SetState(SCE_TCL_OPERATOR); - if (subParen) - sc.ForwardSetState(SCE_TCL_SUBSTITUTION); - continue; - default : - // maybe spaces should be allowed ??? - if (!IsAWordChar(sc.ch)) { // probably the code is wrong - sc.SetState(SCE_TCL_DEFAULT); - subParen = 0; - } - break; - } - } else if (isComment(sc.state)) { - } else if (!IsAWordChar(sc.ch)) { - if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) { - char w[100]; - char *s=w; - sc.GetCurrent(w, sizeof(w)); - if (w[strlen(w)-1]=='\r') - w[strlen(w)-1]=0; - while(*s == ':') // ignore leading : like in ::set a 10 - ++s; - bool quote = sc.state == SCE_TCL_IN_QUOTE; - if (commentLevel || expected) { - if (keywords.InList(s)) { - sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD); - } else if (keywords2.InList(s)) { - sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2); - } else if (keywords3.InList(s)) { - sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3); - } else if (keywords4.InList(s)) { - sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4); - } else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' && - keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces - sc.ChangeState(SCE_TCL_EXPAND); - } - if (keywords6.InList(s)) { - sc.ChangeState(SCE_TCL_WORD5); - } else if (keywords7.InList(s)) { - sc.ChangeState(SCE_TCL_WORD6); - } else if (keywords8.InList(s)) { - sc.ChangeState(SCE_TCL_WORD7); - } else if (keywords9.InList(s)) { - sc.ChangeState(SCE_TCL_WORD8); - } - } - expected = false; - sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT); - } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) { - sc.SetState(SCE_TCL_DEFAULT); - } - } + if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac + continue; + bool atEnd = !sc.More(); // make sure we coloured the last word + if (lineState != LS_DEFAULT) { + sc.SetState(SCE_TCL_DEFAULT); + if (lineState == LS_OPEN_COMMENT) + sc.SetState(SCE_TCL_COMMENTLINE); + else if (lineState == LS_OPEN_DOUBLE_QUOTE) + sc.SetState(SCE_TCL_IN_QUOTE); + else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#'))) + sc.SetState(SCE_TCL_COMMENT_BOX); + lineState = LS_DEFAULT; + } + if (subBrace) { // ${ overrides every thing even \ except } + if (sc.ch == '}') { + subBrace = false; + sc.SetState(SCE_TCL_OPERATOR); + sc.ForwardSetState(SCE_TCL_DEFAULT); + goto next; + } else + sc.SetState(SCE_TCL_SUB_BRACE); + if (!sc.atLineEnd) + continue; + } else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) { + expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#'; + } else if (sc.state == SCE_TCL_SUBSTITUTION) { + switch (sc.ch) { + case '(': + subParen=true; + sc.SetState(SCE_TCL_OPERATOR); + sc.ForwardSetState(SCE_TCL_SUBSTITUTION); + continue; + case ')': + sc.SetState(SCE_TCL_OPERATOR); + subParen=false; + continue; + case '$': + continue; + case ',': + sc.SetState(SCE_TCL_OPERATOR); + if (subParen) + sc.ForwardSetState(SCE_TCL_SUBSTITUTION); + continue; + default : + // maybe spaces should be allowed ??? + if (!IsAWordChar(sc.ch)) { // probably the code is wrong + sc.SetState(SCE_TCL_DEFAULT); + subParen = 0; + } + break; + } + } else if (isComment(sc.state)) { + } else if (!IsAWordChar(sc.ch)) { + if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) { + char w[100]; + char *s=w; + sc.GetCurrent(w, sizeof(w)); + if (w[strlen(w)-1]=='\r') + w[strlen(w)-1]=0; + while (*s == ':') // ignore leading : like in ::set a 10 + ++s; + bool quote = sc.state == SCE_TCL_IN_QUOTE; + if (commentLevel || expected) { + if (keywords.InList(s)) { + sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2); + } else if (keywords3.InList(s)) { + sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3); + } else if (keywords4.InList(s)) { + sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4); + } else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' && + keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces + sc.ChangeState(SCE_TCL_EXPAND); + } + if (keywords6.InList(s)) { + sc.ChangeState(SCE_TCL_WORD5); + } else if (keywords7.InList(s)) { + sc.ChangeState(SCE_TCL_WORD6); + } else if (keywords8.InList(s)) { + sc.ChangeState(SCE_TCL_WORD7); + } else if (keywords9.InList(s)) { + sc.ChangeState(SCE_TCL_WORD8); + } + } + expected = false; + sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT); + } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) { + sc.SetState(SCE_TCL_DEFAULT); + } + } if (atEnd) break; - if (sc.atLineEnd) { - lineState = LS_DEFAULT; + if (sc.atLineEnd) { + lineState = LS_DEFAULT; currentLine = styler.GetLine(sc.currentPos); if (foldComment && sc.state!=SCE_TCL_COMMENT && isComment(sc.state)) { if (currentLevel == 0) { @@ -206,45 +206,45 @@ next: styler.SetLevel(currentLine, flag + previousLevel + SC_FOLDLEVELBASE + (currentLevel << 17) + (commentLevel << 16)); // Update the line state, so it can be seen by next line - if (sc.state == SCE_TCL_IN_QUOTE) + if (sc.state == SCE_TCL_IN_QUOTE) { lineState = LS_OPEN_DOUBLE_QUOTE; - else { - if (prevSlash) { - if (isComment(sc.state)) - lineState = LS_OPEN_COMMENT; - } else if (sc.state == SCE_TCL_COMMENT_BOX) - lineState = LS_COMMENT_BOX; + } else { + if (prevSlash) { + if (isComment(sc.state)) + lineState = LS_OPEN_COMMENT; + } else if (sc.state == SCE_TCL_COMMENT_BOX) + lineState = LS_COMMENT_BOX; } - styler.SetLineState(currentLine, - (subBrace ? LS_BRACE_ONLY : 0) | - (expected ? LS_COMMAND_EXPECTED : 0) | lineState); - if (lineState == LS_COMMENT_BOX) - sc.ForwardSetState(SCE_TCL_COMMENT_BOX); - else if (lineState == LS_OPEN_DOUBLE_QUOTE) - sc.ForwardSetState(SCE_TCL_IN_QUOTE); - else - sc.ForwardSetState(SCE_TCL_DEFAULT); + styler.SetLineState(currentLine, + (subBrace ? LS_BRACE_ONLY : 0) | + (expected ? LS_COMMAND_EXPECTED : 0) | lineState); + if (lineState == LS_COMMENT_BOX) + sc.ForwardSetState(SCE_TCL_COMMENT_BOX); + else if (lineState == LS_OPEN_DOUBLE_QUOTE) + sc.ForwardSetState(SCE_TCL_IN_QUOTE); + else + sc.ForwardSetState(SCE_TCL_DEFAULT); prevSlash = false; previousLevel = currentLevel; goto next; } if (prevSlash) { - prevSlash = false; - if (sc.ch == '#' && IsANumberChar(sc.chNext)) - sc.ForwardSetState(SCE_TCL_NUMBER); - continue; + prevSlash = false; + if (sc.ch == '#' && IsANumberChar(sc.chNext)) + sc.ForwardSetState(SCE_TCL_NUMBER); + continue; } - prevSlash = sc.ch == '\\'; - if (isComment(sc.state)) - continue; + prevSlash = sc.ch == '\\'; + if (isComment(sc.state)) + continue; if (sc.atLineStart) { visibleChars = false; if (sc.state!=SCE_TCL_IN_QUOTE && !isComment(sc.state)) - { + { sc.SetState(SCE_TCL_DEFAULT); - expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch)); - } + expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch)); + } } switch (sc.state) { @@ -259,28 +259,28 @@ next: goto next; } else if (sc.ch == '[' || sc.ch == ']' || sc.ch == '$' || sc.ch == '(') { sc.SetState(SCE_TCL_OPERATOR); - expected = sc.ch == '['; - sc.ForwardSetState(SCE_TCL_IN_QUOTE); + expected = sc.ch == '['; + sc.ForwardSetState(SCE_TCL_IN_QUOTE); goto next; } - continue; - case SCE_TCL_OPERATOR: + continue; + case SCE_TCL_OPERATOR: sc.SetState(SCE_TCL_DEFAULT); break; } if (sc.ch == '#') { if (visibleChars) { - if (sc.state != SCE_TCL_IN_QUOTE && expected) + if (sc.state != SCE_TCL_IN_QUOTE && expected) sc.SetState(SCE_TCL_COMMENT); } else { - sc.SetState(SCE_TCL_COMMENTLINE); - if (sc.chNext == '~') - sc.SetState(SCE_TCL_BLOCK_COMMENT); - if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-')) - sc.SetState(SCE_TCL_COMMENT_BOX); - } - } + sc.SetState(SCE_TCL_COMMENTLINE); + if (sc.chNext == '~') + sc.SetState(SCE_TCL_BLOCK_COMMENT); + if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-')) + sc.SetState(SCE_TCL_COMMENT_BOX); + } + } if (!isspacechar(static_cast<unsigned char>(sc.ch))) { visibleChars = true; @@ -293,7 +293,7 @@ next: // Determine if a new state should be entered. if (sc.state == SCE_TCL_DEFAULT) { - if (IsAWordStart(sc.ch)) { + if (IsAWordStart(sc.ch)) { sc.SetState(SCE_TCL_IDENTIFIER); } else if (IsADigit(sc.ch) && !IsAWordChar(sc.chPrev)) { sc.SetState(SCE_TCL_NUMBER); @@ -313,43 +313,41 @@ next: --currentLevel; break; case '[': - expected = true; + expected = true; case ']': case '(': case ')': sc.SetState(SCE_TCL_OPERATOR); break; case ';': - expected = true; + expected = true; + break; + case '$': + subParen = 0; + if (sc.chNext == '(') { + //$("") jquery selector?! + sc.SetState(SCE_TCL_OPERATOR); + } else if (sc.chNext != '{') { + sc.SetState(SCE_TCL_SUBSTITUTION); + } else { + sc.SetState(SCE_TCL_OPERATOR); // $ + sc.Forward(); // { + sc.ForwardSetState(SCE_TCL_SUB_BRACE); + subBrace = true; + } + break; + case '#': + if ((isspacechar(static_cast<unsigned char>(sc.chPrev))|| + isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10)) + sc.SetState(SCE_TCL_NUMBER); + break; + case '-': + sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER); break; - case '$': - subParen = 0; - if (sc.chNext == '(') { - //$("") jquery selector?! - sc.SetState(SCE_TCL_OPERATOR); - } - else if (sc.chNext != '{') { - sc.SetState(SCE_TCL_SUBSTITUTION); - } - else { - sc.SetState(SCE_TCL_OPERATOR); // $ - sc.Forward(); // { - sc.ForwardSetState(SCE_TCL_SUB_BRACE); - subBrace = true; - } - break; - case '#': - if ((isspacechar(static_cast<unsigned char>(sc.chPrev))|| - isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10)) - sc.SetState(SCE_TCL_NUMBER); - break; - case '-': - sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER); - break; - default: - if (isoperator(static_cast<char>(sc.ch))) { - sc.SetState(SCE_TCL_OPERATOR); - } + default: + if (isoperator(static_cast<char>(sc.ch))) { + sc.SetState(SCE_TCL_OPERATOR); + } } } } @@ -357,18 +355,18 @@ next: sc.Complete(); } -static const char * const tclWordListDesc[] = { - "TCL Keywords", - "TK Keywords", - "iTCL Keywords", - "tkCommands", - "expand", - "user1", - "user2", - "user3", - "user4", - 0 - }; +static const char *const tclWordListDesc[] = { + "TCL Keywords", + "TK Keywords", + "iTCL Keywords", + "tkCommands", + "expand", + "user1", + "user2", + "user3", + "user4", + 0 +}; // this code supports folding in the colourizer LexerModule lmTCL(SCLEX_TCL, ColouriseTCLDoc, "tcl", 0, tclWordListDesc); |