diff --git a/src/lex.rs b/src/lex.rs index a7439c7..9f98dda 100644 --- a/src/lex.rs +++ b/src/lex.rs @@ -136,7 +136,7 @@ impl<'s> Lexer<'s> { '\\' => { let next = self.peek(); - if next == ' ' || next.is_ascii_punctuation() { + if next.is_whitespace() || next.is_ascii_punctuation() { self.escape = true; Escape } else { @@ -316,6 +316,13 @@ mod test { test_lex!(r#"\{-"#, Escape.l(1), Text.l(1), Seq(Hyphen).l(1)); } + #[test] + fn hardbreak() { + test_lex!("a\\\n", Text.l(1), Escape.l(1), Hardbreak.l(1)); + test_lex!("a\\ \n", Text.l(1), Escape.l(1), Hardbreak.l(4)); + test_lex!("a\\\t \t \n", Text.l(1), Escape.l(1), Hardbreak.l(5)); + } + #[test] fn delim() { test_lex!("{-", Open(BraceHyphen).l(2));