Dont consume the character immediately following a number

This commit is contained in:
Deukhoofd 2019-05-19 12:20:08 +02:00
parent 22e450e7e7
commit 600315d401
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 6 additions and 2 deletions

View File

@ -70,12 +70,15 @@ IToken* Lexer::LexNumber(char c){
bool has_point = false; bool has_point = false;
bool is_searching = true; bool is_searching = true;
while (is_searching){ while (is_searching){
char next = Lexer::Next(); char next = Lexer::Peek();
int next_val = CharToInt(next); int next_val = CharToInt(next);
if (next_val == -1){ if (next_val == -1){
switch (next){ switch (next){
case '_': continue; case '_':
Lexer::Next();
continue;
case '.': case '.':
Lexer::Next();
has_point = true; has_point = true;
decimal_index = 0; decimal_index = 0;
float_value = int_value; float_value = int_value;
@ -86,6 +89,7 @@ IToken* Lexer::LexNumber(char c){
} }
} }
else{ else{
Lexer::Next();
if (has_point){ if (has_point){
decimal_index++; decimal_index++;
float_value += next_val / pow(10, decimal_index); float_value += next_val / pow(10, decimal_index);