From 94c95bd15e63520fc2844ffb1bc387d1bc9c79ae Mon Sep 17 00:00:00 2001 From: Joey Hain Date: Sat, 27 Oct 2018 12:41:52 -0700 Subject: Allow whitespace after line ending backslash (#162) --- src/tokens.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tokens.rs b/src/tokens.rs index 15c3b41..382c1ec 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -364,7 +364,24 @@ impl<'a> Tokenizer<'a> { let len = if c == 'u' {4} else {8}; val.push(me.hex(start, i, len)?); } - Some((_, '\n')) if multi => { + Some((i, c @ ' ')) | + Some((i, c @ '\t')) | + Some((i, c @ '\n')) if multi => { + if c != '\n' { + while let Some((_, ch)) = me.chars.clone().next() { + match ch { + ' ' | '\t' => { + me.chars.next(); + continue + }, + '\n' => { + me.chars.next(); + break + }, + _ => return Err(Error::InvalidEscape(i, c)), + } + } + } while let Some((_, ch)) = me.chars.clone().next() { match ch { ' ' | '\t' | '\n' => { -- cgit v1.2.3