diff options
Diffstat (limited to 'lexers/LexLua.cxx')
| -rw-r--r-- | lexers/LexLua.cxx | 82 | 
1 files changed, 76 insertions, 6 deletions
| diff --git a/lexers/LexLua.cxx b/lexers/LexLua.cxx index 1dc9d4058..9e48efcd9 100644 --- a/lexers/LexLua.cxx +++ b/lexers/LexLua.cxx @@ -59,7 +59,7 @@ static void ColouriseLuaDoc(  	// Accepts accented characters  	CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); -	CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); +	CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true);  	// Not exactly following number definition (several dots are seen as OK, etc.)  	// but probably enough in most cases. [pP] is for hex floats.  	CharacterSet setNumber(CharacterSet::setDigits, ".-+abcdefpABCDEFP"); @@ -71,7 +71,7 @@ static void ColouriseLuaDoc(  	// Initialize long string [[ ... ]] or block comment --[[ ... ]] nesting level,  	// if we are inside such a string. Block comment was introduced in Lua 5.0,  	// blocks with separators [=[ ... ]=] in Lua 5.1. -	// Continuation of a string (\* whitespace escaping) is controlled by stringWs. +	// Continuation of a string (\z whitespace escaping) is controlled by stringWs.  	int nestLevel = 0;  	int sepCount = 0;  	int stringWs = 0; @@ -130,6 +130,61 @@ static void ColouriseLuaDoc(  		// Determine if the current state should terminate.  		if (sc.state == SCE_LUA_OPERATOR) { +			if (sc.ch == ':' && sc.chPrev == ':') {	// :: <label> :: forward scan +				sc.Forward(); +				int ln = 0, maxln = startPos + length - sc.currentPos; +				int c; +				while (ln < maxln) {		// determine line extent +					c = sc.GetRelative(ln); +					if (c == '\r' || c == '\n') +						break; +					ln++; +				} +				maxln = ln; ln = 0; +				while (ln < maxln) {		// skip over spaces/tabs +					if (!IsASpaceOrTab(sc.GetRelative(ln))) +						break; +					ln++; +				} +				int ws1 = ln; +				if (setWordStart.Contains(sc.GetRelative(ln))) { +					int i = 0; +					char s[100]; +					while (ln < maxln) {	// get potential label +						c = sc.GetRelative(ln); +						if (!setWord.Contains(c)) +							break; +						if (i < 90) +							s[i++] = c; +						ln++; +					} +					s[i] = '\0'; int lbl = ln; +					if (!keywords.InList(s)) { +						while (ln < maxln) {		// skip over spaces/tabs +							if (!IsASpaceOrTab(sc.GetRelative(ln))) +								break; +							ln++; +						} +						int ws2 = ln - lbl; +						if (sc.GetRelative(ln) == ':' && sc.GetRelative(ln + 1) == ':') { +							// final :: found, complete valid label construct +							sc.ChangeState(SCE_LUA_LABEL); +							if (ws1) { +								sc.SetState(SCE_LUA_DEFAULT); +								sc.Forward(ws1); +							} +							sc.SetState(SCE_LUA_LABEL); +							sc.Forward(lbl - ws1); +							if (ws2) { +								sc.SetState(SCE_LUA_DEFAULT); +								sc.Forward(ws2); +							} +							sc.SetState(SCE_LUA_LABEL); +							sc.Forward(2); +						} +					} +				} +			}  			sc.SetState(SCE_LUA_DEFAULT);  		} else if (sc.state == SCE_LUA_NUMBER) {  			// We stop the number definition on non-numerical non-dot non-eEpP non-sign non-hexdigit char @@ -140,11 +195,26 @@ static void ColouriseLuaDoc(  					sc.SetState(SCE_LUA_DEFAULT);  			}  		} else if (sc.state == SCE_LUA_IDENTIFIER) { -			if (!setWord.Contains(sc.ch) || sc.Match('.', '.')) { +			if (!(setWord.Contains(sc.ch) || sc.ch == '.') || sc.Match('.', '.')) {  				char s[100];  				sc.GetCurrent(s, sizeof(s));  				if (keywords.InList(s)) {  					sc.ChangeState(SCE_LUA_WORD); +					if (strcmp(s, "goto") == 0) {	// goto <label> forward scan +						sc.SetState(SCE_LUA_DEFAULT); +						while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd) +							sc.Forward(); +						if (setWordStart.Contains(sc.ch)) { +							sc.SetState(SCE_LUA_LABEL); +							sc.Forward(); +							while (setWord.Contains(sc.ch)) +								sc.Forward(); +							sc.GetCurrent(s, sizeof(s)); +							if (keywords.InList(s)) +								sc.ChangeState(SCE_LUA_WORD); +						} +						sc.SetState(SCE_LUA_DEFAULT); +					}  				} else if (keywords2.InList(s)) {  					sc.ChangeState(SCE_LUA_WORD2);  				} else if (keywords3.InList(s)) { @@ -174,7 +244,7 @@ static void ColouriseLuaDoc(  			if (sc.ch == '\\') {  				if (setEscapeSkip.Contains(sc.chNext)) {  					sc.Forward(); -				} else if (sc.chNext == '*') { +				} else if (sc.chNext == 'z') {  					sc.Forward();  					stringWs = 0x100;  				} @@ -192,7 +262,7 @@ static void ColouriseLuaDoc(  			if (sc.ch == '\\') {  				if (setEscapeSkip.Contains(sc.chNext)) {  					sc.Forward(); -				} else if (sc.chNext == '*') { +				} else if (sc.chNext == 'z') {  					sc.Forward();  					stringWs = 0x100;  				} @@ -269,7 +339,7 @@ static void ColouriseLuaDoc(  		}  	} -	if (setWord.Contains(sc.chPrev)) { +	if (setWord.Contains(sc.chPrev) || sc.chPrev == '.') {  		char s[100];  		sc.GetCurrent(s, sizeof(s));  		if (keywords.InList(s)) { | 
