Skip to content

Commit

Permalink
fix(parser): fixed panic when EOL was reached while consuming a long …
Browse files Browse the repository at this point in the history
…literal name
  • Loading branch information
AurumTheEnd committed Mar 8, 2024
1 parent 1308044 commit 0fae7a2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/parser/tokenize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,26 @@ fn tokenize_level(
// move over from the initial `{`, resetting peeking
pop_n_left(&mut buffer, input, 1);
let mut literal_buffer: String = String::new();
let mut did_hit_closing_brace = false;
input.reset_peek();

while let Some(c) = input.peek() {
if c.to_string() == IntermediateToken::LITERAL_END_PATTERN {
// move over from the final `}`
input.next();

did_hit_closing_brace = true;
break;
}

literal_buffer.push(*c);
input.next();
}

if !did_hit_closing_brace {
return Err(TokenizeError::MissingClosingCurlyBrace);
}

// TODO return TokenizeError if builder is empty at the end
(FinalToken::Literal(literal_buffer), 0)
}
Expand Down

0 comments on commit 0fae7a2

Please sign in to comment.