diff options
-rw-r--r-- | include/SciLexer.h | 2 | ||||
-rw-r--r-- | include/Scintilla.iface | 2 | ||||
-rw-r--r-- | src/LexHTML.cxx | 63 |
3 files changed, 62 insertions, 5 deletions
diff --git a/include/SciLexer.h b/include/SciLexer.h index 9960b8531..076a96fb1 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -160,7 +160,7 @@ #define SCE_HPHP_VARIABLE 123 #define SCE_HPHP_COMMENT 124 #define SCE_HPHP_COMMENTLINE 125 -#define SCE_HPHP_STRINGEOL 126 +#define SCE_HPHP_HSTRING_VARIABLE 126 #define SCE_PL_DEFAULT 0 #define SCE_PL_ERROR 1 #define SCE_PL_COMMENTLINE 2 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index b585c2a7c..c4d3c54f7 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1272,7 +1272,7 @@ val SCE_HPHP_NUMBER=122 val SCE_HPHP_VARIABLE=123 val SCE_HPHP_COMMENT=124 val SCE_HPHP_COMMENTLINE=125 -val SCE_HPHP_STRINGEOL=126 +val SCE_HPHP_HSTRING_VARIABLE=126 # Lexical states for SCLEX_PERL val SCE_PL_DEFAULT=0 val SCE_PL_ERROR=1 diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx index 860adc891..d74981ec5 100644 --- a/src/LexHTML.cxx +++ b/src/LexHTML.cxx @@ -124,6 +124,50 @@ static inline bool IsNumber(unsigned int start, Accessor &styler) { (styler[start] == '-') || (styler[start] == '#'); } +static inline bool isStringState(int state) { + bool bResult; + + switch (state) { + case SCE_HJ_DOUBLESTRING: + case SCE_HJ_SINGLESTRING: + case SCE_HJA_DOUBLESTRING: + case SCE_HJA_SINGLESTRING: + case SCE_HB_STRING: + case SCE_HBA_STRING: + case SCE_HP_STRING: + case SCE_HPA_STRING: + case SCE_HPHP_HSTRING: + case SCE_HPHP_SIMPLESTRING: + bResult = true; + break; + default : + bResult = false; + break; + } + return bResult; +} + +// not really well done, since it's only comments that should lex the %> and <% +static inline bool isCommentASPState(int state) { + bool bResult; + + switch (state) { + case SCE_HJ_COMMENT: + case SCE_HJ_COMMENTLINE: + case SCE_HJ_COMMENTDOC: + case SCE_HB_COMMENTLINE: + case SCE_HP_COMMENTLINE: + case SCE_HPHP_COMMENT: + case SCE_HPHP_COMMENTLINE: + bResult = true; + break; + default : + bResult = false; + break; + } + return bResult; +} + static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { bool wordIsNumber = IsNumber(start, styler); char chAttr = SCE_H_ATTRIBUTEUNKNOWN; @@ -478,7 +522,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty ///////////////////////////////////// // handle the start of PHP pre-processor = Non-HTML - else if ((ch == '<') && (chNext == '?')) { + else if ((state != SCE_H_ASPAT) && (ch == '<') && (chNext == '?')) { styler.ColourTo(i - 1, StateToPrint); beforePreProc = state; scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment() + 2, i + 10, eScriptPHP); @@ -501,7 +545,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } // handle the start of ASP pre-processor = Non-HTML - else if ((ch == '<') && (chNext == '%')) { + else if (!isCommentASPState(state) && (ch == '<') && (chNext == '%')) { styler.ColourTo(i - 1, StateToPrint); beforePreProc = state; if (inScriptType == eNonHtmlScript) @@ -530,7 +574,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } // handle the end of a pre-processor = Non-HTML - else if (((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && ((ch == '?') || (ch == '%')) && (chNext == '>')) { + else if (((inScriptType == eNonHtmlPreProc) + || (inScriptType == eNonHtmlScriptPreProc)) + && (((scriptLanguage == eScriptPHP) && (ch == '?')) + || (!isStringState(state) && !isCommentASPState(state) && (ch == '%'))) + && (chNext == '>')) { if (state == SCE_H_ASPAT) { defaultScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, defaultScript); } @@ -1164,6 +1212,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (ch == '\\') { // skip the next char i++; + } else if (ch == '$') { + styler.ColourTo(i-1, StateToPrint); + state = SCE_HPHP_HSTRING_VARIABLE; } else if (ch == '\"') { styler.ColourTo(i, StateToPrint); state = SCE_HPHP_DEFAULT; @@ -1178,6 +1229,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_HPHP_DEFAULT; } break; + case SCE_HPHP_HSTRING_VARIABLE: + if (!iswordstart(ch)) { + styler.ColourTo(i-1, StateToPrint); + state = SCE_HPHP_HSTRING; + } + break; case SCE_HPHP_DEFAULT: styler.ColourTo(i - 1, StateToPrint); if (isdigit(ch)) { |