diff --git a/crates/oyster_parser/src/lexer.rs b/crates/oyster_parser/src/lexer.rs index f73993e..36f8154 100644 --- a/crates/oyster_parser/src/lexer.rs +++ b/crates/oyster_parser/src/lexer.rs @@ -125,10 +125,10 @@ impl Lexer<'_> { TokenKind::Comment } - '\\' => { - self.next_char(); - TokenKind::EscapedChar - } + '\\' => match self.next_char() { + Some('\n') => TokenKind::Whitespace, + _ => TokenKind::EscapedChar, + }, _ => { self.eat_while(|c| { diff --git a/crates/oyster_parser/tests/it/lexer.rs b/crates/oyster_parser/tests/it/lexer.rs index 6c43425..92a2368 100644 --- a/crates/oyster_parser/tests/it/lexer.rs +++ b/crates/oyster_parser/tests/it/lexer.rs @@ -144,3 +144,12 @@ fn closing_parenthesis_string_mode() { assert_snapshot!(actual); } + +#[test] +fn escape_newline() { + let source = "\\\n"; + + let actual = Lexer::new(source).next_command_token(); + + assert_snapshot!(actual); +} diff --git a/crates/oyster_parser/tests/it/snapshots/it__lexer__escape_newline.snap b/crates/oyster_parser/tests/it/snapshots/it__lexer__escape_newline.snap new file mode 100644 index 0000000..1fb4ba0 --- /dev/null +++ b/crates/oyster_parser/tests/it/snapshots/it__lexer__escape_newline.snap @@ -0,0 +1,8 @@ +--- +source: crates/oyster_parser/tests/it/lexer.rs +expression: actual +--- +Token { + kind: Whitespace, + len: 2, +}