don't read multiple stars in comment eagerly
This commit is contained in:
parent
d1be778682
commit
e5d73ac265
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user