Skip to content

Commit

Permalink
Support escaping sequence in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Nov 28, 2021
1 parent dcc51a6 commit a65390c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,25 @@ impl<'a> Tokenizer<'a> {
return Ok(s);
}
}
'\\' => {
chars.next();
match chars.peek() {
None => {
return self.tokenizer_error("Unterminated escape sequence");
}
Some(&c) => {
chars.next();
match c {
'0' => s.push('\0'),
'n' => s.push('\n'),
'r' => s.push('\r'),
't' => s.push('\t'),
'Z' => s.push('\x1a'),
x => s.push(x)
}
}
}
}
_ => {
chars.next(); // consume
s.push(ch);
Expand Down

0 comments on commit a65390c

Please sign in to comment.