Merge pull request #24634 from BastiaanOlij/fix_e_notation_in_shaders

Always treat exponent as float
This commit is contained in:
Rémi Verschelde 2018-12-30 13:36:38 +01:00 committed by GitHub
commit 8b7028e7b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -525,7 +525,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
bool exponent_found = false; bool exponent_found = false;
bool hexa_found = false; bool hexa_found = false;
bool sign_found = false; bool sign_found = false;
bool minus_exponent_found = false;
bool float_suffix_found = false; bool float_suffix_found = false;
String str; String str;
@ -557,8 +556,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
if (sign_found) if (sign_found)
return _make_token(TK_ERROR, "Invalid numeric constant"); return _make_token(TK_ERROR, "Invalid numeric constant");
sign_found = true; sign_found = true;
if (GETCHAR(i) == '-')
minus_exponent_found = true;
} else } else
break; break;
@ -571,7 +568,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
if (hexa_found) { if (hexa_found) {
//hex integers eg."0xFF" or "0x12AB", etc - NOT supported yet //hex integers eg."0xFF" or "0x12AB", etc - NOT supported yet
return _make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant - Not supported"); return _make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant - Not supported");
} else if (period_found || float_suffix_found) { } else if (period_found || exponent_found || float_suffix_found) {
//floats //floats
if (period_found) { if (period_found) {
if (float_suffix_found) { if (float_suffix_found) {
@ -614,7 +611,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
char_idx += str.length(); char_idx += str.length();
Token tk; Token tk;
if (period_found || minus_exponent_found || float_suffix_found) if (period_found || exponent_found || float_suffix_found)
tk.type = TK_REAL_CONSTANT; tk.type = TK_REAL_CONSTANT;
else else
tk.type = TK_INT_CONSTANT; tk.type = TK_INT_CONSTANT;