Merge pull request #12957 from bojidar-bg/12928-numeric-underscores
Allow underscores in GDScript numeric literals
This commit is contained in:
commit
3002130a6d
@ -885,6 +885,9 @@ void GDTokenizerText::_advance() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sign_found = true;
|
sign_found = true;
|
||||||
|
} else if (GETCHAR(i) == '_') {
|
||||||
|
i++;
|
||||||
|
continue; // Included for readability, shouldn't be a part of the string
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -897,7 +900,7 @@ void GDTokenizerText::_advance() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
INCPOS(str.length());
|
INCPOS(i);
|
||||||
if (hexa_found) {
|
if (hexa_found) {
|
||||||
int64_t val = str.hex_to_int64();
|
int64_t val = str.hex_to_int64();
|
||||||
_make_constant(val);
|
_make_constant(val);
|
||||||
|
@ -894,17 +894,18 @@ void TextEdit::_notification(int p_what) {
|
|||||||
is_hex_notation = false;
|
is_hex_notation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for dot or 'x' for hex notation in floating point number
|
// check for dot or underscore or 'x' for hex notation in floating point number
|
||||||
if ((str[j] == '.' || str[j] == 'x') && !in_word && prev_is_number && !is_number) {
|
if ((str[j] == '.' || str[j] == 'x' || str[j] == '_') && !in_word && prev_is_number && !is_number) {
|
||||||
is_number = true;
|
is_number = true;
|
||||||
is_symbol = false;
|
is_symbol = false;
|
||||||
|
is_char = false;
|
||||||
|
|
||||||
if (str[j] == 'x' && str[j - 1] == '0') {
|
if (str[j] == 'x' && str[j - 1] == '0') {
|
||||||
is_hex_notation = true;
|
is_hex_notation = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_word && _is_char(str[j])) {
|
if (!in_word && _is_char(str[j]) && !is_number) {
|
||||||
in_word = true;
|
in_word = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user