eval expressions: unary +, correctly lex exponentiated numerics

This commit is contained in:
Ryan Fleury
2024-10-21 09:23:31 -07:00
parent 52245a8e5a
commit d0915ec9a7
6 changed files with 25 additions and 9 deletions
+8 -1
View File
@@ -389,6 +389,7 @@ e_token_array_from_text(Arena *arena, String8 text)
E_TokenKind active_token_kind = E_TokenKind_Null;
B32 active_token_kind_started_with_tick = 0;
B32 escaped = 0;
B32 exp = 0;
for(U64 idx = 0, advance = 0; idx <= text.size; idx += advance)
{
U8 byte = (idx+0 < text.size) ? text.str[idx+0] : 0;
@@ -486,11 +487,17 @@ e_token_array_from_text(Arena *arena, String8 text)
}break;
case E_TokenKind_Numeric:
{
if(!char_is_alpha(byte) && !char_is_digit(byte, 10) && byte != '.' && byte != ':')
if(exp && byte == '+' || byte == '-'){}
else if(!char_is_alpha(byte) && !char_is_digit(byte, 10) && byte != '.' && byte != ':')
{
advance = 0;
token_formed = 1;
}
else
{
exp = 0;
exp = (byte == 'e');
}
}break;
case E_TokenKind_StringLiteral:
{