diff options
| author | SiegeLord <slabode@aim.com> | 2014-01-11 16:27:48 -0500 | 
|---|---|---|
| committer | SiegeLord <slabode@aim.com> | 2014-01-11 16:27:48 -0500 | 
| commit | 1f93d72710cd0d97c302ebb094b5aed01c786384 (patch) | |
| tree | 39ba0660ad0faa78f03469702bfb084484d4b125 /lexers/LexRust.cxx | |
| parent | c556c61445f054db4be6976ecc1633b3c36b6cad (diff) | |
| download | scintilla-mirror-1f93d72710cd0d97c302ebb094b5aed01c786384.tar.gz | |
Rust: Make lexing of float literals more correct.
Diffstat (limited to 'lexers/LexRust.cxx')
| -rw-r--r-- | lexers/LexRust.cxx | 44 | 
1 files changed, 23 insertions, 21 deletions
| diff --git a/lexers/LexRust.cxx b/lexers/LexRust.cxx index 8917b9182..bf59933af 100644 --- a/lexers/LexRust.cxx +++ b/lexers/LexRust.cxx @@ -240,22 +240,6 @@ static void ScanDigits(Accessor& styler, int& pos, int base) {  	}  } -static bool ScanExponent(Accessor& styler, int& pos) { -	int c = styler.SafeGetCharAt(pos, '\0'); -	if (c == 'e' || c == 'E') { -		pos++; -		c = styler.SafeGetCharAt(pos, '\0'); -		if (c == '-' || c == '+') -			pos++; -		int old_pos = pos; -		ScanDigits(styler, pos, 10); -		if (old_pos == pos)	{ -			return false; -		} -	} -	return true; -} -  static void ScanNumber(Accessor& styler, int& pos) {  	int base = 10;  	int c = styler.SafeGetCharAt(pos, '\0'); @@ -287,13 +271,31 @@ static void ScanNumber(Accessor& styler, int& pos) {  		} else if (c == '6' && n == '4') {  			pos += 2;  		} -	} else if (c == '.') { -		error = base != 10; -		pos++; -		ScanDigits(styler, pos, 10); -		error |= !ScanExponent(styler, pos); +	} else { +		n = styler.SafeGetCharAt(pos + 1, '\0'); +		if (c == '.' && !(IsIdentifierStart(n) || n == '.')) { +			error |= base != 10; +			pos++; +			ScanDigits(styler, pos, 10); +		} + +		c = styler.SafeGetCharAt(pos, '\0'); +		if (c == 'e' || c == 'E') { +			error |= base != 10; +			pos++; +			c = styler.SafeGetCharAt(pos, '\0'); +			if (c == '-' || c == '+') +				pos++; +			int old_pos = pos; +			ScanDigits(styler, pos, 10); +			if (old_pos == pos) { +				error = true; +			} +		} +		  		c = styler.SafeGetCharAt(pos, '\0');  		if (c == 'f') { +			error |= base != 10;  			pos++;  			c = styler.SafeGetCharAt(pos, '\0');  			n = styler.SafeGetCharAt(pos + 1, '\0'); | 
