Allow underscores in GDScript numeric literals

Closes #12928
This commit is contained in:
Bojidar Marinov 2017-11-15 22:53:08 +02:00
parent 6277e6d40a
commit 443ce6fef2
No known key found for this signature in database
GPG key ID: 4D546A8F1E091856
2 changed files with 8 additions and 4 deletions

View file

@ -885,6 +885,9 @@ void GDTokenizerText::_advance() {
return;
}
sign_found = true;
} else if (GETCHAR(i) == '_') {
i++;
continue; // Included for readability, shouldn't be a part of the string
} else
break;
@ -897,7 +900,7 @@ void GDTokenizerText::_advance() {
return;
}
INCPOS(str.length());
INCPOS(i);
if (hexa_found) {
int64_t val = str.hex_to_int64();
_make_constant(val);

View file

@ -894,17 +894,18 @@ void TextEdit::_notification(int p_what) {
is_hex_notation = false;
}
// check for dot or 'x' for hex notation in floating point number
if ((str[j] == '.' || str[j] == 'x') && !in_word && prev_is_number && !is_number) {
// check for dot or underscore or 'x' for hex notation in floating point number
if ((str[j] == '.' || str[j] == 'x' || str[j] == '_') && !in_word && prev_is_number && !is_number) {
is_number = true;
is_symbol = false;
is_char = false;
if (str[j] == 'x' && str[j - 1] == '0') {
is_hex_notation = true;
}
}
if (!in_word && _is_char(str[j])) {
if (!in_word && _is_char(str[j]) && !is_number) {
in_word = true;
}