diff --git a/src/parse/mod.rs b/src/parse/mod.rs index f09eaac..cabb393 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -589,7 +589,8 @@ impl<'a> Parser<'a> { self.toks.next(); while let Some(tok) = self.toks.next() { if tok.kind == '*' { - if let Some(Token { kind: '/', .. }) = self.toks.next() { + if let Some(Token { kind: '/', .. }) = self.toks.peek() { + self.toks.next(); break; } } diff --git a/src/parse/value/parse.rs b/src/parse/value/parse.rs index 407be00..9c1f745 100644 --- a/src/parse/value/parse.rs +++ b/src/parse/value/parse.rs @@ -578,10 +578,12 @@ impl<'a> Parser<'a> { } let mut map = SassMap::new(); - let key = self.parse_value( - true, - &|c| matches!(c.peek(), Some(Token { kind: ':', .. }) | Some(Token { kind: ')', .. })), - )?; + let key = self.parse_value(true, &|c| { + matches!( + c.peek(), + Some(Token { kind: ':', .. }) | Some(Token { kind: ')', .. }) + ) + })?; match self.toks.next() { Some(Token { kind: ':', .. }) => {} @@ -594,10 +596,12 @@ impl<'a> Parser<'a> { Some(..) | None => return Err(("expected \")\".", key.span).into()), } - let val = self.parse_value( - true, - &|c| matches!(c.peek(), Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. })), - )?; + let val = self.parse_value(true, &|c| { + matches!( + c.peek(), + Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. }) + ) + })?; map.insert(key.node, val.node); @@ -630,14 +634,22 @@ impl<'a> Parser<'a> { } loop { - let key = - self.parse_value(true, &|c| matches!(c.peek(), Some(Token { kind: ':', .. }) | Some(Token { kind: ',', .. })))?; + let key = self.parse_value(true, &|c| { + matches!( + c.peek(), + Some(Token { kind: ':', .. }) | Some(Token { kind: ',', .. }) + ) + })?; self.expect_char(':')?; self.whitespace_or_comment(); - let val = - self.parse_value(true, &|c| matches!(c.peek(), Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. })))?; + let val = self.parse_value(true, &|c| { + matches!( + c.peek(), + Some(Token { kind: ',', .. }) | Some(Token { kind: ')', .. }) + ) + })?; span = span.merge(val.span); diff --git a/tests/comments.rs b/tests/comments.rs index e890148..275e165 100644 --- a/tests/comments.rs +++ b/tests/comments.rs @@ -66,3 +66,16 @@ test!( "$a: foo;/* interpolation #{1 + 1} in #{$a} comments */", "/* interpolation 2 in foo comments */\n" ); +test!( + triple_star_in_selector, + "a/***/ {x: y} b { color: red; }", + "a {\n x: y;\n}\n\nb {\n color: red;\n}\n" +); +test!( + sass_spec__css_comments_multiple_stars, + "a /***/ b {x: y} + a /****/ b {x: y} + a /* **/ b {x: y} + a /** */ b {x: y}", + "a b {\n x: y;\n}\n\na b {\n x: y;\n}\n\na b {\n x: y;\n}\n\na b {\n x: y;\n}\n" +);