fix(lexer): fix inproper handling of \\\n

Before it would escape the newline resulting in passing it as an
argument.

Signed-off-by: Charlotte Meyer <dev@buffet.sh>
This commit is contained in:
buffet 2022-10-26 14:46:13 +00:00
parent aeb61873c1
commit fbba44312f
3 changed files with 21 additions and 4 deletions

View file

@ -125,10 +125,10 @@ impl Lexer<'_> {
TokenKind::Comment TokenKind::Comment
} }
'\\' => { '\\' => match self.next_char() {
self.next_char(); Some('\n') => TokenKind::Whitespace,
TokenKind::EscapedChar _ => TokenKind::EscapedChar,
} },
_ => { _ => {
self.eat_while(|c| { self.eat_while(|c| {

View file

@ -144,3 +144,12 @@ fn closing_parenthesis_string_mode() {
assert_snapshot!(actual); assert_snapshot!(actual);
} }
#[test]
fn escape_newline() {
let source = "\\\n";
let actual = Lexer::new(source).next_command_token();
assert_snapshot!(actual);
}

View file

@ -0,0 +1,8 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: Whitespace,
len: 2,
}