diff options
author | nyamatongwe <unknown> | 2004-04-05 20:45:27 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2004-04-05 20:45:27 +0000 |
commit | c736119c81bc75d66ad35e5b1ce750f954efebd1 (patch) | |
tree | 7ea4e38ea7d28da2a8e9e093de7c2d63c427975b | |
parent | 2990b09c5ee8c837dae1e766f468ba6370487c53 (diff) | |
download | scintilla-mirror-c736119c81bc75d66ad35e5b1ce750f954efebd1.tar.gz |
Patch from Kein-Hong Man:
- fixed / interpretation following -> style variables/objects
- fixed ->y type cases where lexer sees regex-type blocks
-rw-r--r-- | src/LexPerl.cxx | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/src/LexPerl.cxx b/src/LexPerl.cxx index 86dad5b57..acc8aba13 100644 --- a/src/LexPerl.cxx +++ b/src/LexPerl.cxx @@ -40,13 +40,15 @@ static bool isSingleCharOp(char ch) { } static inline bool isPerlOperator(char ch) { - if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || ch == '\\' || + if (ch == '^' || ch == '&' || ch == '\\' || ch == '(' || ch == ')' || ch == '-' || ch == '+' || ch == '=' || ch == '|' || ch == '{' || ch == '}' || ch == '[' || ch == ']' || ch == ':' || ch == ';' || - ch == '<' || ch == '>' || ch == ',' || ch == '/' || + ch == '>' || ch == ',' || ch == '?' || ch == '!' || ch == '.' || ch == '~') return true; + // these chars are already tested before this call + // ch == '%' || ch == '*' || ch == '<' || ch == '/' || return false; } @@ -68,6 +70,7 @@ static inline bool isEndVar(char ch) { ch != '_' && ch != '\''; } + static inline bool isNonQuote(char ch) { return isalnum(ch) || ch == '_'; } @@ -276,7 +279,15 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, numState = PERLNUM_V_VECTOR; } } else if (iswordstart(ch)) { - if (ch == 's' && !isNonQuote(chNext)) { + if (chPrev == '>' && styler.SafeGetCharAt(i - 2) == '-') { + state = SCE_PL_IDENTIFIER; // part of "->" expr + if ((!iswordchar(chNext) && chNext != '\'') + || (chNext == '.' && chNext2 == '.')) { + // We need that if length of word == 1! + styler.ColourTo(i, SCE_PL_IDENTIFIER); + state = SCE_PL_DEFAULT; + } + } else if (ch == 's' && !isNonQuote(chNext)) { state = SCE_PL_REGSUBST; Quote.New(2); } else if (ch == 'm' && !isNonQuote(chNext)) { @@ -443,14 +454,45 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, } } break; - // other styles uses the default, preferRE=false case SCE_PL_IDENTIFIER: + preferRE = true; if (bkch == '>') { // inputsymbol preferRE = false; break; } - case SCE_PL_POD: + // backtrack to find "->" or "::" before identifier + while (bk > 0 && styler.StyleAt(bk) == SCE_PL_IDENTIFIER) { + bk--; + } + while (bk > 0) { + bkstyle = styler.StyleAt(bk); + if (bkstyle == SCE_PL_DEFAULT || + bkstyle == SCE_PL_COMMENTLINE) { + } else if (bkstyle == SCE_PL_OPERATOR) { + // gcc 3.2.3 bloats if more compact form used + bkch = styler.SafeGetCharAt(bk); + if (bkch == '>') { // "->" + if (styler.SafeGetCharAt(bk - 1) == '-') { + preferRE = false; + break; + } + } else if (bkch == ':') { // "::" + if (styler.SafeGetCharAt(bk - 1) == ':') { + preferRE = false; + break; + } + } + } else {// bare identifier, usually a function + // call but perl also uses this for + // pseudo-constants (really ambiguous...) + break; + } + bk--; + } + break; + // other styles uses the default, preferRE=false case SCE_PL_WORD: + case SCE_PL_POD: case SCE_PL_HERE_Q: case SCE_PL_HERE_QQ: case SCE_PL_HERE_QX: @@ -594,6 +636,13 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, ch = ' '; } } + } else if (state == SCE_PL_IDENTIFIER) { + if ((!iswordchar(chNext) && chNext != '\'') + || chNext == '.') { + styler.ColourTo(i, SCE_PL_IDENTIFIER); + state = SCE_PL_DEFAULT; + ch = ' '; + } } else { if (state == SCE_PL_COMMENTLINE) { if (isEOLChar(ch)) { @@ -925,4 +974,3 @@ static const char * const perlWordListDesc[] = { }; LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl", FoldPerlDoc, perlWordListDesc); - |