Skip to content

Commit

Permalink
Fix parsing of scientific E in float
Browse files Browse the repository at this point in the history
Do not consume the token unless the next token is valid.

This is going to help when creating the parser for Kernel.Float
  • Loading branch information
herwinw committed Feb 25, 2025
1 parent a50db50 commit fb70372
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/number_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,16 @@ namespace {

void parse_scientific_e() {
if (current().type == TokenType::ScientificE) {
advance();
if (current().type == TokenType::Number) {
append_char('e');
} else if (current().type == TokenType::Sign && peek().type == TokenType::Number) {
append_char('e');
if (peek().type == TokenType::Number) {
append();
advance();
} else if (peek().type == TokenType::Sign) {
advance();
if (peek().type == TokenType::Number) {
append_char('e');
append();
advance();
}
}
if (current().type == TokenType::Number)
parse_number_sequence();
Expand Down

0 comments on commit fb70372

Please sign in to comment.