Skip to content

Commit a65390c

Browse files
committed
Support escaping sequence in strings
1 parent dcc51a6 commit a65390c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/tokenizer.rs

+19
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,25 @@ impl<'a> Tokenizer<'a> {
602602
return Ok(s);
603603
}
604604
}
605+
'\\' => {
606+
chars.next();
607+
match chars.peek() {
608+
None => {
609+
return self.tokenizer_error("Unterminated escape sequence");
610+
}
611+
Some(&c) => {
612+
chars.next();
613+
match c {
614+
'0' => s.push('\0'),
615+
'n' => s.push('\n'),
616+
'r' => s.push('\r'),
617+
't' => s.push('\t'),
618+
'Z' => s.push('\x1a'),
619+
x => s.push(x)
620+
}
621+
}
622+
}
623+
}
605624
_ => {
606625
chars.next(); // consume
607626
s.push(ch);

0 commit comments

Comments
 (0)