// Scintilla source code edit control/** @file LexHTML.cxx ** Lexer for HTML. **/// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>// The License.txt file describes the conditions under which this software may be distributed.#include<stdlib.h>#include<string.h>#include<stdio.h>#include<stdarg.h>#include<assert.h>#include<ctype.h>#include"ILexer.h"#include"Scintilla.h"#include"SciLexer.h"#include"StringCopy.h"#include"WordList.h"#include"LexAccessor.h"#include"Accessor.h"#include"StyleContext.h"#include"CharacterSet.h"#include"LexerModule.h"#ifdef SCI_NAMESPACEusingnamespaceScintilla;#endif#define SCE_HA_JS (SCE_HJA_START - SCE_HJ_START)#define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)#define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)enumscript_type{eScriptNone=0,eScriptJS,eScriptVBS,eScriptPython,eScriptPHP,eScriptXML,eScriptSGML,eScriptSGMLblock,eScriptComment};enumscript_mode{eHtml=0,eNonHtmlScript,eNonHtmlPreProc,eNonHtmlScriptPreProc};staticinlineboolIsAWordChar(constintch){return(ch<0x80)&&(isalnum(ch)||ch=='.'||ch=='_');}staticinlineboolIsAWordStart(constintch){return(ch<0x80)&&(isalnum(ch)||ch=='_');}inlineboolIsOperator(intch){if(IsASCII(ch)&&isalnum(ch))returnfalse;// '.' left out as it is used to make up numbersif(ch=='%'||ch=='^'||ch=='&'||ch=='*'||ch=='('||ch==')'||ch=='-'||ch=='+'||ch=='='||ch=='|'||ch=='{'||ch=='}'||ch=='['||ch==']'||ch==':'||ch==';'||ch=='<'||ch=='>'||ch==','||ch=='/'||ch=='?'||ch=='!'||ch=='.'||ch=='~')returntrue;returnfalse;}staticvoidGetTextSegment(Accessor&styler,unsignedintstart,unsignedintend,char*s,size_tlen){unsignedinti=0;for(;(i<end-start+1)&&(i<len-1);i++){s[i]=static_cast<char>(MakeLowerCase(styler[start+i]));}s[i]='\0';}staticconstchar*GetNextWord(Accessor&styler,unsignedintstart,char*s,size_tsLen){unsignedinti=0;for(;i<sLen-1;i++){charch=static_cast<char>(styler.SafeGetCharAt(start+i));if((i==0)&&!IsAWordStart(ch))break;if((i>0)&&!IsAWordChar(ch))break;s[i]=ch;}s[i]='\0';returns;}staticscript_typesegIsScriptingIndicator(Accessor&styler,unsignedintstart,unsignedintend,script_typeprevValue){chars[100];GetTextSegment(styler,start,end,s,sizeof(s));//Platform::DebugPrintf("Scripting indicator [%s]\n", s);if(strstr(s,"src"))// External scriptreturneScriptNone;if(strstr(s,"vbs"))returneScriptVBS;if(strstr(s,"pyth"))returneScriptPython;if(strstr(s,"javas"))returneScriptJS;if(strstr(s,"jscr"))returneScriptJS;if(strstr(s,"php"))returneScriptPHP;if(strstr(s,"xml")){constchar*xml=strstr(s,"xml");for(constchar*t=s;t<xml;t++){if(!IsASpace(*t)){returnprevValue;}}returneScriptXML;}returnprevValue;}staticintPrintScriptingIndicatorOffset(Accessor&styler,unsignedintstart,unsignedintend){intiResult=0;chars[100];GetTextSegment(styler,start,end,s,sizeof(s));if(0==strncmp(s,"php",3)){iResult=3;}returniResult;}staticscript_typeScriptOfState(intstate){if((state>=SCE_HP_START)&&(state<=SCE_HP_IDENTIFIER)){returneScriptPython;}elseif((state>=SCE_HB_START)&&(state<=SCE_HB_STRINGEOL)){returneScriptVBS;}elseif((state>=SCE_HJ_START)&&(state<=SCE_HJ_REGEX)){returneScriptJS;}elseif((state>=SCE_HPHP_DEFAULT)&&(state<=SCE_HPHP_COMMENTLINE)){returneScriptPHP;}elseif((state>=SCE_H_SGML_DEFAULT)&&(state<SCE_H_SGML_BLOCK_DEFAULT)){returneScriptSGML;}elseif(state==SCE_H_SGML_BLOCK_DEFAULT){returneScriptSGMLblock;}else{returneScriptNone;}}staticintstatePrintForState(intstate,script_modeinScriptType){intStateToPrint=state;if(state>=SCE_HJ_START){if((state>=SCE_HP_START)&&(state<=SCE_HP_IDENTIFIER)){StateToPrint=state+((inScriptType==eNonHtmlScript)?0:SCE_HA_PYTHON);}elseif((state>=SCE_HB_START)&&(state<=SCE_HB_STRINGEOL)){StateToPrint=state+((inScriptType==eNonHtmlScript)?0:SCE_HA_VBS);}elseif((state>=SCE_HJ_START)&&(state<=SCE_HJ_REGEX)){StateToPrint=state+((inScriptType==eNonHtmlScript)?0:SCE_HA_JS);}}returnStateToPrint;}staticintstateForPrintState(intStateToPrint){intstate;if((StateToPrint>=SCE_HPA_START)&&(StateToPrint<=SCE_HPA_IDENTIFIER)){state=StateToPrint-SCE_HA_PYTHON;}elseif((StateToPrint>=SCE_HBA_START)&&(StateToPrint<=SCE_HBA_STRINGEOL)){state=StateToPrint-SCE_HA_VBS;}elseif((StateToPrint>=SCE_HJA_START)&&(StateToPrint<=SCE_HJA_REGEX)){state=StateToPrint-SCE_HA_JS;}else{state=StateToPrint;}returnstate;}staticinlineboolIsNumber(unsignedintstart,Accessor&styler){returnIsADigit(styler[start])||(styler[start]=='.')||(styler[start]=='-')||(styler[start]=='#');}staticinlineboolisStringState(intstate){boolbResult;switch(state){caseSCE_HJ_DOUBLESTRING:caseSCE_HJ_SINGLESTRING:caseSCE_HJA_DOUBLESTRING:caseSCE_HJA_SINGLESTRING:caseSCE_HB_STRING:caseSCE_HBA_STRING:caseSCE_HP_STRING:caseSCE_HP_CHARACTER:caseSCE_HP_TRIPLE:caseSCE_HP_TRIPLEDOUBLE:caseSCE_HPA_STRING:caseSCE_HPA_CHARACTER:caseSCE_HPA_TRIPLE:caseSCE_HPA_TRIPLEDOUBLE:caseSCE_HPHP_HSTRING:caseSCE_HPHP_SIMPLESTRING:caseSCE_HPHP_HSTRING_VARIABLE:caseSCE_HPHP_COMPLEX_VARIABLE:bResult=true;break;default:bResult=false;break;}returnbResult;}staticinlineboolstateAllowsTermination(intstate){boolallowTermination=!isStringState(state);if(allowTermination){switch(state){caseSCE_HB_COMMENTLINE:caseSCE_HPHP_COMMENT:caseSCE_HP_COMMENTLINE:caseSCE_HPA_COMMENTLINE:allowTermination=false;}}returnallowTermination;}// not really well done, since it's only comments that should lex the %> and <%staticinlineboolisCommentASPState(intstate){boolbResult;switch(state){caseSCE_HJ_COMMENT:caseSCE_HJ_COMMENTLINE:caseSCE_HJ_COMMENTDOC:caseSCE_HB_COMMENTLINE:caseSCE_HP_COMMENTLINE:caseSCE_HPHP_COMMENT:caseSCE_HPHP_COMMENTLINE:bResult=true;break;default:bResult=false;break;}returnbResult;}staticvoidclassifyAttribHTML(unsignedintstart,unsignedintend,WordList&keywords,Accessor&styler){boolwordIsNumber=IsNumber(start,styler);charchAttr=SCE_H_ATTRIBUTEUNKNOWN;if(wordIsNumber){chAttr=SCE_H_NUMBER;}else{chars[100];GetTextSegment(styler,start,end,s,sizeof(s));if(keywords.InList(s))chAttr=SCE_H_ATTRIBUTE;}if((chAttr==SCE_H_ATTRIBUTEUNKNOWN)&&!keywords)// No keywords -> all are knownchAttr=SCE_H_ATTRIBUTE;styler.ColourTo(end,chAttr);}staticintclassifyTagHTML(unsignedintstart,unsignedintend,WordList&keywords,Accessor&styler,bool&tagDontFold,boolcaseSensitive,boolisXml,boolallowScripts){charwithSpace[30+2]=" ";constchar*s=withSpace+1;// Copy after the '<'unsignedinti=1;for(unsignedintcPos=start;cPos<=end&&i<30;cPos++){charch=styler[cPos];if((ch!='<')&&(ch!='/')){withSpace[i++]=caseSensitive?ch:static_cast<char>(MakeLowerCase(ch));}}//The following is only a quick hack, to see if this whole thing would work//we first need the tagname with a trailing space...withSpace[i]=' ';withSpace[i+1]='\0';// if the current language is XML, I can fold any tag// if the current language is HTML, I don't want to fold certain tags (input, meta, etc.)//...to find it in the list of no-container-tagstagDontFold=(!isXml)&&(NULL!=strstr(" area base basefont br col command embed frame hr img input isindex keygen link meta param source track wbr ",withSpace));//now we can remove the trailing spacewithSpace[i]='\0';// No keywords -> all are knowncharchAttr=SCE_H_TAGUNKNOWN;if(s[0]=='!'){chAttr=SCE_H_SGML_DEFAULT;}elseif(!keywords||keywords.InList(s)){chAttr=SCE_H_TAG;}styler.ColourTo(end,chAttr);if(chAttr==SCE_H_TAG){if(allowScripts&&0==strcmp(s,"script")){// check to see if this is a self-closing tag by sniffing aheadboolisSelfClose=false;for(unsignedintcPos=end;cPos<=end+200;cPos++){charch=styler.SafeGetCharAt(cPos,'\0');if(ch=='\0'||ch=='>')break;elseif(ch=='/'&&styler.SafeGetCharAt(cPos+1,'\0')=='>'){isSelfClose=true;break;}}// do not enter a script state if the tag self-closedif(!isSelfClose)chAttr=SCE_H_SCRIPT;}elseif(!isXml&&0==strcmp(s,"comment")){chAttr=SCE_H_COMMENT;}}returnchAttr;}staticvoidclassifyWordHTJS(unsignedintstart,unsignedintend,WordList&keywords,Accessor&styler,script_modeinScriptType){chars[30+1];unsignedinti=0;for(;i<end-start+1&&i<30;i++){s[i]=styler[start+i];}s[i]='\0';charchAttr=SCE_HJ_WORD;boolwordIsNumber=IsADigit(s[0])||((s[0]=='.')&&IsADigit(s[1]));if(wordIsNumber){chAttr=SCE_HJ_NUMBER;}elseif(keywords.InList(s)){chAttr=SCE_HJ_KEYWORD;}styler.ColourTo(end,statePrintForState(chAttr,inScriptType));}staticintclassifyWordHTVB(unsignedintstart,unsignedintend,WordList&keywords,Accessor&styler,script_modeinScriptType){charchAttr=SCE_HB_IDENTIFIER;boolwordIsNumber=IsADigit(styler[start])||(styler[start]=='.');if(wordIsNumber){chAttr=SCE_HB_NUMBER;}else{chars[100];GetTextSegment(styler,start,end,s,sizeof(s));if(keywords.InList(s)){chAttr=SCE_HB_WORD;if(strcmp(s,"rem")==0)chAttr=SCE_HB_COMMENTLINE;}}styler.ColourTo(end,statePrintForState(chAttr,inScriptType));if(chAttr==SCE_HB_COMMENTLINE)returnSCE_HB_COMMENTLINE;elsereturnSCE_HB_DEFAULT;}staticvoidclassifyWordHTPy(unsignedintstart,unsignedintend,WordList&keywords,Accessor&styler,char*prevWord,script_modeinScriptType,boolisMako){boolwordIsNumber=IsADigit(styler[start]);chars[30+1];unsignedinti=0;for(;i<end-start+1&&i<30;i++){s[i]=styler[start+i];}s[i]='\0';charchAttr=SCE_HP_IDENTIFIER;if(0==strcmp(prevWord,"class"))chAttr=SCE_HP_CLASSNAME;elseif(0==strcmp(prevWord,"def"))chAttr=SCE_HP_DEFNAME;elseif(wordIsNumber)chAttr=SCE_HP_NUMBER;elseif(keywords.InList(s))chAttr=SCE_HP_WORD;elseif(isMako&&0==strcmp(s,"block"))chAttr=SCE_HP_WORD;styler.ColourTo(end,statePrintForState(chAttr,inScriptType));strcpy(prevWord,s);}// Update the word colour to default or keyword// Called when in a PHP wordstaticvoidclassifyWordHTPHP(unsignedintstart,unsignedintend,WordList&keywords,Accessor&styler){charchAttr=SCE_HPHP_DEFAULT;boolwordIsNumber=IsADigit(styler[start])||(styler[start]=='.'&&start+1<=end&&IsADigit(styler[start+1]));if(wordIsNumber){chAttr=SCE_HPHP_NUMBER;}else{chars[100];GetTextSegment(styler,start,end,s,sizeof(s));if(keywords.InList(s))chAttr=SCE_HPHP_WORD;}styler.ColourTo(end,chAttr);}staticboolisWordHSGML(unsignedintstart,unsignedintend,WordList&keywords,Accessor&styler){chars[30+1];unsignedinti=0;for(;i<end-start+1&&i<30;i++){s[i]=styler[start+i];}s[i]='\0';returnkeywords.InList(s);}staticboolisWordCdata(unsignedintstart,unsignedintend,Accessor&styler){chars[30+1];unsignedinti=0;for(;i<end-start+1&&i<30;i++){s[i]=styler[start+i];}s[i]='\0';return(0==strcmp(s,"[CDATA["));}// Return the first state to reach when entering a scripting languagestaticintStateForScript(script_typescriptLanguage){intResult;switch(scriptLanguage){caseeScriptVBS:Result=SCE_HB_START;break;caseeScriptPython:Result=SCE_HP_START;break;caseeScriptPHP:Result=SCE_HPHP_DEFAULT;break;caseeScriptXML:Result=SCE_H_TAGUNKNOWN;break;caseeScriptSGML:Result=SCE_H_SGML_DEFAULT;break;caseeScriptComment:Result=SCE_H_COMMENT;break;default:Result=SCE_HJ_START;break;}returnResult;}staticinlineboolissgmlwordchar(intch){return!IsASCII(ch)||(isalnum(ch)||ch=='.'||ch=='_'||ch==':'||ch=='!'||ch=='#'||ch=='[');}staticinlineboolIsPhpWordStart(intch){return(IsASCII(ch)&&(isalpha(ch)||(ch=='_')))||(ch>=0x7f);}staticinlineboolIsPhpWordChar(intch){returnIsADigit(ch)||IsPhpWordStart(ch);}staticboolInTagState(intstate){returnstate==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;}staticboolIsCommentState(constintstate){returnstate==SCE_H_COMMENT||state==SCE_H_SGML_COMMENT;}staticboolIsScriptCommentState(constintstate){returnstate==SCE_HJ_COMMENT||state==SCE_HJ_COMMENTLINE||state==SCE_HJA_COMMENT||state==SCE_HJA_COMMENTLINE||state==SCE_HB_COMMENTLINE||state==SCE_HBA_COMMENTLINE;}staticboolisLineEnd(intch){returnch=='\r'||ch=='\n';}staticboolisMakoBlockEnd(constintch,constintchNext,constchar*blockType){if(strlen(blockType)==0){return((ch=='%')&&(chNext=='>'));}elseif((0==strcmp(blockType,"inherit"))||(0==strcmp(blockType,"namespace"))||(0==strcmp(blockType,"include"))||(0==strcmp(blockType,"page"))){return((ch=='/')&&(chNext=='>'));}elseif(0==strcmp(blockType,"%")){if(ch=='/'&&isLineEnd(chNext))return1;elsereturnisLineEnd(ch);}elseif(0==strcmp(blockType,"{")){returnch=='}';}else{return(ch=='>');}}staticboolisDjangoBlockEnd(constintch,constintchNext,constchar*blockType){if(strlen(blockType)==0){return0;}elseif(0==strcmp(blockType,"%")){return((ch=='%')&&(chNext=='}'));}elseif(0==strcmp(blockType,"{")){return((ch=='}')&&(chNext=='}'));}else{return0;}}staticboolisPHPStringState(intstate){return(state==SCE_HPHP_HSTRING)||(state==SCE_HPHP_SIMPLESTRING)||(state==SCE_HPHP_HSTRING_VARIABLE)||(state==SCE_HPHP_COMPLEX_VARIABLE);}staticintFindPhpStringDelimiter(char*phpStringDelimiter,constintphpStringDelimiterSize,inti,constintlengthDoc,Accessor&styler,bool&isSimpleString){intj;constintbeginning=i-1;boolisValidSimpleString=false;while(i<lengthDoc&&(styler[i]==' '||styler[i]=='\t'))i++;charch=styler.SafeGetCharAt(i);constcharchNext=styler.SafeGetCharAt(i+1);if(!IsPhpWordStart(ch)){if(ch=='\''&&IsPhpWordStart(chNext)){i++;ch=chNext;isSimpleString=true;}else{phpStringDelimiter[0]='\0';returnbeginning;}}phpStringDelimiter[0]=ch;i++;for(j=i;j<lengthDoc&&!isLineEnd(styler[j]);j++){if(!IsPhpWordChar(styler[j])){if(isSimpleString&&(styler[j]=='\'')&&isLineEnd(styler.SafeGetCharAt(j+1))){isValidSimpleString=true;j++;break;}else{phpStringDelimiter[0]='\0';returnbeginning;}}if(j-i<phpStringDelimiterSize-2)phpStringDelimiter[j-i+1]=styler[j];elsei++;}if(isSimpleString&&!isValidSimpleString){phpStringDelimiter[0]='\0';returnbeginning;}phpStringDelimiter[j-i+1-(isSimpleString?1:0)]='\0';returnj-1;}staticvoidColouriseHyperTextDoc(unsignedintstartPos,intlength,intinitStyle,WordList*keywordlists[],Accessor&styler,boolisXml){WordList&keywords=*keywordlists[0];WordList&keywords2=*keywordlists[1];WordList&keywords3=*keywordlists[2];WordList&keywords4=*keywordlists[3];WordList&keywords5=*keywordlists[4];WordList&keywords6=*keywordlists[5];// SGML (DTD) keywordsstyler.StartAt(startPos);charprevWord[200];prevWord[0]='\0';charphpStringDelimiter[200];// PHP is not limited in length, we arephpStringDelimiter[0]='\0';intStateToPrint=initStyle;intstate=stateForPrintState(StateToPrint);charmakoBlockType[200];makoBlockType[0]='\0';intmakoComment=0;chardjangoBlockType[2];djangoBlockType[0]='\0';// If inside a tag, it may be a script tag, so reread from the start of line starting tag to ensure any language tags are seenif(InTagState(state)){while((startPos>0)&&(InTagState(styler.StyleAt(startPos-1)))){intbackLineStart=styler.LineStart(styler.GetLine(startPos-1));length+=startPos-backLineStart;startPos=backLineStart;}state=SCE_H_DEFAULT;}// String can be heredoc, must find a delimiter first. Reread from beginning of line containing the string, to get the correct lineStateif(isPHPStringState(state)){while(startPos>0&&(isPHPStringState(state)||!isLineEnd(styler[startPos-1]))){startPos--;length++;state=styler.StyleAt(startPos);}if(startPos==0)state=SCE_H_DEFAULT;}styler.StartAt(startPos);intlineCurrent=styler.GetLine(startPos);intlineState;if(lineCurrent>0){lineState=styler.GetLineState(lineCurrent-1);}else{// Default client and ASP scripting language is JavaScriptlineState=eScriptJS<<8;// property asp.default.language// Script in ASP code is initially assumed to be in JavaScript.// To change this to VBScript set asp.default.language to 2. Python is 3.lineState|=styler.GetPropertyInt("asp.default.language",eScriptJS)<<4;}script_modeinScriptType=script_mode((lineState>>0)&0x03);// 2 bits of scripting modebooltagOpened=(lineState>>2)&0x01;// 1 bit to know if we are in an opened tagbooltagClosing=(lineState>>3)&0x01;// 1 bit to know if we are in a closing tagbooltagDontFold=false;//some HTML tags should not be foldedscript_typeaspScript=script_type((lineState>>4)&0x0F);// 4 bits of script namescript_typeclientScript=script_type((lineState>>8)&0x0F);// 4 bits of script nameintbeforePreProc=(lineState>>12)&0xFF;// 8 bits of statescript_typescriptLanguage=ScriptOfState(state);// If eNonHtmlScript coincides with SCE_H_COMMENT, assume eScriptCommentif(inScriptType==eNonHtmlScript&&state==SCE_H_COMMENT){scriptLanguage=eScriptComment;}script_typebeforeLanguage=ScriptOfState(beforePreProc);// property fold.html// Folding is turned on or off for HTML and XML files with this option.// The fold option must also be on for folding to occur.constboolfoldHTML=styler.GetPropertyInt("fold.html",0)!=0;constboolfold=foldHTML&&styler.GetPropertyInt("fold",0);// property fold.html.preprocessor// Folding is turned on or off for scripts embedded in HTML files with this option.// The default is on.constboolfoldHTMLPreprocessor=foldHTML&&styler.GetPropertyInt("fold.html.preprocessor",1);constboolfoldCompact=styler.GetPropertyInt("fold.compact",1)!=0;// property fold.hypertext.comment// Allow folding for comments in scripts embedded in HTML.// The default is off.constboolfoldComment=fold&&styler.GetPropertyInt("fold.hypertext.comment",0)!=0;// property fold.hypertext.heredoc// Allow folding for heredocs in scripts embedded in HTML.// The default is off.constboolfoldHeredoc=fold&&styler.GetPropertyInt("fold.hypertext.heredoc",0)!=0;// property html.tags.case.sensitive// For XML and HTML, setting this property to 1 will make tags match in a case// sensitive way which is the expected behaviour for XML and XHTML.constboolcaseSensitive=styler.GetPropertyInt("html.tags.case.sensitive",0)!=0;// property lexer.xml.allow.scripts// Set to 0 to disable scripts in XML.constboolallowScripts=styler.GetPropertyInt("lexer.xml.allow.scripts",1)!=0;// property lexer.html.mako// Set to 1 to enable the mako template language.constboolisMako=styler.GetPropertyInt("lexer.html.mako",0)!=0;// property lexer.html.django// Set to 1 to enable the django template language.constboolisDjango=styler.GetPropertyInt("lexer.html.django",0)!=0;constCharacterSetsetHTMLWord(CharacterSet::setAlphaNum,".-_:!#",0x80,true);constCharacterSetsetTagContinue(CharacterSet::setAlphaNum,".-_:!#[",0x80,true);constCharacterSetsetAttributeContinue(CharacterSet::setAlphaNum,".-_:!#/",0x80,true);// TODO: also handle + and - (except if they're part of ++ or --) and return keywordsconstCharacterSetsetOKBeforeJSRE(CharacterSet::setNone,"([{=,:;!%^&*|?~");intlevelPrev=styler.LevelAt(lineCurrent)&SC_FOLDLEVELNUMBERMASK;intlevelCurrent=levelPrev;intvisibleChars=0;intlineStartVisibleChars=0;intchPrev=' ';intch=' ';intchPrevNonWhite=' ';// look back to set chPrevNonWhite properly for better regex colouringif(scriptLanguage==eScriptJS&&startPos>0){intback=startPos;intstyle=0;while(--back){style=styler.StyleAt(back);if(style<SCE_HJ_DEFAULT||style>SCE_HJ_COMMENTDOC)// includes SCE_HJ_COMMENT & SCE_HJ_COMMENTLINEbreak;}if(style==SCE_HJ_SYMBOLS){chPrevNonWhite=static_cast<unsignedchar>(styler.SafeGetCharAt(back));}}styler.StartSegment(startPos);constintlengthDoc=startPos+length;for(inti=startPos;i<lengthDoc;i++){constintchPrev2=chPrev;chPrev=ch;if(!IsASpace(ch)&&state!=SCE_HJ_COMMENT&&state!=SCE_HJ_COMMENTLINE&&state!=SCE_HJ_COMMENTDOC)chPrevNonWhite=ch;ch=static_cast<unsignedchar>(styler[i]);intchNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));constintchNext2=static_cast<unsignedchar>(styler.SafeGetCharAt(i+2));// Handle DBCS codepagesif(styler.IsLeadByte(static_cast<char>(ch))){chPrev=' ';i+=1;continue;}if((!IsASpace(ch)||!foldCompact)&&fold)visibleChars++;if(!IsASpace(ch))lineStartVisibleChars++;// decide what is the current state to print (depending of the script tag)StateToPrint=statePrintForState(state,inScriptType);// handle script foldingif(fold){switch(scriptLanguage){caseeScriptJS:caseeScriptPHP://not currently supported case eScriptVBS:if((state!=SCE_HPHP_COMMENT)&&(state!=SCE_HPHP_COMMENTLINE)&&(state!=SCE_HJ_COMMENT)&&(state!=SCE_HJ_COMMENTLINE)&&(state!=SCE_HJ_COMMENTDOC)&&(!isStringState(state))){//Platform::DebugPrintf("state=%d, StateToPrint=%d, initStyle=%d\n", state, StateToPrint, initStyle);//if ((state == SCE_HPHP_OPERATOR) || (state == SCE_HPHP_DEFAULT) || (state == SCE_HJ_SYMBOLS) || (state == SCE_HJ_START) || (state == SCE_HJ_DEFAULT)) {if(ch=='#'){intj=i+1;while((j<lengthDoc)&&IsASpaceOrTab(styler.SafeGetCharAt(j))){j++;}if(styler.Match(j,"region")||styler.Match(j,"if")){levelCurrent++;}elseif(styler.Match(j,"end")){levelCurrent--;}}elseif((ch=='{')||(ch=='}')||(foldComment&&(ch=='/')&&(chNext=='*'))){levelCurrent+=(((ch=='{')||(ch=='/'))?1:-1);}}elseif(((state==SCE_HPHP_COMMENT)||(state==SCE_HJ_COMMENT))&&foldComment&&(ch=='*')&&(chNext=='/')){levelCurrent--;}break;caseeScriptPython:if(state!=SCE_HP_COMMENTLINE&&!isMako){if((ch==':')&&((chNext=='\n')||(chNext=='\r'&&chNext2=='\n'))){levelCurrent++;}elseif((ch=='\n')&&!((chNext=='\r')&&(chNext2=='\n'))&&(chNext!='\n')){// check if the number of tabs is lower than the levelintFindlevel=(levelCurrent&~SC_FOLDLEVELBASE)*8;for(intj=0;Findlevel>0;j++){charchTmp=styler.SafeGetCharAt(i+j+1);if(chTmp=='\t'){Findlevel-=8;}elseif(chTmp==' '){Findlevel--;}else{break;}}if(Findlevel>0){levelCurrent-=Findlevel/8;if(Findlevel%8)levelCurrent--;}}}break;default:break;}}if((ch=='\r'&&chNext!='\n')||(ch=='\n')){// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)// Avoid triggering two times on Dos/Win// New line -> record any line state onto /next/ lineif(fold){intlev=levelPrev;if(visibleChars==0)lev|=SC_FOLDLEVELWHITEFLAG;if((levelCurrent>levelPrev)&&(visibleChars>0))lev|=SC_FOLDLEVELHEADERFLAG;styler.SetLevel(lineCurrent,lev);visibleChars=0;levelPrev=levelCurrent;}styler.SetLineState(lineCurrent,((inScriptType&0x03)<<0)|((tagOpened?1:0)<<2)|((tagClosing?1:0)<<3)|((aspScript&0x0F)<<4)|((clientScript&0x0F)<<8)|((beforePreProc&0xFF)<<12));lineCurrent++;lineStartVisibleChars=0;}// handle start of Mako comment lineif(isMako&&ch=='#'&&chNext=='#'){makoComment=1;state=SCE_HP_COMMENTLINE;}// handle end of Mako comment lineelseif(isMako&&makoComment&&(ch=='\r'||ch=='\n')){makoComment=0;styler.ColourTo(i,StateToPrint);if(scriptLanguage==eScriptPython){state=SCE_HP_DEFAULT;}else{state=SCE_H_DEFAULT;}}// Allow falling through to mako handling code if newline is going to end a blockif(((ch=='\r'&&chNext!='\n')||(ch=='\n'))&&(!isMako||(0!=strcmp(makoBlockType,"%")))){}// Ignore everything in mako comment until the line endselseif(isMako&&makoComment){}// generic end of script processingelseif((inScriptType==eNonHtmlScript)&&(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 !!!!!!!!!!!!!!!!!!!!!!)caseSCE_H_DOUBLESTRING:caseSCE_H_SINGLESTRING:caseSCE_HJ_COMMENT:caseSCE_HJ_COMMENTDOC://case SCE_HJ_COMMENTLINE: // removed as this is a common thing done to hide// the end of script marker from some JS interpreters.caseSCE_HB_COMMENTLINE:caseSCE_HBA_COMMENTLINE:caseSCE_HJ_DOUBLESTRING:caseSCE_HJ_SINGLESTRING:caseSCE_HJ_REGEX:caseSCE_HB_STRING:caseSCE_HBA_STRING:caseSCE_HP_STRING:caseSCE_HP_TRIPLE:caseSCE_HP_TRIPLEDOUBLE:caseSCE_HPHP_HSTRING:caseSCE_HPHP_SIMPLESTRING:caseSCE_HPHP_COMMENT:caseSCE_HPHP_COMMENTLINE:break;default:// check if the closing tag is a script tagif(constchar*tag=state==SCE_HJ_COMMENTLINE||isXml?"script":state==SCE_H_COMMENT?"comment":0){intj=i+2;intchr;do{chr=static_cast<int>(*tag++);}while(chr!=0&&chr==MakeLowerCase(styler.SafeGetCharAt(j++)));if(chr!=0)break;}// closing tag of the script (it's a closing HTML tag anyway)styler.ColourTo(i-1,StateToPrint);state=SCE_H_TAGUNKNOWN;inScriptType=eHtml;scriptLanguage=eScriptNone;clientScript=eScriptJS;i+=2;visibleChars+=2;tagClosing=true;continue;}}/////////////////////////////////////// handle the start of PHP pre-processor = Non-HTMLelseif((state!=SCE_H_ASPAT)&&!isPHPStringState(state)&&(state!=SCE_HPHP_COMMENT)&&(state!=SCE_HPHP_COMMENTLINE)&&(ch=='<')&&(chNext=='?')&&!IsScriptCommentState(state)){beforeLanguage=scriptLanguage;scriptLanguage=segIsScriptingIndicator(styler,i+2,i+6,isXml?eScriptXML:eScriptPHP);if((scriptLanguage!=eScriptPHP)&&(isStringState(state)||(state==SCE_H_COMMENT)))continue;styler.ColourTo(i-1,StateToPrint);beforePreProc=state;i++;visibleChars++;i+=PrintScriptingIndicatorOffset(styler,styler.GetStartSegment()+2,i+6);if(scriptLanguage==eScriptXML)styler.ColourTo(i,SCE_H_XMLSTART);elsestyler.ColourTo(i,SCE_H_QUESTION);state=StateForScript(scriptLanguage);if(inScriptType==eNonHtmlScript)inScriptType=eNonHtmlScriptPreProc;elseinScriptType=eNonHtmlPreProc;// Fold whole script, but not if the XML first tag (all XML-like tags in this case)if(foldHTMLPreprocessor&&(scriptLanguage!=eScriptXML)){levelCurrent++;}// should be betterch=static_cast<unsignedchar>(styler.SafeGetCharAt(i));continue;}// handle the start Mako template Python codeelseif(isMako&&scriptLanguage==eScriptNone&&((ch=='<'&&chNext=='%')||(lineStartVisibleChars==1&&ch=='%')||(lineStartVisibleChars==1&&ch=='/'&&chNext=='%')||(ch=='$'&&chNext=='{')||(ch=='<'&&chNext=='/'&&chNext2=='%'))){if(ch=='%'||ch=='/')StringCopy(makoBlockType,"%");elseif(ch=='$')StringCopy(makoBlockType,"{");elseif(chNext=='/')GetNextWord(styler,i+3,makoBlockType,sizeof(makoBlockType));elseGetNextWord(styler,i+2,makoBlockType,sizeof(makoBlockType));styler.ColourTo(i-1,StateToPrint);beforePreProc=state;if(inScriptType==eNonHtmlScript)inScriptType=eNonHtmlScriptPreProc;elseinScriptType=eNonHtmlPreProc;if(chNext=='/'){i+=2;visibleChars+=2;}elseif(ch!='%'){i++;visibleChars++;}state=SCE_HP_START;scriptLanguage=eScriptPython;styler.ColourTo(i,SCE_H_ASP);if(ch!='%'&&ch!='$'&&ch!='/'){i+=static_cast<int>(strlen(makoBlockType));visibleChars+=static_cast<int>(strlen(makoBlockType));if(keywords4.InList(makoBlockType))styler.ColourTo(i,SCE_HP_WORD);elsestyler.ColourTo(i,SCE_H_TAGUNKNOWN);}ch=static_cast<unsignedchar>(styler.SafeGetCharAt(i));continue;}// handle the start/end of Django commentelseif(isDjango&&state!=SCE_H_COMMENT&&(ch=='{'&&chNext=='#')){styler.ColourTo(i-1,StateToPrint);beforePreProc=state;beforeLanguage=scriptLanguage;if(inScriptType==eNonHtmlScript)inScriptType=eNonHtmlScriptPreProc;elseinScriptType=eNonHtmlPreProc;i+=1;visibleChars+=1;scriptLanguage=eScriptComment;state=SCE_H_COMMENT;styler.ColourTo(i,SCE_H_ASP);ch=static_cast<unsignedchar>(styler.SafeGetCharAt(i));continue;}elseif(isDjango&&state==SCE_H_COMMENT&&(ch=='#'&&chNext=='}')){styler.ColourTo(i-1,StateToPrint);i+=1;visibleChars+=1;styler.ColourTo(i,SCE_H_ASP);state=beforePreProc;if(inScriptType==eNonHtmlScriptPreProc)inScriptType=eNonHtmlScript;elseinScriptType=eHtml;scriptLanguage=beforeLanguage;continue;}// handle the start Django template codeelseif(isDjango&&scriptLanguage!=eScriptPython&&(ch=='{'&&(chNext=='%'||chNext=='{'))){if(chNext=='%')StringCopy(djangoBlockType,"%");elseStringCopy(djangoBlockType,"{");styler.ColourTo(i-1,StateToPrint);beforePreProc=state;if(inScriptType==eNonHtmlScript)inScriptType=eNonHtmlScriptPreProc;elseinScriptType=eNonHtmlPreProc;i+=1;visibleChars+=1;state=SCE_HP_START;beforeLanguage=scriptLanguage;scriptLanguage=eScriptPython;styler.ColourTo(i,SCE_H_ASP);ch=static_cast<unsignedchar>(styler.SafeGetCharAt(i));continue;}// handle the start of ASP pre-processor = Non-HTMLelseif(!isMako&&!isDjango&&!isCommentASPState(state)&&(ch=='<')&&(chNext=='%')&&!isPHPStringState(state)){styler.ColourTo(i-1,StateToPrint);beforePreProc=state;if(inScriptType==eNonHtmlScript)inScriptType=eNonHtmlScriptPreProc;elseinScriptType=eNonHtmlPreProc;if(chNext2=='@'){i+=2;// place as if it was the second next char treatedvisibleChars+=2;state=SCE_H_ASPAT;}elseif((chNext2=='-')&&(styler.SafeGetCharAt(i+3)=='-')){styler.ColourTo(i+3,SCE_H_ASP);state=SCE_H_XCCOMMENT;scriptLanguage=eScriptVBS;continue;}else{if(chNext2=='='){i+=2;// place as if it was the second next char treatedvisibleChars+=2;}else{i++;// place as if it was the next char treatedvisibleChars++;}state=StateForScript(aspScript);}scriptLanguage=eScriptVBS;styler.ColourTo(i,SCE_H_ASP);// fold whole scriptif(foldHTMLPreprocessor)levelCurrent++;// should be betterch=static_cast<unsignedchar>(styler.SafeGetCharAt(i));continue;}/////////////////////////////////////// handle the start of SGML language (DTD)elseif(((scriptLanguage==eScriptNone)||(scriptLanguage==eScriptXML))&&(chPrev=='<')&&(ch=='!')&&(StateToPrint!=SCE_H_CDATA)&&(!IsCommentState(StateToPrint))&&(!IsScriptCommentState(StateToPrint))){beforePreProc=state;styler.ColourTo(i-2,StateToPrint);if((chNext=='-')&&(chNext2=='-')){state=SCE_H_COMMENT;// wait for a pending commandstyler.ColourTo(i+2,SCE_H_COMMENT);i+=2;// follow styling after the --}elseif(isWordCdata(i+1,i+7,styler)){state=SCE_H_CDATA;}else{styler.ColourTo(i,SCE_H_SGML_DEFAULT);// <! is defaultscriptLanguage=eScriptSGML;state=SCE_H_SGML_COMMAND;// wait for a pending command}// fold whole tag (-- when closing the tag)if(foldHTMLPreprocessor||state==SCE_H_COMMENT||state==SCE_H_CDATA)levelCurrent++;continue;}// handle the end of Mako Python codeelseif(isMako&&((inScriptType==eNonHtmlPreProc)||(inScriptType==eNonHtmlScriptPreProc))&&(scriptLanguage!=eScriptNone)&&stateAllowsTermination(state)&&isMakoBlockEnd(ch,chNext,makoBlockType)){if(state==SCE_H_ASPAT){aspScript=segIsScriptingIndicator(styler,styler.GetStartSegment(),i-1,aspScript);}if(state==SCE_HP_WORD){classifyWordHTPy(styler.GetStartSegment(),i-1,keywords4,styler,prevWord,inScriptType,isMako);}else{styler.ColourTo(i-1,StateToPrint);}if(0!=strcmp(makoBlockType,"%")&&(0!=strcmp(makoBlockType,"{"))&&ch!='>'){i++;visibleChars++;}elseif(0==strcmp(makoBlockType,"%")&&ch=='/'){i++;visibleChars++;}if(0!=strcmp(makoBlockType,"%")||ch=='/'){styler.ColourTo(i,SCE_H_ASP);}state=beforePreProc;if(inScriptType==eNonHtmlScriptPreProc)inScriptType=eNonHtmlScript;elseinScriptType=eHtml;scriptLanguage=eScriptNone;continue;}// handle the end of Django template codeelseif(isDjango&&((inScriptType==eNonHtmlPreProc)||(inScriptType==eNonHtmlScriptPreProc))&&(scriptLanguage!=eScriptNone)&&stateAllowsTermination(state)&&isDjangoBlockEnd(ch,chNext,djangoBlockType)){if(state==SCE_H_ASPAT){aspScript=segIsScriptingIndicator(styler,styler.GetStartSegment(),i-1,aspScript);}if(state==SCE_HP_WORD){classifyWordHTPy(styler.GetStartSegment(),i-1,keywords4,styler,prevWord,inScriptType,isMako);}else{styler.ColourTo(i-1,StateToPrint);}i+=1;visibleChars+=1;styler.ColourTo(i,SCE_H_ASP);state=beforePreProc;if(inScriptType==eNonHtmlScriptPreProc)inScriptType=eNonHtmlScript;elseinScriptType=eHtml;scriptLanguage=beforeLanguage;continue;}// handle the end of a pre-processor = Non-HTMLelseif((!isMako&&!isDjango&&((inScriptType==eNonHtmlPreProc)||(inScriptType==eNonHtmlScriptPreProc))&&(((scriptLanguage!=eScriptNone)&&stateAllowsTermination(state)))&&(((ch=='%')||(ch=='?'))&&(chNext=='>')))||((scriptLanguage==eScriptSGML)&&(ch=='>')&&(state!=SCE_H_SGML_COMMENT))){if(state==SCE_H_ASPAT){aspScript=segIsScriptingIndicator(styler,styler.GetStartSegment(),i-1,aspScript);}// Bounce out of any ASP modeswitch(state){caseSCE_HJ_WORD:classifyWordHTJS(styler.GetStartSegment(),i-1,keywords2,styler,inScriptType);break;caseSCE_HB_WORD:classifyWordHTVB(styler.GetStartSegment(),i-1,keywords3,styler,inScriptType);break;caseSCE_HP_WORD:classifyWordHTPy(styler.GetStartSegment(),i-1,keywords4,styler,prevWord,inScriptType,isMako);break;caseSCE_HPHP_WORD:classifyWordHTPHP(styler.GetStartSegment(),i-1,keywords5,styler);break;caseSCE_H_XCCOMMENT:styler.ColourTo(i-1,state);break;default:styler.ColourTo(i-1,StateToPrint);break;}if(scriptLanguage!=eScriptSGML){i++;visibleChars++;}if(ch=='%')styler.ColourTo(i,SCE_H_ASP);elseif(scriptLanguage==eScriptXML)styler.ColourTo(i,SCE_H_XMLEND);elseif(scriptLanguage==eScriptSGML)styler.ColourTo(i,SCE_H_SGML_DEFAULT);elsestyler.ColourTo(i,SCE_H_QUESTION);state=beforePreProc;if(inScriptType==eNonHtmlScriptPreProc)inScriptType=eNonHtmlScript;elseinScriptType=eHtml;// Unfold all scripting languages, except for XML tagif(foldHTMLPreprocessor&&(scriptLanguage!=eScriptXML)){levelCurrent--;}scriptLanguage=beforeLanguage;continue;}/////////////////////////////////////switch(state){caseSCE_H_DEFAULT:if(ch=='<'){// in HTML, fold on tag open and unfold on tag closetagOpened=true;tagClosing=(chNext=='/');styler.ColourTo(i-1,StateToPrint);if(chNext!='!')state=SCE_H_TAGUNKNOWN;}elseif(ch=='&'){styler.ColourTo(i-1,SCE_H_DEFAULT);state=SCE_H_ENTITY;}break;caseSCE_H_SGML_DEFAULT:caseSCE_H_SGML_BLOCK_DEFAULT:// if (scriptLanguage == eScriptSGMLblock)// StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;if(ch=='\"'){styler.ColourTo(i-1,StateToPrint);state=SCE_H_SGML_DOUBLESTRING;}elseif(ch=='\''){styler.ColourTo(i-1,StateToPrint);state=SCE_H_SGML_SIMPLESTRING;}elseif((ch=='-')&&(chPrev=='-')){if(static_cast<int>(styler.GetStartSegment())<=(i-2)){styler.ColourTo(i-2,StateToPrint);}state=SCE_H_SGML_COMMENT;}elseif(IsASCII(ch)&&isalpha(ch)&&(chPrev=='%')){styler.ColourTo(i-2,StateToPrint);state=SCE_H_SGML_ENTITY;}elseif(ch=='#'){styler.ColourTo(i-1,StateToPrint);state=SCE_H_SGML_SPECIAL;}elseif(ch=='['){styler.ColourTo(i-1,StateToPrint);scriptLanguage=eScriptSGMLblock;state=SCE_H_SGML_BLOCK_DEFAULT;}elseif(ch==']'){if(scriptLanguage==eScriptSGMLblock){styler.ColourTo(i,StateToPrint);scriptLanguage=eScriptSGML;}else{styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i,SCE_H_SGML_ERROR);}state=SCE_H_SGML_DEFAULT;}elseif(scriptLanguage==eScriptSGMLblock){if((ch=='!')&&(chPrev=='<')){styler.ColourTo(i-2,StateToPrint);styler.ColourTo(i,SCE_H_SGML_DEFAULT);state=SCE_H_SGML_COMMAND;}elseif(ch=='>'){styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i,SCE_H_SGML_DEFAULT);}}break;caseSCE_H_SGML_COMMAND:if((ch=='-')&&(chPrev=='-')){styler.ColourTo(i-2,StateToPrint);state=SCE_H_SGML_COMMENT;}elseif(!issgmlwordchar(ch)){if(isWordHSGML(styler.GetStartSegment(),i-1,keywords6,styler)){styler.ColourTo(i-1,StateToPrint);state=SCE_H_SGML_1ST_PARAM;}else{state=SCE_H_SGML_ERROR;}}break;caseSCE_H_SGML_1ST_PARAM:// wait for the beginning of the wordif((ch=='-')&&(chPrev=='-')){if(scriptLanguage==eScriptSGMLblock){styler.ColourTo(i-2,SCE_H_SGML_BLOCK_DEFAULT);}else{styler.ColourTo(i-2,SCE_H_SGML_DEFAULT);}state=SCE_H_SGML_1ST_PARAM_COMMENT;}elseif(issgmlwordchar(ch)){if(scriptLanguage==eScriptSGMLblock){styler.ColourTo(i-1,SCE_H_SGML_BLOCK_DEFAULT);}else{styler.ColourTo(i-1,SCE_H_SGML_DEFAULT);}// find the length of the wordintsize=1;while(setHTMLWord.Contains(static_cast<unsignedchar>(styler.SafeGetCharAt(i+size))))size++;styler.ColourTo(i+size-1,StateToPrint);i+=size-1;visibleChars+=size-1;ch=static_cast<unsignedchar>(styler.SafeGetCharAt(i));if(scriptLanguage==eScriptSGMLblock){state=SCE_H_SGML_BLOCK_DEFAULT;}else{state=SCE_H_SGML_DEFAULT;}continue;}break;caseSCE_H_SGML_ERROR:if((ch=='-')&&(chPrev=='-')){styler.ColourTo(i-2,StateToPrint);state=SCE_H_SGML_COMMENT;}break;caseSCE_H_SGML_DOUBLESTRING:if(ch=='\"'){styler.ColourTo(i,StateToPrint);state=SCE_H_SGML_DEFAULT;}break;caseSCE_H_SGML_SIMPLESTRING:if(ch=='\''){styler.ColourTo(i,StateToPrint);state=SCE_H_SGML_DEFAULT;}break;caseSCE_H_SGML_COMMENT:if((ch=='-')&&(chPrev=='-')){styler.ColourTo(i,StateToPrint);state=SCE_H_SGML_DEFAULT;}break;caseSCE_H_CDATA:if((chPrev2==']')&&(chPrev==']')&&(ch=='>')){styler.ColourTo(i,StateToPrint);state=SCE_H_DEFAULT;levelCurrent--;}break;caseSCE_H_COMMENT:if((scriptLanguage!=eScriptComment)&&(chPrev2=='-')&&(chPrev=='-')&&(ch=='>')){styler.ColourTo(i,StateToPrint);state=SCE_H_DEFAULT;levelCurrent--;}break;caseSCE_H_SGML_1ST_PARAM_COMMENT:if((ch=='-')&&(chPrev=='-')){styler.ColourTo(i,SCE_H_SGML_COMMENT);state=SCE_H_SGML_1ST_PARAM;}break;caseSCE_H_SGML_SPECIAL:if(!(IsASCII(ch)&&isupper(ch))){styler.ColourTo(i-1,StateToPrint);if(isalnum(ch)){state=SCE_H_SGML_ERROR;}else{state=SCE_H_SGML_DEFAULT;}}break;caseSCE_H_SGML_ENTITY:if(ch==';'){styler.ColourTo(i,StateToPrint);state=SCE_H_SGML_DEFAULT;}elseif(!(IsASCII(ch)&&isalnum(ch))&&ch!='-'&&ch!='.'){styler.ColourTo(i,SCE_H_SGML_ERROR);state=SCE_H_SGML_DEFAULT;}break;caseSCE_H_ENTITY:if(ch==';'){styler.ColourTo(i,StateToPrint);state=SCE_H_DEFAULT;}if(ch!='#'&&!(IsASCII(ch)&&isalnum(ch))// Should check that '#' follows '&', but it is unlikely anyway...&&ch!='.'&&ch!='-'&&ch!='_'&&ch!=':'){// valid in XMLif(!IsASCII(ch))// Possibly start of a multibyte character so don't allow this byte to be in entity stylestyler.ColourTo(i-1,SCE_H_TAGUNKNOWN);elsestyler.ColourTo(i,SCE_H_TAGUNKNOWN);state=SCE_H_DEFAULT;}break;caseSCE_H_TAGUNKNOWN:if(!setTagContinue.Contains(ch)&&!((ch=='/')&&(chPrev=='<'))){inteClass=classifyTagHTML(styler.GetStartSegment(),i-1,keywords,styler,tagDontFold,caseSensitive,isXml,allowScripts);if(eClass==SCE_H_SCRIPT||eClass==SCE_H_COMMENT){if(!tagClosing){inScriptType=eNonHtmlScript;scriptLanguage=eClass==SCE_H_SCRIPT?clientScript:eScriptComment;}else{scriptLanguage=eScriptNone;}eClass=SCE_H_TAG;}if(ch=='>'){styler.ColourTo(i,eClass);if(inScriptType==eNonHtmlScript){state=StateForScript(scriptLanguage);}else{state=SCE_H_DEFAULT;}tagOpened=false;if(!tagDontFold){if(tagClosing){levelCurrent--;}else{levelCurrent++;}}tagClosing=false;}elseif(ch=='/'&&chNext=='>'){if(eClass==SCE_H_TAGUNKNOWN){styler.ColourTo(i+1,SCE_H_TAGUNKNOWN);}else{styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i+1,SCE_H_TAGEND);}i++;ch=chNext;state=SCE_H_DEFAULT;tagOpened=false;}else{if(eClass!=SCE_H_TAGUNKNOWN){if(eClass==SCE_H_SGML_DEFAULT){state=SCE_H_SGML_DEFAULT;}else{state=SCE_H_OTHER;}}}}break;caseSCE_H_ATTRIBUTE:if(!setAttributeContinue.Contains(ch)){if(inScriptType==eNonHtmlScript){intscriptLanguagePrev=scriptLanguage;clientScript=segIsScriptingIndicator(styler,styler.GetStartSegment(),i-1,scriptLanguage);scriptLanguage=clientScript;if((scriptLanguagePrev!=scriptLanguage)&&(scriptLanguage==eScriptNone))inScriptType=eHtml;}classifyAttribHTML(styler.GetStartSegment(),i-1,keywords,styler);if(ch=='>'){styler.ColourTo(i,SCE_H_TAG);if(inScriptType==eNonHtmlScript){state=StateForScript(scriptLanguage);}else{state=SCE_H_DEFAULT;}tagOpened=false;if(!tagDontFold){if(tagClosing){levelCurrent--;}else{levelCurrent++;}}tagClosing=false;}elseif(ch=='='){styler.ColourTo(i,SCE_H_OTHER);state=SCE_H_VALUE;}else{state=SCE_H_OTHER;}}break;caseSCE_H_OTHER:if(ch=='>'){styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i,SCE_H_TAG);if(inScriptType==eNonHtmlScript){state=StateForScript(scriptLanguage);}else{state=SCE_H_DEFAULT;}tagOpened=false;if(!tagDontFold){if(tagClosing){levelCurrent--;}else{levelCurrent++;}}tagClosing=false;}elseif(ch=='\"'){styler.ColourTo(i-1,StateToPrint);state=SCE_H_DOUBLESTRING;}elseif(ch=='\''){styler.ColourTo(i-1,StateToPrint);state=SCE_H_SINGLESTRING;}elseif(ch=='='){styler.ColourTo(i,StateToPrint);state=SCE_H_VALUE;}elseif(ch=='/'&&chNext=='>'){styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i+1,SCE_H_TAGEND);i++;ch=chNext;state=SCE_H_DEFAULT;tagOpened=false;}elseif(ch=='?'&&chNext=='>'){styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i+1,SCE_H_XMLEND);i++;ch=chNext;state=SCE_H_DEFAULT;}elseif(setHTMLWord.Contains(ch)){styler.ColourTo(i-1,StateToPrint);state=SCE_H_ATTRIBUTE;}break;caseSCE_H_DOUBLESTRING:if(ch=='\"'){if(inScriptType==eNonHtmlScript){scriptLanguage=segIsScriptingIndicator(styler,styler.GetStartSegment(),i,scriptLanguage);}styler.ColourTo(i,SCE_H_DOUBLESTRING);state=SCE_H_OTHER;}break;caseSCE_H_SINGLESTRING:if(ch=='\''){if(inScriptType==eNonHtmlScript){scriptLanguage=segIsScriptingIndicator(styler,styler.GetStartSegment(),i,scriptLanguage);}styler.ColourTo(i,SCE_H_SINGLESTRING);state=SCE_H_OTHER;}break;caseSCE_H_VALUE:if(!setHTMLWord.Contains(ch)){if(ch=='\"'&&chPrev=='='){// Should really test for being first characterstate=SCE_H_DOUBLESTRING;}elseif(ch=='\''&&chPrev=='='){state=SCE_H_SINGLESTRING;}else{if(IsNumber(styler.GetStartSegment(),styler)){styler.ColourTo(i-1,SCE_H_NUMBER);}else{styler.ColourTo(i-1,StateToPrint);}if(ch=='>'){styler.ColourTo(i,SCE_H_TAG);if(inScriptType==eNonHtmlScript){state=StateForScript(scriptLanguage);}else{state=SCE_H_DEFAULT;}tagOpened=false;if(!tagDontFold){if(tagClosing){levelCurrent--;}else{levelCurrent++;}}tagClosing=false;}else{state=SCE_H_OTHER;}}}break;caseSCE_HJ_DEFAULT:caseSCE_HJ_START:caseSCE_HJ_SYMBOLS:if(IsAWordStart(ch)){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_WORD;}elseif(ch=='/'&&chNext=='*'){styler.ColourTo(i-1,StateToPrint);if(chNext2=='*')state=SCE_HJ_COMMENTDOC;elsestate=SCE_HJ_COMMENT;if(chNext2=='/'){// Eat the * so it isn't used for the end of the commenti++;}}elseif(ch=='/'&&chNext=='/'){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_COMMENTLINE;}elseif(ch=='/'&&setOKBeforeJSRE.Contains(chPrevNonWhite)){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_REGEX;}elseif(ch=='\"'){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_DOUBLESTRING;}elseif(ch=='\''){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_SINGLESTRING;}elseif((ch=='<')&&(chNext=='!')&&(chNext2=='-')&&styler.SafeGetCharAt(i+3)=='-'){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_COMMENTLINE;}elseif((ch=='-')&&(chNext=='-')&&(chNext2=='>')){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_COMMENTLINE;i+=2;}elseif(IsOperator(ch)){styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i,statePrintForState(SCE_HJ_SYMBOLS,inScriptType));state=SCE_HJ_DEFAULT;}elseif((ch==' ')||(ch=='\t')){if(state==SCE_HJ_START){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_DEFAULT;}}break;caseSCE_HJ_WORD:if(!IsAWordChar(ch)){classifyWordHTJS(styler.GetStartSegment(),i-1,keywords2,styler,inScriptType);//styler.ColourTo(i - 1, eHTJSKeyword);state=SCE_HJ_DEFAULT;if(ch=='/'&&chNext=='*'){if(chNext2=='*')state=SCE_HJ_COMMENTDOC;elsestate=SCE_HJ_COMMENT;}elseif(ch=='/'&&chNext=='/'){state=SCE_HJ_COMMENTLINE;}elseif(ch=='\"'){state=SCE_HJ_DOUBLESTRING;}elseif(ch=='\''){state=SCE_HJ_SINGLESTRING;}elseif((ch=='-')&&(chNext=='-')&&(chNext2=='>')){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_COMMENTLINE;i+=2;}elseif(IsOperator(ch)){styler.ColourTo(i,statePrintForState(SCE_HJ_SYMBOLS,inScriptType));state=SCE_HJ_DEFAULT;}}break;caseSCE_HJ_COMMENT:caseSCE_HJ_COMMENTDOC:if(ch=='/'&&chPrev=='*'){styler.ColourTo(i,StateToPrint);state=SCE_HJ_DEFAULT;ch=' ';}break;caseSCE_HJ_COMMENTLINE:if(ch=='\r'||ch=='\n'){styler.ColourTo(i-1,statePrintForState(SCE_HJ_COMMENTLINE,inScriptType));state=SCE_HJ_DEFAULT;ch=' ';}break;caseSCE_HJ_DOUBLESTRING:if(ch=='\\'){if(chNext=='\"'||chNext=='\''||chNext=='\\'){i++;}}elseif(ch=='\"'){styler.ColourTo(i,statePrintForState(SCE_HJ_DOUBLESTRING,inScriptType));state=SCE_HJ_DEFAULT;}elseif((inScriptType==eNonHtmlScript)&&(ch=='-')&&(chNext=='-')&&(chNext2=='>')){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_COMMENTLINE;i+=2;}elseif(isLineEnd(ch)){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_STRINGEOL;}break;caseSCE_HJ_SINGLESTRING:if(ch=='\\'){if(chNext=='\"'||chNext=='\''||chNext=='\\'){i++;}}elseif(ch=='\''){styler.ColourTo(i,statePrintForState(SCE_HJ_SINGLESTRING,inScriptType));state=SCE_HJ_DEFAULT;}elseif((inScriptType==eNonHtmlScript)&&(ch=='-')&&(chNext=='-')&&(chNext2=='>')){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_COMMENTLINE;i+=2;}elseif(isLineEnd(ch)){styler.ColourTo(i-1,StateToPrint);if(chPrev!='\\'&&(chPrev2!='\\'||chPrev!='\r'||ch!='\n')){state=SCE_HJ_STRINGEOL;}}break;caseSCE_HJ_STRINGEOL:if(!isLineEnd(ch)){styler.ColourTo(i-1,StateToPrint);state=SCE_HJ_DEFAULT;}elseif(!isLineEnd(chNext)){styler.ColourTo(i,StateToPrint);state=SCE_HJ_DEFAULT;}break;caseSCE_HJ_REGEX:if(ch=='\r'||ch=='\n'||ch=='/'){if(ch=='/'){while(IsASCII(chNext)&&islower(chNext)){// gobble regex flagsi++;ch=chNext;chNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));}}styler.ColourTo(i,StateToPrint);state=SCE_HJ_DEFAULT;}elseif(ch=='\\'){// Gobble up the quoted characterif(chNext=='\\'||chNext=='/'){i++;ch=chNext;chNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));}}break;caseSCE_HB_DEFAULT:caseSCE_HB_START:if(IsAWordStart(ch)){styler.ColourTo(i-1,StateToPrint);state=SCE_HB_WORD;}elseif(ch=='\''){styler.ColourTo(i-1,StateToPrint);state=SCE_HB_COMMENTLINE;}elseif(ch=='\"'){styler.ColourTo(i-1,StateToPrint);state=SCE_HB_STRING;}elseif((ch=='<')&&(chNext=='!')&&(chNext2=='-')&&styler.SafeGetCharAt(i+3)=='-'){styler.ColourTo(i-1,StateToPrint);state=SCE_HB_COMMENTLINE;}elseif(IsOperator(ch)){styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i,statePrintForState(SCE_HB_DEFAULT,inScriptType));state=SCE_HB_DEFAULT;}elseif((ch==' ')||(ch=='\t')){if(state==SCE_HB_START){styler.ColourTo(i-1,StateToPrint);state=SCE_HB_DEFAULT;}}break;caseSCE_HB_WORD:if(!IsAWordChar(ch)){state=classifyWordHTVB(styler.GetStartSegment(),i-1,keywords3,styler,inScriptType);if(state==SCE_HB_DEFAULT){if(ch=='\"'){state=SCE_HB_STRING;}elseif(ch=='\''){state=SCE_HB_COMMENTLINE;}elseif(IsOperator(ch)){styler.ColourTo(i,statePrintForState(SCE_HB_DEFAULT,inScriptType));state=SCE_HB_DEFAULT;}}}break;caseSCE_HB_STRING:if(ch=='\"'){styler.ColourTo(i,StateToPrint);state=SCE_HB_DEFAULT;}elseif(ch=='\r'||ch=='\n'){styler.ColourTo(i-1,StateToPrint);state=SCE_HB_STRINGEOL;}break;caseSCE_HB_COMMENTLINE:if(ch=='\r'||ch=='\n'){styler.ColourTo(i-1,StateToPrint);state=SCE_HB_DEFAULT;}break;caseSCE_HB_STRINGEOL:if(!isLineEnd(ch)){styler.ColourTo(i-1,StateToPrint);state=SCE_HB_DEFAULT;}elseif(!isLineEnd(chNext)){styler.ColourTo(i,StateToPrint);state=SCE_HB_DEFAULT;}break;caseSCE_HP_DEFAULT:caseSCE_HP_START:if(IsAWordStart(ch)){styler.ColourTo(i-1,StateToPrint);state=SCE_HP_WORD;}elseif((ch=='<')&&(chNext=='!')&&(chNext2=='-')&&styler.SafeGetCharAt(i+3)=='-'){styler.ColourTo(i-1,StateToPrint);state=SCE_HP_COMMENTLINE;}elseif(ch=='#'){styler.ColourTo(i-1,StateToPrint);state=SCE_HP_COMMENTLINE;}elseif(ch=='\"'){styler.ColourTo(i-1,StateToPrint);if(chNext=='\"'&&chNext2=='\"'){i+=2;state=SCE_HP_TRIPLEDOUBLE;ch=' ';chPrev=' ';chNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));}else{// state = statePrintForState(SCE_HP_STRING,inScriptType);state=SCE_HP_STRING;}}elseif(ch=='\''){styler.ColourTo(i-1,StateToPrint);if(chNext=='\''&&chNext2=='\''){i+=2;state=SCE_HP_TRIPLE;ch=' ';chPrev=' ';chNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));}else{state=SCE_HP_CHARACTER;}}elseif(IsOperator(ch)){styler.ColourTo(i-1,StateToPrint);styler.ColourTo(i,statePrintForState(SCE_HP_OPERATOR,inScriptType));}elseif((ch==' ')||(ch=='\t')){if(state==SCE_HP_START){styler.ColourTo(i-1,StateToPrint);state=SCE_HP_DEFAULT;}}break;caseSCE_HP_WORD:if(!IsAWordChar(ch)){classifyWordHTPy(styler.GetStartSegment(),i-1,keywords4,styler,prevWord,inScriptType,isMako);state=SCE_HP_DEFAULT;if(ch=='#'){state=SCE_HP_COMMENTLINE;}elseif(ch=='\"'){if(chNext=='\"'&&chNext2=='\"'){i+=2;state=SCE_HP_TRIPLEDOUBLE;ch=' ';chPrev=' ';chNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));}else{state=SCE_HP_STRING;}}elseif(ch=='\''){if(chNext=='\''&&chNext2=='\''){i+=2;state=SCE_HP_TRIPLE;ch=' ';chPrev=' ';chNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));}else{state=SCE_HP_CHARACTER;}}elseif(IsOperator(ch)){styler.ColourTo(i,statePrintForState(SCE_HP_OPERATOR,inScriptType));}}break;caseSCE_HP_COMMENTLINE:if(ch=='\r'||ch=='\n'){styler.ColourTo(i-1,StateToPrint);state=SCE_HP_DEFAULT;}break;caseSCE_HP_STRING:if(ch=='\\'){if(chNext=='\"'||chNext=='\''||chNext=='\\'){i++;ch=chNext;chNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));}}elseif(ch=='\"'){styler.ColourTo(i,StateToPrint);state=SCE_HP_DEFAULT;}break;caseSCE_HP_CHARACTER:if(ch=='\\'){if(chNext=='\"'||chNext=='\''||chNext=='\\'){i++;ch=chNext;chNext=static_cast<unsignedchar>(styler.SafeGetCharAt(i+1));}}elseif(ch=='\''){styler.ColourTo(i,StateToPrint);state=SCE_HP_DEFAULT;}break;caseSCE_HP_TRIPLE:if(ch=='\''&&chPrev=='\''&&chPrev2=='\''){styler.ColourTo(i,StateToPrint);state=SCE_HP_DEFAULT;}break;caseSCE_HP_TRIPLEDOUBLE:if(ch=='\"'&&chPrev=='\"'&&chPrev2=='\"'){styler.ColourTo(i,StateToPrint);state=SCE_HP_DEFAULT;}break;///////////// start - PHP state handlingcaseSCE_HPHP_WORD:if(!IsAWordChar(ch)){classifyWordHTPHP(styler.GetStartSegment(),i-1,keywords5,styler);if(ch=='/'&&chNext=='*'){i++;state=SCE_HPHP_COMMENT;}elseif(ch=='/'&&chNext=='/'){i++;state=SCE_HPHP_COMMENTLINE;}elseif(ch=='#'){state=SCE_HPHP_COMMENTLINE;}elseif(ch=='\"'){state=SCE_HPHP_HSTRING;StringCopy(phpStringDelimiter,"\"");}elseif(styler.Match(i,"<<<")){boolisSimpleString=false;i=FindPhpStringDelimiter(phpStringDelimiter,sizeof(phpStringDelimiter),i+3,lengthDoc,styler,isSimpleString);if(strlen(phpStringDelimiter)){state=(isSimpleString?SCE_HPHP_SIMPLESTRING:SCE_HPHP_HSTRING);if(foldHeredoc)levelCurrent++;}}elseif(ch=='\''){state=SCE_HPHP_SIMPLESTRING;StringCopy(phpStringDelimiter,"\'");}elseif(ch=='$'&&IsPhpWordStart(chNext)){state=SCE_HPHP_VARIABLE;}elseif(IsOperator(ch)){state=SCE_HPHP_OPERATOR;}else{state=SCE_HPHP_DEFAULT;}}break;caseSCE_HPHP_NUMBER:// recognize bases 8,10 or 16 integers OR floating-point numbersif(!IsADigit(ch)&&strchr(".xXabcdefABCDEF",ch)==NULL&&((ch!='-'&&ch!='+')||(chPrev!='e'&&chPrev!='E'))){styler.ColourTo(i-1,SCE_HPHP_NUMBER);if(IsOperator(ch))state=SCE_HPHP_OPERATOR;elsestate=SCE_HPHP_DEFAULT;}break;caseSCE_HPHP_VARIABLE:if(!IsPhpWordChar(chNext)){styler.ColourTo(i,SCE_HPHP_VARIABLE);state=SCE_HPHP_DEFAULT;}break;caseSCE_HPHP_COMMENT:if(ch=='/'&&chPrev=='*'){styler.ColourTo(i,StateToPrint);state=SCE_HPHP_DEFAULT;}break;caseSCE_HPHP_COMMENTLINE:if(ch=='\r'||ch=='\n'){styler.ColourTo(i-1,StateToPrint);state=SCE_HPHP_DEFAULT;}break;caseSCE_HPHP_HSTRING:if(ch=='\\'&&(phpStringDelimiter[0]=='\"'||chNext=='$'||chNext=='{')){// skip the next chari++;}elseif(((ch=='{'&&chNext=='$')||(ch=='$'&&chNext=='{'))&&IsPhpWordStart(chNext2)){styler.ColourTo(i-1,StateToPrint);state=SCE_HPHP_COMPLEX_VARIABLE;}elseif(ch=='$'&&IsPhpWordStart(chNext)){styler.ColourTo(i-1,StateToPrint);state=SCE_HPHP_HSTRING_VARIABLE;}elseif(styler.Match(i,phpStringDelimiter)){if(phpStringDelimiter[0]=='\"'){styler.ColourTo(i,StateToPrint);state=SCE_HPHP_DEFAULT;}elseif(isLineEnd(chPrev)){constintpsdLength=static_cast<int>(strlen(phpStringDelimiter));constcharchAfterPsd=styler.SafeGetCharAt(i+psdLength);constcharchAfterPsd2=styler.SafeGetCharAt(i+psdLength+1);if(isLineEnd(chAfterPsd)||(chAfterPsd==';'&&isLineEnd(chAfterPsd2))){i+=(((i+psdLength)<lengthDoc)?psdLength:lengthDoc)-1;styler.ColourTo(i,StateToPrint);state=SCE_HPHP_DEFAULT;if(foldHeredoc)levelCurrent--;}}}break;caseSCE_HPHP_SIMPLESTRING:if(phpStringDelimiter[0]=='\''){if(ch=='\\'){// skip the next chari++;}elseif(ch=='\''){styler.ColourTo(i,StateToPrint);state=SCE_HPHP_DEFAULT;}}elseif(isLineEnd(chPrev)&&styler.Match(i,phpStringDelimiter)){constintpsdLength=static_cast<int>(strlen(phpStringDelimiter));constcharchAfterPsd=styler.SafeGetCharAt(i+psdLength);constcharchAfterPsd2=styler.SafeGetCharAt(i+psdLength+1);if(isLineEnd(chAfterPsd)||(chAfterPsd==';'&&isLineEnd(chAfterPsd2))){i+=(((i+psdLength)<lengthDoc)?psdLength:lengthDoc)-1;styler.ColourTo(i,StateToPrint);state=SCE_HPHP_DEFAULT;if(foldHeredoc)levelCurrent--;}}break;caseSCE_HPHP_HSTRING_VARIABLE:if(!IsPhpWordChar(chNext)){styler.ColourTo(i,StateToPrint);state=SCE_HPHP_HSTRING;}break;caseSCE_HPHP_COMPLEX_VARIABLE:if(ch=='}'){styler.ColourTo(i,StateToPrint);state=SCE_HPHP_HSTRING;}break;caseSCE_HPHP_OPERATOR:caseSCE_HPHP_DEFAULT:styler.ColourTo(i-1,StateToPrint);if(IsADigit(ch)||(ch=='.'&&IsADigit(chNext))){state=SCE_HPHP_NUMBER;}elseif(IsAWordStart(ch)){state=SCE_HPHP_WORD;}elseif(ch=='/'&&chNext=='*'){i++;state=SCE_HPHP_COMMENT;}elseif(ch=='/'&&chNext=='/'){i++;state=SCE_HPHP_COMMENTLINE;}elseif(ch=='#'){state=SCE_HPHP_COMMENTLINE;}elseif(ch=='\"'){state=SCE_HPHP_HSTRING;StringCopy(phpStringDelimiter,"\"");}elseif(styler.Match(i,"<<<")){boolisSimpleString=false;i=FindPhpStringDelimiter(phpStringDelimiter,sizeof(phpStringDelimiter),i+3,lengthDoc,styler,isSimpleString);if(strlen(phpStringDelimiter)){state=(isSimpleString?SCE_HPHP_SIMPLESTRING:SCE_HPHP_HSTRING);if(foldHeredoc)levelCurrent++;}}elseif(ch=='\''){state=SCE_HPHP_SIMPLESTRING;StringCopy(phpStringDelimiter,"\'");}elseif(ch=='$'&&IsPhpWordStart(chNext)){state=SCE_HPHP_VARIABLE;}elseif(IsOperator(ch)){state=SCE_HPHP_OPERATOR;}elseif((state==SCE_HPHP_OPERATOR)&&(IsASpace(ch))){state=SCE_HPHP_DEFAULT;}break;///////////// end - PHP state handling}// Some of the above terminated their lexeme but since the same character starts// the same class again, only reenter if non empty segment.boolnonEmptySegment=i>=static_cast<int>(styler.GetStartSegment());if(state==SCE_HB_DEFAULT){// One of the above succeededif((ch=='\"')&&(nonEmptySegment)){state=SCE_HB_STRING;}elseif(ch=='\''){state=SCE_HB_COMMENTLINE;}elseif(IsAWordStart(ch)){state=SCE_HB_WORD;}elseif(IsOperator(ch)){styler.ColourTo(i,SCE_HB_DEFAULT);}}elseif(state==SCE_HBA_DEFAULT){// One of the above succeededif((ch=='\"')&&(nonEmptySegment)){state=SCE_HBA_STRING;}elseif(ch=='\''){state=SCE_HBA_COMMENTLINE;}elseif(IsAWordStart(ch)){state=SCE_HBA_WORD;}elseif(IsOperator(ch)){styler.ColourTo(i,SCE_HBA_DEFAULT);}}elseif(state==SCE_HJ_DEFAULT){// One of the above succeededif(ch=='/'&&chNext=='*'){if(styler.SafeGetCharAt(i+2)=='*')state=SCE_HJ_COMMENTDOC;elsestate=SCE_HJ_COMMENT;}elseif(ch=='/'&&chNext=='/'){state=SCE_HJ_COMMENTLINE;}elseif((ch=='\"')&&(nonEmptySegment)){state=SCE_HJ_DOUBLESTRING;}elseif((ch=='\'')&&(nonEmptySegment)){state=SCE_HJ_SINGLESTRING;}elseif(IsAWordStart(ch)){state=SCE_HJ_WORD;}elseif(IsOperator(ch)){styler.ColourTo(i,statePrintForState(SCE_HJ_SYMBOLS,inScriptType));}}}switch(state){caseSCE_HJ_WORD:classifyWordHTJS(styler.GetStartSegment(),lengthDoc-1,keywords2,styler,inScriptType);break;caseSCE_HB_WORD:classifyWordHTVB(styler.GetStartSegment(),lengthDoc-1,keywords3,styler,inScriptType);break;caseSCE_HP_WORD:classifyWordHTPy(styler.GetStartSegment(),lengthDoc-1,keywords4,styler,prevWord,inScriptType,isMako);break;caseSCE_HPHP_WORD:classifyWordHTPHP(styler.GetStartSegment(),lengthDoc-1,keywords5,styler);break;default:StateToPrint=statePrintForState(state,inScriptType);if(static_cast<int>(styler.GetStartSegment())<lengthDoc)styler.ColourTo(lengthDoc-1,StateToPrint);break;}// Fill in the real level of the next line, keeping the current flags as they will be filled in laterif(fold){intflagsNext=styler.LevelAt(lineCurrent)&~SC_FOLDLEVELNUMBERMASK;styler.SetLevel(lineCurrent,levelPrev|flagsNext);}}staticvoidColouriseXMLDoc(unsignedintstartPos,intlength,intinitStyle,WordList*keywordlists[],Accessor&styler){// Passing in true because we're lexing XMLColouriseHyperTextDoc(startPos,length,initStyle,keywordlists,styler,true);}staticvoidColouriseHTMLDoc(unsignedintstartPos,intlength,intinitStyle,WordList*keywordlists[],Accessor&styler){// Passing in false because we're notlexing XMLColouriseHyperTextDoc(startPos,length,initStyle,keywordlists,styler,false);}staticvoidColourisePHPScriptDoc(unsignedintstartPos,intlength,intinitStyle,WordList*keywordlists[],Accessor&styler){if(startPos==0)initStyle=SCE_HPHP_DEFAULT;ColouriseHTMLDoc(startPos,length,initStyle,keywordlists,styler);}staticconstchar*consthtmlWordListDesc[]={"HTML elements and attributes","JavaScript keywords","VBScript keywords","Python keywords","PHP keywords","SGML and DTD keywords",0,};staticconstchar*constphpscriptWordListDesc[]={"",//Unused"",//Unused"",//Unused"",//Unused"PHP keywords","",//Unused0,};LexerModulelmHTML(SCLEX_HTML,ColouriseHTMLDoc,"hypertext",0,htmlWordListDesc);LexerModulelmXML(SCLEX_XML,ColouriseXMLDoc,"xml",0,htmlWordListDesc);LexerModulelmPHPSCRIPT(SCLEX_PHPSCRIPT,ColourisePHPScriptDoc,"phpscript",0,phpscriptWordListDesc);