Added some comments

pull/9/head
ondra05 2022-04-24 23:33:11 +02:00
parent b462fd9c8f
commit c7ea807a8e
1 changed files with 7 additions and 0 deletions

View File

@ -142,9 +142,14 @@ fn get_string(lexer: &mut Lexer<Token>) -> Option<String> {
let mut string = String::new();
let mut slice = &lexer.slice()[2..];
while let Some(escape_start) = slice.find('"') {
// Push predeceasing string
string.push_str(&slice.get(..escape_start)?);
// Move slice behind escape start delimiter
slice = &slice.get(escape_start + 1..)?;
// Get escape end delimiter position and parse string before it to
// a character from it's unicode value (base-12) and push it to string
let escape_end = slice.find('"')?;
string.push(
u32::from_str_radix(&slice.get(..escape_end)?, 12)
@ -152,9 +157,11 @@ fn get_string(lexer: &mut Lexer<Token>) -> Option<String> {
.and_then(char::from_u32)?,
);
// Move slice behind escape end delimiter
slice = &slice.get(escape_end + 1..)?;
}
// Push remaining string
string.push_str(&slice);
lexer.bump(2);