From 136ad3b0d17b4a94f158ed39e14666389d7f4abd Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Thu, 27 Oct 2022 21:40:07 +0300 Subject: [PATCH 01/12] refactor(css/parser): refactor --- .../swc_css_parser/src/parser/syntax/mod.rs | 151 +---- .../src/parser/values_and_units/mod.rs | 114 +++- .../recovery/at-rule/document/output.json | 50 +- .../at-rule/document/output.swc-stderr | 2 +- .../recovery/at-rule/document/span.rust-debug | 34 +- .../recovery/delim-token/minus/output.json | 24 +- .../delim-token/minus/span.rust-debug | 14 +- .../recovery/delim-token/plus/output.json | 24 +- .../recovery/delim-token/plus/span.rust-debug | 14 +- .../tests/recovery/function/base/output.json | 57 +- .../recovery/function/base/span.rust-debug | 30 +- .../tests/recovery/function/rgb/output.json | 579 +++++++++++++++--- .../recovery/function/rgb/span.rust-debug | 302 +++++++-- .../recovery/function/unclosed-2/output.json | 13 - .../function/unclosed-2/span.rust-debug | 13 - .../recovery/function/unclosed/output.json | 49 +- .../function/unclosed/output.swc-stderr | 4 +- .../function/unclosed/span.rust-debug | 50 +- .../tests/recovery/ie-progid/output.json | 33 +- .../recovery/ie-progid/output.swc-stderr | 12 + .../tests/recovery/ie-progid/span.rust-debug | 6 +- .../recovery/vercel/002/output.swc-stderr | 6 +- 22 files changed, 1023 insertions(+), 558 deletions(-) diff --git a/crates/swc_css_parser/src/parser/syntax/mod.rs b/crates/swc_css_parser/src/parser/syntax/mod.rs index 69d95223c11e..2baf87d83eeb 100644 --- a/crates/swc_css_parser/src/parser/syntax/mod.rs +++ b/crates/swc_css_parser/src/parser/syntax/mod.rs @@ -15,6 +15,9 @@ where { fn parse(&mut self) -> PResult { let start = self.input.cur_span(); + + // Consume a list of rules from input, with the top-level flag set, and set the + // stylesheet’s value to the result. let rules = self .with_ctx(Ctx { is_top_level: true, @@ -23,6 +26,7 @@ where .parse_as::>()?; let last = self.input.last_pos(); + // Return the stylesheet. Ok(Stylesheet { span: Span::new(start.lo, last, Default::default()), rules, @@ -35,6 +39,8 @@ where I: ParserInput, { fn parse(&mut self) -> PResult> { + // To consume a list of rules, given a top-level flag: + // Create an initially empty list of rules. let mut rules = vec![]; @@ -122,6 +128,8 @@ where I: ParserInput, { fn parse(&mut self) -> PResult { + // To consume an at-rule: + // Consume the next input token. Create a new at-rule with its name set to the // value of the current input token, its prelude initially set to an empty list, // and its value initially set to nothing. @@ -314,6 +322,7 @@ where I: ParserInput, { fn parse(&mut self) -> PResult { + // To consume a qualified rule: let create_prelude = |p: &mut Parser, list: Vec| -> PResult { let list_of_component_values = p.create_locv(list); @@ -817,7 +826,7 @@ where block_contents_grammar: BlockContentsGrammar::DeclarationValue, ..self.ctx }; - let parsed = self.with_ctx(ctx).parse_as::(); + let parsed = self.with_ctx(ctx).parse_generic_value(); let value_or_token = match parsed { Ok(value) => value, Err(err) => { @@ -918,137 +927,27 @@ where I: ParserInput, { fn parse(&mut self) -> PResult { - match self.ctx.block_contents_grammar { - BlockContentsGrammar::NoGrammar => { - // Consume the next input token. - match cur!(self) { - // If the current input token is a <{-token>, <[-token>, or <(-token>, consume a - // simple block and return it. - tok!("[") | tok!("(") | tok!("{") => { - let block = self.parse()?; - - Ok(ComponentValue::SimpleBlock(block)) - } - // Otherwise, if the current input token is a , consume a - // function and return it. - tok!("function") => Ok(ComponentValue::Function(self.parse()?)), - // Otherwise, return the current input token. - _ => { - let token = self.input.bump(); + match cur!(self) { + // If the current input token is a <{-token>, <[-token>, or <(-token>, consume a + // simple block and return it. + tok!("[") | tok!("(") | tok!("{") => { + let block = self.parse()?; - match token { - Some(t) => Ok(ComponentValue::PreservedToken(t)), - _ => { - unreachable!(); - } - } - } - } + Ok(ComponentValue::SimpleBlock(block)) } + // Otherwise, if the current input token is a , consume a + // function and return it. + tok!("function") => Ok(ComponentValue::Function(self.parse()?)), + // Otherwise, return the current input token. _ => { - // TODO refactor me - self.input.skip_ws(); - - let span = self.input.cur_span(); - - match cur!(self) { - tok!(",") | tok!("/") | tok!(";") => { - return Ok(ComponentValue::Delimiter(self.parse()?)); - } - - tok!("string") => { - return Ok(ComponentValue::Str(self.parse()?)); - } + let token = self.input.bump(); - tok!("url") => { - return Ok(ComponentValue::Url(self.parse()?)); - } - - Token::Function { value, .. } => match &*value.to_ascii_lowercase() { - "url" | "src" => { - return Ok(ComponentValue::Url(self.parse()?)); - } - "rgb" | "rgba" | "hsl" | "hsla" | "hwb" | "lab" | "lch" | "oklab" - | "oklch" | "color" | "device-cmyk" | "color-mix" | "color-contrast" => { - return Ok(ComponentValue::Color(self.parse()?)); - } - _ => { - return Ok(ComponentValue::Function(self.parse()?)); - } - }, - - tok!("percentage") => { - return Ok(ComponentValue::Percentage(self.parse()?)); - } - - tok!("dimension") => return Ok(ComponentValue::Dimension(self.parse()?)), - - Token::Number { type_flag, .. } => { - if *type_flag == NumberType::Integer { - return Ok(ComponentValue::Integer(self.parse()?)); - } - - return Ok(ComponentValue::Number(self.parse()?)); - } - - Token::Ident { value, .. } => { - if value.starts_with("--") { - return Ok(ComponentValue::DashedIdent(self.parse()?)); - } else if &*value.to_ascii_lowercase() == "u" - && peeked_is_one_of!(self, "+", "number", "dimension") - { - return Ok(ComponentValue::UnicodeRange(self.parse()?)); - } - - return Ok(ComponentValue::Ident(self.parse()?)); - } - - tok!("[") | tok!("(") | tok!("{") => { - let ctx = Ctx { - block_contents_grammar: BlockContentsGrammar::NoGrammar, - ..self.ctx - }; - let mut block = self.with_ctx(ctx).parse_as::()?; - let locv = self.create_locv(block.value); - - block.value = match self.parse_according_to_grammar(&locv, |parser| { - let mut values = vec![]; - - loop { - parser.input.skip_ws(); - - if is!(parser, EOF) { - break; - } - - let component_value = parser.parse()?; - - values.push(component_value); - } - - Ok(values) - }) { - Ok(values) => values, - Err(err) => { - if *err.kind() != ErrorKind::Ignore { - self.errors.push(err); - } - - locv.children - } - }; - - return Ok(ComponentValue::SimpleBlock(block)); - } - - tok!("#") => { - return Ok(ComponentValue::Color(self.parse()?)); + match token { + Some(t) => Ok(ComponentValue::PreservedToken(t)), + _ => { + unreachable!(); } - - _ => {} } - - Err(Error::new(span, ErrorKind::Expected("Declaration value"))) } } } diff --git a/crates/swc_css_parser/src/parser/values_and_units/mod.rs b/crates/swc_css_parser/src/parser/values_and_units/mod.rs index 476b764d2a43..cdf1adc805b8 100644 --- a/crates/swc_css_parser/src/parser/values_and_units/mod.rs +++ b/crates/swc_css_parser/src/parser/values_and_units/mod.rs @@ -11,6 +11,111 @@ impl Parser where I: ParserInput, { + pub(super) fn parse_generic_value(&mut self) -> PResult { + self.input.skip_ws(); + + let span = self.input.cur_span(); + + match cur!(self) { + tok!(",") | tok!("/") | tok!(";") => { + return Ok(ComponentValue::Delimiter(self.parse()?)); + } + + tok!("string") => { + return Ok(ComponentValue::Str(self.parse()?)); + } + + tok!("url") => { + return Ok(ComponentValue::Url(self.parse()?)); + } + + Token::Function { value, .. } => match &*value.to_ascii_lowercase() { + "url" | "src" => { + return Ok(ComponentValue::Url(self.parse()?)); + } + "rgb" | "rgba" | "hsl" | "hsla" | "hwb" | "lab" | "lch" | "oklab" | "oklch" + | "color" | "device-cmyk" | "color-mix" | "color-contrast" => { + return Ok(ComponentValue::Color(self.parse()?)); + } + _ => { + return Ok(ComponentValue::Function(self.parse()?)); + } + }, + + tok!("percentage") => { + return Ok(ComponentValue::Percentage(self.parse()?)); + } + + tok!("dimension") => return Ok(ComponentValue::Dimension(self.parse()?)), + + Token::Number { type_flag, .. } => { + if *type_flag == NumberType::Integer { + return Ok(ComponentValue::Integer(self.parse()?)); + } + + return Ok(ComponentValue::Number(self.parse()?)); + } + + Token::Ident { value, .. } => { + if value.starts_with("--") { + return Ok(ComponentValue::DashedIdent(self.parse()?)); + } else if &*value.to_ascii_lowercase() == "u" + && peeked_is_one_of!(self, "+", "number", "dimension") + { + return Ok(ComponentValue::UnicodeRange(self.parse()?)); + } + + return Ok(ComponentValue::Ident(self.parse()?)); + } + + tok!("[") | tok!("(") | tok!("{") => { + let ctx = Ctx { + block_contents_grammar: BlockContentsGrammar::NoGrammar, + ..self.ctx + }; + let mut block = self.with_ctx(ctx).parse_as::()?; + let locv = self.create_locv(block.value); + + block.value = match self.parse_according_to_grammar(&locv, |parser| { + let mut values = vec![]; + + loop { + parser.input.skip_ws(); + + if is!(parser, EOF) { + break; + } + + let component_value = parser.parse_generic_value()?; + + values.push(component_value); + } + + Ok(values) + }) { + Ok(values) => values, + Err(err) => { + if *err.kind() != ErrorKind::Ignore { + self.errors.push(err); + } + + locv.children + } + }; + + return Ok(ComponentValue::SimpleBlock(block)); + } + + tok!("#") => { + return Ok(ComponentValue::Color(self.parse()?)); + } + + _ => {} + } + + Err(Error::new(span, ErrorKind::Expected("Declaration value"))) + } + /// Parse value as . pub(super) fn parse_declaration_value(&mut self) -> PResult> { let mut value = vec![]; @@ -1542,14 +1647,7 @@ where break; } - let value = match self.try_parse(|p| { - let ctx = Ctx { - block_contents_grammar: BlockContentsGrammar::DeclarationValue, - ..p.ctx - }; - - p.with_ctx(ctx).parse_as::() - }) { + let value = match self.try_parse(|p| p.parse_generic_value()) { Some(v) => v, None => { if is_one_of!(self, ";", ":") { diff --git a/crates/swc_css_parser/tests/recovery/at-rule/document/output.json b/crates/swc_css_parser/tests/recovery/at-rule/document/output.json index b3e5f27f4cac..e7c24437bc44 100644 --- a/crates/swc_css_parser/tests/recovery/at-rule/document/output.json +++ b/crates/swc_css_parser/tests/recovery/at-rule/document/output.json @@ -24,26 +24,13 @@ "raw": "document" }, "prelude": { - "type": "ListOfComponentValues", + "type": "DocumentPrelude", "span": { - "start": 10, + "start": 11, "end": 43, "ctxt": 0 }, - "children": [ - { - "type": "PreservedToken", - "span": { - "start": 10, - "end": 11, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, + "matchingFunctions": [ { "type": "Function", "span": { @@ -166,46 +153,25 @@ } }, { - "type": "PreservedToken", + "type": "Ident", "span": { "start": 37, "end": 40, "ctxt": 0 }, - "token": { - "Ident": { - "value": "com", - "raw": "com" - } - } + "value": "com", + "raw": "com" }, { - "type": "PreservedToken", + "type": "Delimiter", "span": { "start": 40, "end": 41, "ctxt": 0 }, - "token": { - "Delim": { - "value": "/" - } - } + "value": "/" } ] - }, - { - "type": "PreservedToken", - "span": { - "start": 42, - "end": 43, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } } ] }, diff --git a/crates/swc_css_parser/tests/recovery/at-rule/document/output.swc-stderr b/crates/swc_css_parser/tests/recovery/at-rule/document/output.swc-stderr index 673df98cff9d..4d2d1000f996 100644 --- a/crates/swc_css_parser/tests/recovery/at-rule/document/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/at-rule/document/output.swc-stderr @@ -8,5 +8,5 @@ x Expected Declaration value ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] 1 | @document domain(http://www.example.com/) {} - : ^ + : ^ `---- diff --git a/crates/swc_css_parser/tests/recovery/at-rule/document/span.rust-debug b/crates/swc_css_parser/tests/recovery/at-rule/document/span.rust-debug index f3726ff47ddc..dd44e201a35a 100644 --- a/crates/swc_css_parser/tests/recovery/at-rule/document/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/at-rule/document/span.rust-debug @@ -29,24 +29,6 @@ : ^^^^^^^^ `---- - x ComponentValue - ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] - 1 | @document domain(http://www.example.com/) {} - : ^ - `---- - - x WhiteSpace { value: Atom(' ' type=inline) } - ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] - 1 | @document domain(http://www.example.com/) {} - : ^ - `---- - - x ComponentValue - ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] - 1 | @document domain(http://www.example.com/) {} - : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - `---- - x Function ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] 1 | @document domain(http://www.example.com/) {} @@ -161,7 +143,7 @@ : ^^^ `---- - x Ident { value: Atom('com' type=inline), raw: Atom('com' type=inline) } + x Ident ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] 1 | @document domain(http://www.example.com/) {} : ^^^ @@ -173,24 +155,12 @@ : ^ `---- - x Delim { value: '/' } + x Delimiter ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] 1 | @document domain(http://www.example.com/) {} : ^ `---- - x ComponentValue - ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] - 1 | @document domain(http://www.example.com/) {} - : ^ - `---- - - x WhiteSpace { value: Atom(' ' type=inline) } - ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] - 1 | @document domain(http://www.example.com/) {} - : ^ - `---- - x SimpleBlock ,-[$DIR/tests/recovery/at-rule/document/input.css:1:1] 1 | @document domain(http://www.example.com/) {} diff --git a/crates/swc_css_parser/tests/recovery/delim-token/minus/output.json b/crates/swc_css_parser/tests/recovery/delim-token/minus/output.json index 30ce3802d29a..a7d319cef2df 100644 --- a/crates/swc_css_parser/tests/recovery/delim-token/minus/output.json +++ b/crates/swc_css_parser/tests/recovery/delim-token/minus/output.json @@ -253,32 +253,14 @@ } }, { - "type": "PreservedToken", - "span": { - "start": 55, - "end": 56, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", + "type": "Integer", "span": { "start": 56, "end": 57, "ctxt": 0 }, - "token": { - "Number": { - "value": 2.0, - "raw": "2", - "type": "integer" - } - } + "value": 2, + "raw": "2" } ] } diff --git a/crates/swc_css_parser/tests/recovery/delim-token/minus/span.rust-debug b/crates/swc_css_parser/tests/recovery/delim-token/minus/span.rust-debug index c516a96116fe..14742aa8959d 100644 --- a/crates/swc_css_parser/tests/recovery/delim-token/minus/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/delim-token/minus/span.rust-debug @@ -275,25 +275,13 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/recovery/delim-token/minus/input.css:4:5] - 4 | prop2: func(1 - 2); - : ^ - `---- - - x WhiteSpace { value: Atom(' ' type=inline) } - ,-[$DIR/tests/recovery/delim-token/minus/input.css:4:5] - 4 | prop2: func(1 - 2); - : ^ - `---- - x ComponentValue ,-[$DIR/tests/recovery/delim-token/minus/input.css:4:5] 4 | prop2: func(1 - 2); : ^ `---- - x Number { value: 2.0, raw: Atom('2' type=inline), type_flag: Integer } + x Integer ,-[$DIR/tests/recovery/delim-token/minus/input.css:4:5] 4 | prop2: func(1 - 2); : ^ diff --git a/crates/swc_css_parser/tests/recovery/delim-token/plus/output.json b/crates/swc_css_parser/tests/recovery/delim-token/plus/output.json index cd924500340d..be16df387031 100644 --- a/crates/swc_css_parser/tests/recovery/delim-token/plus/output.json +++ b/crates/swc_css_parser/tests/recovery/delim-token/plus/output.json @@ -253,32 +253,14 @@ } }, { - "type": "PreservedToken", - "span": { - "start": 55, - "end": 56, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", + "type": "Integer", "span": { "start": 56, "end": 57, "ctxt": 0 }, - "token": { - "Number": { - "value": 2.0, - "raw": "2", - "type": "integer" - } - } + "value": 2, + "raw": "2" } ] } diff --git a/crates/swc_css_parser/tests/recovery/delim-token/plus/span.rust-debug b/crates/swc_css_parser/tests/recovery/delim-token/plus/span.rust-debug index 50ebd5175322..b01c53b5c901 100644 --- a/crates/swc_css_parser/tests/recovery/delim-token/plus/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/delim-token/plus/span.rust-debug @@ -275,25 +275,13 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/recovery/delim-token/plus/input.css:4:5] - 4 | prop2: func(1 + 2); - : ^ - `---- - - x WhiteSpace { value: Atom(' ' type=inline) } - ,-[$DIR/tests/recovery/delim-token/plus/input.css:4:5] - 4 | prop2: func(1 + 2); - : ^ - `---- - x ComponentValue ,-[$DIR/tests/recovery/delim-token/plus/input.css:4:5] 4 | prop2: func(1 + 2); : ^ `---- - x Number { value: 2.0, raw: Atom('2' type=inline), type_flag: Integer } + x Integer ,-[$DIR/tests/recovery/delim-token/plus/input.css:4:5] 4 | prop2: func(1 + 2); : ^ diff --git a/crates/swc_css_parser/tests/recovery/function/base/output.json b/crates/swc_css_parser/tests/recovery/function/base/output.json index 5ebbc9c121cc..7ea65b94e972 100644 --- a/crates/swc_css_parser/tests/recovery/function/base/output.json +++ b/crates/swc_css_parser/tests/recovery/function/base/output.json @@ -165,32 +165,14 @@ } }, { - "type": "PreservedToken", - "span": { - "start": 25, - "end": 26, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", + "type": "Integer", "span": { "start": 26, "end": 27, "ctxt": 0 }, - "token": { - "Number": { - "value": 2.0, - "raw": "2", - "type": "integer" - } - } + "value": 2, + "raw": "2" } ] } @@ -261,18 +243,14 @@ } }, { - "type": "PreservedToken", + "type": "Ident", "span": { "start": 51, "end": 56, "ctxt": 0 }, - "token": { - "Ident": { - "value": "ident", - "raw": "ident" - } - } + "value": "ident", + "raw": "ident" } ] } @@ -356,31 +334,14 @@ } }, { - "type": "PreservedToken", + "type": "Ident", "span": { "start": 84, "end": 89, "ctxt": 0 }, - "token": { - "Ident": { - "value": "ident", - "raw": "ident" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 89, - "end": 92, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } + "value": "ident", + "raw": "ident" } ] } diff --git a/crates/swc_css_parser/tests/recovery/function/base/span.rust-debug b/crates/swc_css_parser/tests/recovery/function/base/span.rust-debug index 38d2d2ee19c6..c6245708a45a 100644 --- a/crates/swc_css_parser/tests/recovery/function/base/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/function/base/span.rust-debug @@ -183,25 +183,13 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/recovery/function/base/input.css:2:5] - 2 | prop: func(1 + 2); - : ^ - `---- - - x WhiteSpace { value: Atom(' ' type=inline) } - ,-[$DIR/tests/recovery/function/base/input.css:2:5] - 2 | prop: func(1 + 2); - : ^ - `---- - x ComponentValue ,-[$DIR/tests/recovery/function/base/input.css:2:5] 2 | prop: func(1 + 2); : ^ `---- - x Number { value: 2.0, raw: Atom('2' type=inline), type_flag: Integer } + x Integer ,-[$DIR/tests/recovery/function/base/input.css:2:5] 2 | prop: func(1 + 2); : ^ @@ -285,7 +273,7 @@ : ^^^^^ `---- - x Ident { value: Atom('ident' type=inline), raw: Atom('ident' type=inline) } + x Ident ,-[$DIR/tests/recovery/function/base/input.css:3:5] 3 | prop: func(ident.ident); : ^^^^^ @@ -381,24 +369,12 @@ : ^^^^^ `---- - x Ident { value: Atom('ident' type=inline), raw: Atom('ident' type=inline) } + x Ident ,-[$DIR/tests/recovery/function/base/input.css:4:5] 4 | prop: func3( ident.ident ); : ^^^^^ `---- - x ComponentValue - ,-[$DIR/tests/recovery/function/base/input.css:4:5] - 4 | prop: func3( ident.ident ); - : ^^^ - `---- - - x WhiteSpace { value: Atom(' ' type=inline) } - ,-[$DIR/tests/recovery/function/base/input.css:4:5] - 4 | prop: func3( ident.ident ); - : ^^^ - `---- - x ComponentValue ,-[$DIR/tests/recovery/function/base/input.css:5:5] 5 | prop: func([foo bar]); diff --git a/crates/swc_css_parser/tests/recovery/function/rgb/output.json b/crates/swc_css_parser/tests/recovery/function/rgb/output.json index 71d1bfa63e3f..913de2c6ba6a 100644 --- a/crates/swc_css_parser/tests/recovery/function/rgb/output.json +++ b/crates/swc_css_parser/tests/recovery/function/rgb/output.json @@ -117,14 +117,18 @@ }, "value": [ { - "type": "String", + "type": "PreservedToken", "span": { "start": 23, "end": 29, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } } ] } @@ -168,52 +172,92 @@ }, "value": [ { - "type": "String", + "type": "PreservedToken", "span": { "start": 48, "end": 54, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 54, "end": 55, "ctxt": 0 }, - "value": "," + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 55, + "end": 56, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 56, "end": 59, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 59, "end": 60, "ctxt": 0 }, - "value": "," + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 60, + "end": 61, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 61, "end": 64, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } } ] } @@ -257,52 +301,92 @@ }, "value": [ { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 82, "end": 85, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 85, "end": 86, "ctxt": 0 }, - "value": "," + "token": "Comma" }, { - "type": "String", + "type": "PreservedToken", + "span": { + "start": 86, + "end": 87, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", "span": { "start": 87, "end": 93, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 93, "end": 94, "ctxt": 0 }, - "value": "," + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 94, + "end": 95, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 95, "end": 98, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } } ] } @@ -346,52 +430,92 @@ }, "value": [ { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 116, "end": 119, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 119, "end": 120, "ctxt": 0 }, - "value": "," + "token": "Comma" }, { - "type": "Integer", + "type": "PreservedToken", + "span": { + "start": 120, + "end": 121, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", "span": { "start": 121, "end": 124, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 124, "end": 125, "ctxt": 0 }, - "value": "," + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 125, + "end": 126, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "String", + "type": "PreservedToken", "span": { "start": 126, "end": 132, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } } ] } @@ -435,71 +559,129 @@ }, "value": [ { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 150, "end": 153, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 153, "end": 154, "ctxt": 0 }, - "value": "," + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 154, + "end": 155, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 155, "end": 158, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 158, "end": 159, "ctxt": 0 }, - "value": "," + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 159, + "end": 160, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 160, "end": 163, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 163, "end": 164, "ctxt": 0 }, - "value": "," + "token": "Comma" }, { - "type": "String", + "type": "PreservedToken", + "span": { + "start": 164, + "end": 165, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", "span": { "start": 165, "end": 171, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } } ] } @@ -543,34 +725,74 @@ }, "value": [ { - "type": "String", + "type": "PreservedToken", "span": { "start": 190, "end": 196, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } }, { - "type": "Integer", + "type": "PreservedToken", + "span": { + "start": 196, + "end": 197, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", "span": { "start": 197, "end": 200, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 200, + "end": 201, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 201, "end": 204, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } } ] } @@ -614,34 +836,74 @@ }, "value": [ { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 222, "end": 225, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "String", + "type": "PreservedToken", + "span": { + "start": 225, + "end": 226, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", "span": { "start": 226, "end": 232, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 232, + "end": 233, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 233, "end": 236, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } } ] } @@ -685,34 +947,74 @@ }, "value": [ { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 254, "end": 257, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Integer", + "type": "PreservedToken", + "span": { + "start": 257, + "end": 258, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", "span": { "start": 258, "end": 261, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 261, + "end": 262, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "String", + "type": "PreservedToken", "span": { "start": 262, "end": 268, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } } ] } @@ -756,53 +1058,128 @@ }, "value": [ { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 286, "end": 289, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 289, + "end": 290, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Integer", + "type": "PreservedToken", "span": { "start": 290, "end": 293, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } }, { - "type": "Integer", + "type": "PreservedToken", + "span": { + "start": 293, + "end": 294, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", "span": { "start": 294, "end": 297, "ctxt": 0 }, - "value": 100, - "raw": "100" + "token": { + "Number": { + "value": 100.0, + "raw": "100", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 297, + "end": 298, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } }, { - "type": "Delimiter", + "type": "PreservedToken", "span": { "start": 298, "end": 299, "ctxt": 0 }, - "value": "/" + "token": { + "Delim": { + "value": "/" + } + } }, { - "type": "String", + "type": "PreservedToken", + "span": { + "start": 299, + "end": 300, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", "span": { "start": 300, "end": 306, "ctxt": 0 }, - "value": "test", - "raw": "\"test\"" + "token": { + "String": { + "value": "test", + "raw": "\"test\"" + } + } } ] } diff --git a/crates/swc_css_parser/tests/recovery/function/rgb/span.rust-debug b/crates/swc_css_parser/tests/recovery/function/rgb/span.rust-debug index c65caba51cdd..f4a677e9281c 100644 --- a/crates/swc_css_parser/tests/recovery/function/rgb/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/function/rgb/span.rust-debug @@ -181,7 +181,7 @@ : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:2:5] 2 | color: rgb("test"); : ^^^^^^ @@ -247,7 +247,7 @@ : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] 4 | color: rgb("test", 100, 100); : ^^^^^^ @@ -259,19 +259,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] 4 | color: rgb("test", 100, 100); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] + 4 | color: rgb("test", 100, 100); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] + 4 | color: rgb("test", 100, 100); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] 4 | color: rgb("test", 100, 100); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] 4 | color: rgb("test", 100, 100); : ^^^ @@ -283,19 +295,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] 4 | color: rgb("test", 100, 100); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] + 4 | color: rgb("test", 100, 100); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] + 4 | color: rgb("test", 100, 100); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] 4 | color: rgb("test", 100, 100); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:4:5] 4 | color: rgb("test", 100, 100); : ^^^ @@ -361,7 +385,7 @@ : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] 5 | color: rgb(100, "test", 100); : ^^^ @@ -373,19 +397,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] 5 | color: rgb(100, "test", 100); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] + 5 | color: rgb(100, "test", 100); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] + 5 | color: rgb(100, "test", 100); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] 5 | color: rgb(100, "test", 100); : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] 5 | color: rgb(100, "test", 100); : ^^^^^^ @@ -397,19 +433,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] 5 | color: rgb(100, "test", 100); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] + 5 | color: rgb(100, "test", 100); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] + 5 | color: rgb(100, "test", 100); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] 5 | color: rgb(100, "test", 100); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:5:5] 5 | color: rgb(100, "test", 100); : ^^^ @@ -475,7 +523,7 @@ : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] 6 | color: rgb(100, 100, "test"); : ^^^ @@ -487,19 +535,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] 6 | color: rgb(100, 100, "test"); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] + 6 | color: rgb(100, 100, "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] + 6 | color: rgb(100, 100, "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] 6 | color: rgb(100, 100, "test"); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] 6 | color: rgb(100, 100, "test"); : ^^^ @@ -511,19 +571,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] 6 | color: rgb(100, 100, "test"); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] + 6 | color: rgb(100, 100, "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] + 6 | color: rgb(100, 100, "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] 6 | color: rgb(100, 100, "test"); : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:6:5] 6 | color: rgb(100, 100, "test"); : ^^^^^^ @@ -589,7 +661,7 @@ : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^^^ @@ -601,19 +673,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] + 7 | color: rgb(100, 100, 100, "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] + 7 | color: rgb(100, 100, 100, "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^^^ @@ -625,19 +709,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] + 7 | color: rgb(100, 100, 100, "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] + 7 | color: rgb(100, 100, 100, "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^^^ @@ -649,19 +745,31 @@ : ^ `---- - x Delimiter + x Comma ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] + 7 | color: rgb(100, 100, 100, "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] + 7 | color: rgb(100, 100, 100, "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:7:5] 7 | color: rgb(100, 100, 100, "test"); : ^^^^^^ @@ -727,31 +835,55 @@ : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] 9 | color: rgb("test" 100 100); : ^^^^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] + 9 | color: rgb("test" 100 100); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] + 9 | color: rgb("test" 100 100); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] 9 | color: rgb("test" 100 100); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] 9 | color: rgb("test" 100 100); : ^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] + 9 | color: rgb("test" 100 100); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] + 9 | color: rgb("test" 100 100); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] 9 | color: rgb("test" 100 100); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:9:5] 9 | color: rgb("test" 100 100); : ^^^ @@ -817,31 +949,55 @@ : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] 10 | color: rgb(100 "test" 100); : ^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] + 10 | color: rgb(100 "test" 100); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] + 10 | color: rgb(100 "test" 100); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] 10 | color: rgb(100 "test" 100); : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] 10 | color: rgb(100 "test" 100); : ^^^^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] + 10 | color: rgb(100 "test" 100); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] + 10 | color: rgb(100 "test" 100); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] 10 | color: rgb(100 "test" 100); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:10:5] 10 | color: rgb(100 "test" 100); : ^^^ @@ -907,31 +1063,55 @@ : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] 11 | color: rgb(100 100 "test"); : ^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] + 11 | color: rgb(100 100 "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] + 11 | color: rgb(100 100 "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] 11 | color: rgb(100 100 "test"); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] 11 | color: rgb(100 100 "test"); : ^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] + 11 | color: rgb(100 100 "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] + 11 | color: rgb(100 100 "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] 11 | color: rgb(100 100 "test"); : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:11:5] 11 | color: rgb(100 100 "test"); : ^^^^^^ @@ -997,55 +1177,103 @@ : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] + 12 | color: rgb(100 100 100 / "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] + 12 | color: rgb(100 100 100 / "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] + 12 | color: rgb(100 100 100 / "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] + 12 | color: rgb(100 100 100 / "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^^^ `---- - x Integer + x Number { value: 100.0, raw: Atom('100' type=inline), type_flag: Integer } ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^^^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] + 12 | color: rgb(100 100 100 / "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] + 12 | color: rgb(100 100 100 / "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^ `---- - x Delimiter + x Delim { value: '/' } ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^ `---- + x ComponentValue + ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] + 12 | color: rgb(100 100 100 / "test"); + : ^ + `---- + + x WhiteSpace { value: Atom(' ' type=inline) } + ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] + 12 | color: rgb(100 100 100 / "test"); + : ^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^^^^^^ `---- - x Str + x String { value: Atom('test' type=inline), raw: Atom('"test"' type=inline) } ,-[$DIR/tests/recovery/function/rgb/input.css:12:5] 12 | color: rgb(100 100 100 / "test"); : ^^^^^^ diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.json b/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.json index d2a125ca7487..2e07251d3834 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.json +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.json @@ -237,19 +237,6 @@ "ctxt": 0 }, "token": "RBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 62, - "end": 63, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n" - } - } } ] } diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-2/span.rust-debug b/crates/swc_css_parser/tests/recovery/function/unclosed-2/span.rust-debug index 4f19225f7e75..beb9bb5b605a 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed-2/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-2/span.rust-debug @@ -233,16 +233,3 @@ 3 | } : ^ `---- - - x ComponentValue - ,-[$DIR/tests/recovery/function/unclosed-2/input.css:3:1] - 3 | } - : ^ - `---- - - x WhiteSpace { value: Atom(' - | ' type=inline) } - ,-[$DIR/tests/recovery/function/unclosed-2/input.css:3:1] - 3 | } - : ^ - `---- diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed/output.json b/crates/swc_css_parser/tests/recovery/function/unclosed/output.json index de11c9f5373c..56795d8ec98b 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed/output.json +++ b/crates/swc_css_parser/tests/recovery/function/unclosed/output.json @@ -117,21 +117,52 @@ }, "value": [ { - "type": "PreservedToken", + "type": "CalcSum", "span": { "start": 22, "end": 27, "ctxt": 0 }, - "token": { - "Dimension": { - "value": 500.0, - "raw_value": "500", - "unit": "px", - "raw_unit": "px", - "type": "integer" + "expressions": [ + { + "type": "CalcProduct", + "span": { + "start": 22, + "end": 27, + "ctxt": 0 + }, + "expressions": [ + { + "type": "Length", + "span": { + "start": 22, + "end": 27, + "ctxt": 0 + }, + "value": { + "type": "Number", + "span": { + "start": 22, + "end": 25, + "ctxt": 0 + }, + "value": 500.0, + "raw": "500" + }, + "unit": { + "type": "Ident", + "span": { + "start": 25, + "end": 27, + "ctxt": 0 + }, + "value": "px", + "raw": "px" + } + } + ] } - } + ] }, { "type": "PreservedToken", diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr b/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr index 4853ae4a94f9..63d540fd9c6f 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr @@ -11,10 +11,10 @@ : ^ `---- - x Expected Declaration value + x Expected 'number', 'dimension', 'percentage', 'ident', '(' or 'function' tokens ,-[$DIR/tests/recovery/function/unclosed/input.css:3:1] 3 | } - : ^ + : ^ `---- x Unexpected end of file diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed/span.rust-debug b/crates/swc_css_parser/tests/recovery/function/unclosed/span.rust-debug index b1f9ad5f5906..1dd3811b90ad 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/function/unclosed/span.rust-debug @@ -123,12 +123,60 @@ : ^^^^^ `---- - x Dimension { value: 500.0, raw_value: Atom('500' type=inline), unit: Atom('px' type=static), raw_unit: Atom('px' type=static), type_flag: Integer } + x CalcSum ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] 2 | width: min(500px; : ^^^^^ `---- + x CalcProductOrOperator + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | width: min(500px; + : ^^^^^ + `---- + + x CalcProduct + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | width: min(500px; + : ^^^^^ + `---- + + x CalcValueOrOperator + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | width: min(500px; + : ^^^^^ + `---- + + x CalcValue + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | width: min(500px; + : ^^^^^ + `---- + + x Dimension + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | width: min(500px; + : ^^^^^ + `---- + + x Length + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | width: min(500px; + : ^^^^^ + `---- + + x Number + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | width: min(500px; + : ^^^ + `---- + + x Ident + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | width: min(500px; + : ^^ + `---- + x ComponentValue ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] 2 | width: min(500px; diff --git a/crates/swc_css_parser/tests/recovery/ie-progid/output.json b/crates/swc_css_parser/tests/recovery/ie-progid/output.json index 536a56e46a5e..11c844492c51 100644 --- a/crates/swc_css_parser/tests/recovery/ie-progid/output.json +++ b/crates/swc_css_parser/tests/recovery/ie-progid/output.json @@ -316,19 +316,14 @@ } }, { - "type": "PreservedToken", + "type": "Integer", "span": { "start": 118, "end": 119, "ctxt": 0 }, - "token": { - "Number": { - "value": 0.0, - "raw": "0", - "type": "integer" - } - } + "value": 0, + "raw": "0" } ] } @@ -464,19 +459,14 @@ } }, { - "type": "PreservedToken", + "type": "Integer", "span": { "start": 185, "end": 186, "ctxt": 0 }, - "token": { - "Number": { - "value": 2.0, - "raw": "2", - "type": "integer" - } - } + "value": 2, + "raw": "2" } ] }, @@ -591,19 +581,14 @@ } }, { - "type": "PreservedToken", + "type": "Integer", "span": { "start": 237, "end": 238, "ctxt": 0 }, - "token": { - "Number": { - "value": 3.0, - "raw": "3", - "type": "integer" - } - } + "value": 3, + "raw": "3" } ] } diff --git a/crates/swc_css_parser/tests/recovery/ie-progid/output.swc-stderr b/crates/swc_css_parser/tests/recovery/ie-progid/output.swc-stderr index 2277924af161..3c99498821e8 100644 --- a/crates/swc_css_parser/tests/recovery/ie-progid/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/ie-progid/output.swc-stderr @@ -23,6 +23,18 @@ : ^ `---- + x Expected Declaration value + ,-[$DIR/tests/recovery/ie-progid/input.css:2:5] + 2 | filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f',endColorstr='#292929',GradientType=0); + : ^ + `---- + + x Expected Declaration value + ,-[$DIR/tests/recovery/ie-progid/input.css:2:5] + 2 | filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f',endColorstr='#292929',GradientType=0); + : ^ + `---- + x Expected Declaration value ,-[$DIR/tests/recovery/ie-progid/input.css:3:5] 3 | filter: progid:DXImageTransform.Microsoft.Blur(pixelradius=2) progid:DXImageTransform.Microsoft.Wheel(duration=3); diff --git a/crates/swc_css_parser/tests/recovery/ie-progid/span.rust-debug b/crates/swc_css_parser/tests/recovery/ie-progid/span.rust-debug index 93799a257713..3fea1cb45de8 100644 --- a/crates/swc_css_parser/tests/recovery/ie-progid/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/ie-progid/span.rust-debug @@ -325,7 +325,7 @@ : ^ `---- - x Number { value: 0.0, raw: Atom('0' type=inline), type_flag: Integer } + x Integer ,-[$DIR/tests/recovery/ie-progid/input.css:2:5] 2 | filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f',endColorstr='#292929',GradientType=0); : ^ @@ -481,7 +481,7 @@ : ^ `---- - x Number { value: 2.0, raw: Atom('2' type=inline), type_flag: Integer } + x Integer ,-[$DIR/tests/recovery/ie-progid/input.css:3:5] 3 | filter: progid:DXImageTransform.Microsoft.Blur(pixelradius=2) progid:DXImageTransform.Microsoft.Wheel(duration=3); : ^ @@ -607,7 +607,7 @@ : ^ `---- - x Number { value: 3.0, raw: Atom('3' type=inline), type_flag: Integer } + x Integer ,-[$DIR/tests/recovery/ie-progid/input.css:3:5] 3 | filter: progid:DXImageTransform.Microsoft.Blur(pixelradius=2) progid:DXImageTransform.Microsoft.Wheel(duration=3); : ^ diff --git a/crates/swc_css_parser/tests/recovery/vercel/002/output.swc-stderr b/crates/swc_css_parser/tests/recovery/vercel/002/output.swc-stderr index b41b881128c5..543afd2afdc1 100644 --- a/crates/swc_css_parser/tests/recovery/vercel/002/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/vercel/002/output.swc-stderr @@ -5,13 +5,13 @@ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- - x Expected 'number', 'dimension', 'percentage', 'ident', '(' or 'function' tokens + x Expected 'e', 'pi', 'infinity', '-infinity' or 'NaN', ident tokens ,-[$DIR/tests/recovery/vercel/002/input.css:4:5] 4 | margin: 0 calc(__styled-jsx-placeholder__7vw - __styled-jsx-placeholder__7px); - : ^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- - x Expected Declaration value + x Expected 'number', 'dimension', 'percentage', 'ident', '(' or 'function' tokens ,-[$DIR/tests/recovery/vercel/002/input.css:4:5] 4 | margin: 0 calc(__styled-jsx-placeholder__7vw - __styled-jsx-placeholder__7px); : ^ From 0a9c5a6baa6534bea76a404864e88fa3fb07ee21 Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Thu, 27 Oct 2022 22:04:10 +0300 Subject: [PATCH 02/12] fix: error repoting --- .../swc_css_parser/src/parser/syntax/mod.rs | 93 +++++++++ .../src/parser/values_and_units/mod.rs | 83 -------- .../function/unclosed-2/output.swc-stderr | 6 + .../recovery/function/unclosed-3/input.css | 2 + .../recovery/function/unclosed-3/output.json | 176 +++++++++++++++++ .../function/unclosed-3/output.swc-stderr | 12 ++ .../function/unclosed-3/span.rust-debug | 180 ++++++++++++++++++ .../function/unclosed/output.swc-stderr | 6 + .../unclosed-in-function/output.swc-stderr | 6 + 9 files changed, 481 insertions(+), 83 deletions(-) create mode 100644 crates/swc_css_parser/tests/recovery/function/unclosed-3/input.css create mode 100644 crates/swc_css_parser/tests/recovery/function/unclosed-3/output.json create mode 100644 crates/swc_css_parser/tests/recovery/function/unclosed-3/output.swc-stderr create mode 100644 crates/swc_css_parser/tests/recovery/function/unclosed-3/span.rust-debug diff --git a/crates/swc_css_parser/src/parser/syntax/mod.rs b/crates/swc_css_parser/src/parser/syntax/mod.rs index 2baf87d83eeb..db0b64308134 100644 --- a/crates/swc_css_parser/src/parser/syntax/mod.rs +++ b/crates/swc_css_parser/src/parser/syntax/mod.rs @@ -1023,6 +1023,99 @@ where } } +impl Parse for Parser +where + I: ParserInput, +{ + fn parse(&mut self) -> PResult { + // Note: This algorithm assumes that the current input token has already been + // checked to be a . + // + // To consume a function: + + // Create a function with its name equal to the value of the current input token + // and with its value initially set to an empty list. + let span = self.input.cur_span(); + let ident = match bump!(self) { + Token::Function { value, raw } => (value, raw), + _ => { + unreachable!() + } + }; + let function_name = &*ident.0.to_ascii_lowercase(); + let name = Ident { + span: swc_common::Span::new(span.lo, span.hi - BytePos(1), Default::default()), + value: ident.0, + raw: Some(ident.1), + }; + + let mut function = Function { + span: Default::default(), + name, + value: vec![], + }; + + // Repeatedly consume the next input token and process it as follows: + loop { + // + // This is a parse error. Return the function. + if is!(self, EOF) { + self.errors.push(Error::new( + span!(self, span.lo), + ErrorKind::EofButExpected("')'"), + )); + + break; + } + + match cur!(self) { + // <)-token> + // Return the function. + tok!(")") => { + bump!(self); + + break; + } + // anything else + // Reconsume the current input token. Consume a component value and append the + // returned value to the function’s value. + _ => match self.ctx.block_contents_grammar { + BlockContentsGrammar::NoGrammar => { + let ctx = Ctx { + block_contents_grammar: BlockContentsGrammar::NoGrammar, + ..self.ctx + }; + + let component_value = self.with_ctx(ctx).parse_as::()?; + + function.value.push(component_value); + } + _ => { + let state = self.input.state(); + let values = self.parse_function_values(function_name); + + match values { + Ok(values) => { + function.value.extend(values); + } + Err(err) => { + self.errors.push(err); + self.input.reset(&state); + + function.value.push(self.parse()?); + } + } + } + }, + } + } + + function.span = span!(self, span.lo); + + return Ok(function); + } +} + impl Parse for Parser where I: ParserInput, diff --git a/crates/swc_css_parser/src/parser/values_and_units/mod.rs b/crates/swc_css_parser/src/parser/values_and_units/mod.rs index cdf1adc805b8..fa51fe8d103e 100644 --- a/crates/swc_css_parser/src/parser/values_and_units/mod.rs +++ b/crates/swc_css_parser/src/parser/values_and_units/mod.rs @@ -2706,89 +2706,6 @@ where } } -impl Parse for Parser -where - I: ParserInput, -{ - fn parse(&mut self) -> PResult { - let span = self.input.cur_span(); - let ident = match bump!(self) { - Token::Function { value, raw } => (value, raw), - _ => { - unreachable!() - } - }; - let function_name = &*ident.0.to_ascii_lowercase(); - let name = Ident { - span: swc_common::Span::new(span.lo, span.hi - BytePos(1), Default::default()), - value: ident.0, - raw: Some(ident.1), - }; - - // Create a function with its name equal to the value of the current input token - // and with its value initially set to an empty list. - let mut function = Function { - span: Default::default(), - name, - value: vec![], - }; - - // Repeatedly consume the next input token and process it as follows: - loop { - // - // This is a parse error. Return the function. - if is!(self, EOF) { - break; - } - - match cur!(self) { - // <)-token> - // Return the function. - tok!(")") => { - bump!(self); - - break; - } - // anything else - // Reconsume the current input token. Consume a component value and append the - // returned value to the function’s value. - _ => match self.ctx.block_contents_grammar { - BlockContentsGrammar::NoGrammar => { - let ctx = Ctx { - block_contents_grammar: BlockContentsGrammar::NoGrammar, - ..self.ctx - }; - - let component_value = self.with_ctx(ctx).parse_as::()?; - - function.value.push(component_value); - } - _ => { - let state = self.input.state(); - let values = self.parse_function_values(function_name); - - match values { - Ok(values) => { - function.value.extend(values); - } - Err(err) => { - self.errors.push(err); - self.input.reset(&state); - - function.value.push(self.parse()?); - } - } - } - }, - } - } - - function.span = span!(self, span.lo); - - return Ok(function); - } -} - // = // u '+' '?'* | // u '?'* | diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.swc-stderr b/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.swc-stderr index 8d81cb8b7956..5ae7afe5e83f 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.swc-stderr @@ -10,3 +10,9 @@ 3 | : ^ `---- + + x Unexpected end of file, but expected ')' + ,-[$DIR/tests/recovery/function/unclosed-2/input.css:2:5] + 2 | ,-> grid-template-columns: repeat(4, [col-start] 12px + 3 | `-> } + `---- diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-3/input.css b/crates/swc_css_parser/tests/recovery/function/unclosed-3/input.css new file mode 100644 index 000000000000..9f13f1188592 --- /dev/null +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-3/input.css @@ -0,0 +1,2 @@ +.style { + grid-template-columns: rgb(255, 255, 255 \ No newline at end of file diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.json b/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.json new file mode 100644 index 000000000000..fdf8a22d4d59 --- /dev/null +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.json @@ -0,0 +1,176 @@ +{ + "type": "Stylesheet", + "span": { + "start": 1, + "end": 51, + "ctxt": 0 + }, + "rules": [ + { + "type": "QualifiedRule", + "span": { + "start": 1, + "end": 51, + "ctxt": 0 + }, + "prelude": { + "type": "SelectorList", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + }, + "children": [ + { + "type": "ComplexSelector", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + }, + "children": [ + { + "type": "CompoundSelector", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + }, + "nestingSelector": null, + "typeSelector": null, + "subclassSelectors": [ + { + "type": "ClassSelector", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + }, + "text": { + "type": "Ident", + "span": { + "start": 2, + "end": 7, + "ctxt": 0 + }, + "value": "style", + "raw": "style" + } + } + ] + } + ] + } + ] + }, + "block": { + "type": "SimpleBlock", + "span": { + "start": 8, + "end": 51, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 8, + "end": 9, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [ + { + "type": "Declaration", + "span": { + "start": 11, + "end": 51, + "ctxt": 0 + }, + "name": { + "type": "Ident", + "span": { + "start": 11, + "end": 32, + "ctxt": 0 + }, + "value": "grid-template-columns", + "raw": "grid-template-columns" + }, + "value": [ + { + "type": "Function", + "span": { + "start": 34, + "end": 51, + "ctxt": 0 + }, + "name": { + "type": "Ident", + "span": { + "start": 34, + "end": 37, + "ctxt": 0 + }, + "value": "rgb", + "raw": "rgb" + }, + "value": [ + { + "type": "Number", + "span": { + "start": 38, + "end": 41, + "ctxt": 0 + }, + "value": 255.0, + "raw": "255" + }, + { + "type": "Delimiter", + "span": { + "start": 41, + "end": 42, + "ctxt": 0 + }, + "value": "," + }, + { + "type": "Number", + "span": { + "start": 43, + "end": 46, + "ctxt": 0 + }, + "value": 255.0, + "raw": "255" + }, + { + "type": "Delimiter", + "span": { + "start": 46, + "end": 47, + "ctxt": 0 + }, + "value": "," + }, + { + "type": "Number", + "span": { + "start": 48, + "end": 51, + "ctxt": 0 + }, + "value": 255.0, + "raw": "255" + } + ] + } + ], + "important": null + } + ] + } + } + ] +} diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.swc-stderr b/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.swc-stderr new file mode 100644 index 000000000000..a2c27b502d67 --- /dev/null +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.swc-stderr @@ -0,0 +1,12 @@ + + x Unexpected end of file + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^ + `---- + + x Unexpected end of file, but expected ')' + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^ + `---- diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-3/span.rust-debug b/crates/swc_css_parser/tests/recovery/function/unclosed-3/span.rust-debug new file mode 100644 index 000000000000..cd343755501a --- /dev/null +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-3/span.rust-debug @@ -0,0 +1,180 @@ + + x Stylesheet + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | ,-> .style { + 2 | `-> grid-template-columns: rgb(255, 255, 255 + `---- + + x Rule + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | ,-> .style { + 2 | `-> grid-template-columns: rgb(255, 255, 255 + `---- + + x QualifiedRule + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | ,-> .style { + 2 | `-> grid-template-columns: rgb(255, 255, 255 + `---- + + x SelectorList + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | .style { + : ^^^^^^ + `---- + + x ComplexSelector + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | .style { + : ^^^^^^ + `---- + + x CompoundSelector + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | .style { + : ^^^^^^ + `---- + + x SubclassSelector + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | .style { + : ^^^^^^ + `---- + + x ClassSelector + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | .style { + : ^^^^^^ + `---- + + x Ident + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | .style { + : ^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | ,-> .style { + 2 | `-> grid-template-columns: rgb(255, 255, 255 + `---- + + x LBrace + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | .style { + : ^ + `---- + + x ComponentValue + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x StyleBlock + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Declaration + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x DeclarationName + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Ident + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ComponentValue + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^ + `---- + + x Color + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^ + `---- + + x Function + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^^^^^^^^^^^^^^^ + `---- + + x Ident + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^ + `---- + + x ComponentValue + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^ + `---- + + x Number + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^ + `---- + + x ComponentValue + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^ + `---- + + x Delimiter + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^ + `---- + + x ComponentValue + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^ + `---- + + x Number + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^ + `---- + + x ComponentValue + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^ + `---- + + x Delimiter + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^ + `---- + + x ComponentValue + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^ + `---- + + x Number + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] + 2 | grid-template-columns: rgb(255, 255, 255 + : ^^^ + `---- diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr b/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr index 63d540fd9c6f..44bfa7c8fc1b 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr @@ -22,3 +22,9 @@ 3 | : ^ `---- + + x Unexpected end of file, but expected ')' + ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] + 2 | ,-> width: min(500px; + 3 | `-> } + `---- diff --git a/crates/swc_css_parser/tests/recovery/simple-block/unclosed-in-function/output.swc-stderr b/crates/swc_css_parser/tests/recovery/simple-block/unclosed-in-function/output.swc-stderr index 743f324249b7..04ce4b165ea7 100644 --- a/crates/swc_css_parser/tests/recovery/simple-block/unclosed-in-function/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/simple-block/unclosed-in-function/output.swc-stderr @@ -10,3 +10,9 @@ 3 | : ^ `---- + + x Unexpected end of file, but expected ')' + ,-[$DIR/tests/recovery/simple-block/unclosed-in-function/input.css:2:5] + 2 | ,-> grid-template-columns: repeat(4, [col-start); + 3 | `-> } + `---- From 4da55b51db22b35e0e9f2dfd7666b9d78044bf6a Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Thu, 27 Oct 2022 22:20:21 +0300 Subject: [PATCH 03/12] fix: error reporting --- .../swc_css_parser/src/parser/syntax/mod.rs | 43 +++++++++++-------- .../recovery/at-rule/no-end/output.swc-stderr | 2 +- .../at-rule/no-semi/output.swc-stderr | 6 +-- .../function/unclosed-2/output.swc-stderr | 13 +++--- .../function/unclosed-3/output.swc-stderr | 12 +++--- .../function/unclosed/output.swc-stderr | 13 +++--- .../qualified-rule/broken/output.swc-stderr | 8 ++-- .../attribute/unclosed/output.swc-stderr | 7 +++ .../unclosed-in-function/output.swc-stderr | 17 +++++--- .../recovery/value/hash/eof/output.swc-stderr | 8 ++-- .../value/number/eof/output.swc-stderr | 8 ++-- .../eof-double-quotes/output.swc-stderr | 8 ++-- .../eof-single-quotes/output.swc-stderr | 8 ++-- .../string/escaped/broken-1/output.swc-stderr | 9 ++-- .../string/escaped/broken/output.swc-stderr | 8 ++-- .../value/string/newline/output.swc-stderr | 8 ++-- .../recovery/value/url/eof/output.swc-stderr | 4 +- .../value/url/parenthesis/output.swc-stderr | 9 ++-- 18 files changed, 107 insertions(+), 84 deletions(-) diff --git a/crates/swc_css_parser/src/parser/syntax/mod.rs b/crates/swc_css_parser/src/parser/syntax/mod.rs index db0b64308134..495496cbdc60 100644 --- a/crates/swc_css_parser/src/parser/syntax/mod.rs +++ b/crates/swc_css_parser/src/parser/syntax/mod.rs @@ -133,7 +133,7 @@ where // Consume the next input token. Create a new at-rule with its name set to the // value of the current input token, its prelude initially set to an empty list, // and its value initially set to nothing. - let at_rule_span = self.input.cur_span(); + let span = self.input.cur_span(); let at_keyword_name = match bump!(self) { Token::AtKeyword { value, raw } => (value, raw), _ => { @@ -144,11 +144,7 @@ where ( at_keyword_name.0.to_ascii_lowercase(), AtRuleName::DashedIdent(DashedIdent { - span: Span::new( - at_rule_span.lo + BytePos(1), - at_rule_span.hi, - Default::default(), - ), + span: Span::new(span.lo + BytePos(1), span.hi, Default::default()), value: at_keyword_name.0, raw: Some(at_keyword_name.1), }), @@ -157,11 +153,7 @@ where ( at_keyword_name.0.to_ascii_lowercase(), AtRuleName::Ident(Ident { - span: Span::new( - at_rule_span.lo + BytePos(1), - at_rule_span.hi, - Default::default(), - ), + span: Span::new(span.lo + BytePos(1), span.hi, Default::default()), value: at_keyword_name.0, raw: Some(at_keyword_name.1), }), @@ -180,11 +172,11 @@ where // This is a parse error. Return the at-rule. if is!(self, EOF) { self.errors.push(Error::new( - at_rule_span, - ErrorKind::EofButExpected("semicolon or curly block"), + span!(self, span.lo), + ErrorKind::EofButExpected("';' or '{'"), )); - at_rule.span = span!(self, at_rule_span.lo); + at_rule.span = span!(self, span.lo); return Ok(at_rule); } @@ -204,7 +196,7 @@ where Ok(at_rule_prelude) => match at_rule_prelude { None if normalized_at_rule_name == js_word!("layer") => { self.errors.push(Error::new( - at_rule_span, + span, ErrorKind::Expected("at least one name"), )); @@ -228,7 +220,7 @@ where } } }; - at_rule.span = span!(self, at_rule_span.lo); + at_rule.span = span!(self, span.lo); return Ok(at_rule); } @@ -295,7 +287,7 @@ where Some(block) } }; - at_rule.span = span!(self, at_rule_span.lo); + at_rule.span = span!(self, span.lo); return Ok(at_rule); } @@ -981,9 +973,19 @@ where // // This is a parse error. Return the block. if is!(self, EOF) { - let span = self.input.cur_span(); + let mirror = match &simple_block.name.token { + Token::LBracket => "']'", + Token::LParen => "')'", + Token::LBrace => "'}'", + _ => { + unreachable!(); + } + }; - self.errors.push(Error::new(span, ErrorKind::Eof)); + self.errors.push(Error::new( + span!(self, span.lo), + ErrorKind::EofButExpected(mirror), + )); break; } @@ -1128,6 +1130,9 @@ where }; let mut children = vec![]; + // Repeatedly consume a component value from input until an is + // returned, appending the returned values (except the final ) into a + // list. Return the list. loop { if is!(self, EOF) { break; diff --git a/crates/swc_css_parser/tests/recovery/at-rule/no-end/output.swc-stderr b/crates/swc_css_parser/tests/recovery/at-rule/no-end/output.swc-stderr index bac790c800f0..d6db84439df1 100644 --- a/crates/swc_css_parser/tests/recovery/at-rule/no-end/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/at-rule/no-end/output.swc-stderr @@ -1,5 +1,5 @@ - x Unexpected end of file, but expected semicolon or curly block + x Unexpected end of file, but expected ';' or '{' ,-[$DIR/tests/recovery/at-rule/no-end/input.css:1:1] 1 | @unknown : ^^^^^^^^ diff --git a/crates/swc_css_parser/tests/recovery/at-rule/no-semi/output.swc-stderr b/crates/swc_css_parser/tests/recovery/at-rule/no-semi/output.swc-stderr index 5b3c24f80267..3e276f86b6cc 100644 --- a/crates/swc_css_parser/tests/recovery/at-rule/no-semi/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/at-rule/no-semi/output.swc-stderr @@ -1,12 +1,12 @@ - x Unexpected end of file, but expected semicolon or curly block + x Unexpected end of file, but expected ';' or '{' ,-[$DIR/tests/recovery/at-rule/no-semi/input.css:1:1] 1 | @media screen {@content} : ^^^^^^^^ `---- - x Unexpected end of file, but expected semicolon or curly block + x Unexpected end of file, but expected ';' or '{' ,-[$DIR/tests/recovery/at-rule/no-semi/input.css:3:1] 3 | @charset "UTF-8" - : ^^^^^^^^ + : ^^^^^^^^^^^^^^^^^ `---- diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.swc-stderr b/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.swc-stderr index 5ae7afe5e83f..e9a582085358 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-2/output.swc-stderr @@ -5,14 +5,15 @@ : ^ `---- - x Unexpected end of file - ,-[$DIR/tests/recovery/function/unclosed-2/input.css:3:3] - 3 | - : ^ - `---- - x Unexpected end of file, but expected ')' ,-[$DIR/tests/recovery/function/unclosed-2/input.css:2:5] 2 | ,-> grid-template-columns: repeat(4, [col-start] 12px 3 | `-> } `---- + + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/function/unclosed-2/input.css:1:1] + 1 | ,-> .style { + 2 | | grid-template-columns: repeat(4, [col-start] 12px + 3 | `-> } + `---- diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.swc-stderr b/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.swc-stderr index a2c27b502d67..08ddd3806517 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/function/unclosed-3/output.swc-stderr @@ -1,12 +1,12 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] - 2 | grid-template-columns: rgb(255, 255, 255 - : ^ - `---- - x Unexpected end of file, but expected ')' ,-[$DIR/tests/recovery/function/unclosed-3/input.css:2:5] 2 | grid-template-columns: rgb(255, 255, 255 : ^^^^^^^^^^^^^^^^^ `---- + + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/function/unclosed-3/input.css:1:1] + 1 | ,-> .style { + 2 | `-> grid-template-columns: rgb(255, 255, 255 + `---- diff --git a/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr b/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr index 44bfa7c8fc1b..18ed73700a5e 100644 --- a/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/function/unclosed/output.swc-stderr @@ -17,14 +17,15 @@ : ^ `---- - x Unexpected end of file - ,-[$DIR/tests/recovery/function/unclosed/input.css:3:3] - 3 | - : ^ - `---- - x Unexpected end of file, but expected ')' ,-[$DIR/tests/recovery/function/unclosed/input.css:2:5] 2 | ,-> width: min(500px; 3 | `-> } `---- + + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/function/unclosed/input.css:1:1] + 1 | ,-> .style { + 2 | | width: min(500px; + 3 | `-> } + `---- diff --git a/crates/swc_css_parser/tests/recovery/qualified-rule/broken/output.swc-stderr b/crates/swc_css_parser/tests/recovery/qualified-rule/broken/output.swc-stderr index 21cbc95289ef..09b63666bc2b 100644 --- a/crates/swc_css_parser/tests/recovery/qualified-rule/broken/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/qualified-rule/broken/output.swc-stderr @@ -1,6 +1,6 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/qualified-rule/broken/input.css:4:17] - 4 | - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/qualified-rule/broken/input.css:3:1] + 3 | ,-> { + 4 | `-> color: red; `---- diff --git a/crates/swc_css_parser/tests/recovery/selector/attribute/unclosed/output.swc-stderr b/crates/swc_css_parser/tests/recovery/selector/attribute/unclosed/output.swc-stderr index 30907168ff5e..31096da6fc29 100644 --- a/crates/swc_css_parser/tests/recovery/selector/attribute/unclosed/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/selector/attribute/unclosed/output.swc-stderr @@ -4,3 +4,10 @@ 3 | : ^ `---- + + x Unexpected end of file, but expected ']' + ,-[$DIR/tests/recovery/selector/attribute/unclosed/input.css:1:1] + 1 | ,-> .class[attr= { + 2 | | + 3 | `-> } + `---- diff --git a/crates/swc_css_parser/tests/recovery/simple-block/unclosed-in-function/output.swc-stderr b/crates/swc_css_parser/tests/recovery/simple-block/unclosed-in-function/output.swc-stderr index 04ce4b165ea7..8433308f601b 100644 --- a/crates/swc_css_parser/tests/recovery/simple-block/unclosed-in-function/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/simple-block/unclosed-in-function/output.swc-stderr @@ -5,14 +5,21 @@ : ^ `---- - x Unexpected end of file - ,-[$DIR/tests/recovery/simple-block/unclosed-in-function/input.css:3:3] - 3 | - : ^ + x Unexpected end of file, but expected ')' + ,-[$DIR/tests/recovery/simple-block/unclosed-in-function/input.css:2:5] + 2 | ,-> grid-template-columns: repeat(4, [col-start); + 3 | `-> } `---- - x Unexpected end of file, but expected ')' + x Unexpected end of file, but expected ']' ,-[$DIR/tests/recovery/simple-block/unclosed-in-function/input.css:2:5] 2 | ,-> grid-template-columns: repeat(4, [col-start); 3 | `-> } `---- + + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/simple-block/unclosed-in-function/input.css:1:1] + 1 | ,-> .style { + 2 | | grid-template-columns: repeat(4, [col-start); + 3 | `-> } + `---- diff --git a/crates/swc_css_parser/tests/recovery/value/hash/eof/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/hash/eof/output.swc-stderr index 5f13b23ef9d3..7356ebcc6cac 100644 --- a/crates/swc_css_parser/tests/recovery/value/hash/eof/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/hash/eof/output.swc-stderr @@ -5,8 +5,8 @@ : ^ `---- - x Unexpected end of file - ,-[$DIR/tests/recovery/value/hash/eof/input.css:2:5] - 2 | prop: # - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/value/hash/eof/input.css:1:1] + 1 | ,-> a { + 2 | `-> prop: # `---- diff --git a/crates/swc_css_parser/tests/recovery/value/number/eof/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/number/eof/output.swc-stderr index 20070b511b80..4e6a62f737b1 100644 --- a/crates/swc_css_parser/tests/recovery/value/number/eof/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/number/eof/output.swc-stderr @@ -1,6 +1,6 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/value/number/eof/input.css:2:3] - 2 | prop: 12 - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/value/number/eof/input.css:1:1] + 1 | ,-> a { + 2 | `-> prop: 12 `---- diff --git a/crates/swc_css_parser/tests/recovery/value/string/eof-double-quotes/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/string/eof-double-quotes/output.swc-stderr index 2c14307a68d3..23adbdc268c7 100644 --- a/crates/swc_css_parser/tests/recovery/value/string/eof-double-quotes/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/string/eof-double-quotes/output.swc-stderr @@ -1,8 +1,8 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/value/string/eof-double-quotes/input.css:2:3] - 2 | prop: "string - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/value/string/eof-double-quotes/input.css:1:1] + 1 | ,-> div { + 2 | `-> prop: "string `---- x Unterminated string diff --git a/crates/swc_css_parser/tests/recovery/value/string/eof-single-quotes/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/string/eof-single-quotes/output.swc-stderr index 3b08dec299ae..c5e5cd477de8 100644 --- a/crates/swc_css_parser/tests/recovery/value/string/eof-single-quotes/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/string/eof-single-quotes/output.swc-stderr @@ -1,8 +1,8 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/value/string/eof-single-quotes/input.css:2:3] - 2 | prop: 'string - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/value/string/eof-single-quotes/input.css:1:1] + 1 | ,-> div { + 2 | `-> prop: 'string `---- x Unterminated string diff --git a/crates/swc_css_parser/tests/recovery/value/string/escaped/broken-1/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/string/escaped/broken-1/output.swc-stderr index f21fea9d4ba7..3894af28bfbe 100644 --- a/crates/swc_css_parser/tests/recovery/value/string/escaped/broken-1/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/string/escaped/broken-1/output.swc-stderr @@ -1,8 +1,9 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/value/string/escaped/broken-1/input.css:3:1] - 3 | } - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/value/string/escaped/broken-1/input.css:1:1] + 1 | ,-> a { + 2 | | prop: "\a + 3 | `-> } `---- x Unterminated string diff --git a/crates/swc_css_parser/tests/recovery/value/string/escaped/broken/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/string/escaped/broken/output.swc-stderr index 5ff036c1e7a0..0cc11e3e27bd 100644 --- a/crates/swc_css_parser/tests/recovery/value/string/escaped/broken/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/string/escaped/broken/output.swc-stderr @@ -1,8 +1,8 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/value/string/escaped/broken/input.css:2:5] - 2 | prop: "test\\ - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/value/string/escaped/broken/input.css:1:1] + 1 | ,-> a { + 2 | `-> prop: "test\\ `---- x Unterminated string diff --git a/crates/swc_css_parser/tests/recovery/value/string/newline/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/string/newline/output.swc-stderr index 85a4397beb80..86f2b55a3b4c 100644 --- a/crates/swc_css_parser/tests/recovery/value/string/newline/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/string/newline/output.swc-stderr @@ -11,10 +11,10 @@ : ^ `---- - x Unexpected end of file - ,-[$DIR/tests/recovery/value/string/newline/input.css:2:13] - 2 | - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/value/string/newline/input.css:1:1] + 1 | ,-> a { + 2 | `-> prop: " `---- x Unexpected token in diff --git a/crates/swc_css_parser/tests/recovery/value/url/eof/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/url/eof/output.swc-stderr index aeb7b253fc96..42ef706a971c 100644 --- a/crates/swc_css_parser/tests/recovery/value/url/eof/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/url/eof/output.swc-stderr @@ -1,8 +1,8 @@ - x Unexpected end of file + x Unexpected end of file, but expected '}' ,-[$DIR/tests/recovery/value/url/eof/input.css:1:1] 1 | a { prop: url(foo.png - : ^ + : ^^^^^^^^^^^^^^^^^^^ `---- x Unterminated url diff --git a/crates/swc_css_parser/tests/recovery/value/url/parenthesis/output.swc-stderr b/crates/swc_css_parser/tests/recovery/value/url/parenthesis/output.swc-stderr index 5fb9cb41e5c7..9596c6ed4f02 100644 --- a/crates/swc_css_parser/tests/recovery/value/url/parenthesis/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/value/url/parenthesis/output.swc-stderr @@ -5,10 +5,11 @@ 3 | `-> } `---- - x Unexpected end of file - ,-[$DIR/tests/recovery/value/url/parenthesis/input.css:3:1] - 3 | } - : ^ + x Unexpected end of file, but expected '}' + ,-[$DIR/tests/recovery/value/url/parenthesis/input.css:1:1] + 1 | ,-> a { + 2 | | background: url(test\); + 3 | `-> } `---- x Unexpected token in From 64bf9b2ade9d7fae4d1e1bb2e2e2c2e083da7699 Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Thu, 27 Oct 2022 22:23:19 +0300 Subject: [PATCH 04/12] fix: error reporting --- crates/swc_css_parser/src/parser/syntax/mod.rs | 7 ++++--- .../at-rule/media/invalid-nesting/output.swc-stderr | 7 ++++--- .../recovery/comments/bad-comment-1/output.swc-stderr | 4 ++-- .../tests/recovery/hacks/output.swc-stderr | 9 +++++---- .../selector/attribute/unclosed/output.swc-stderr | 11 ++++++----- .../style-blocks-contents/basic/output.swc-stderr | 7 ++++--- .../invalid-nested-2/output.swc-stderr | 9 +++++---- .../invalid-nested/output.swc-stderr | 9 +++++---- .../tests/recovery/vercel/001/output.swc-stderr | 7 ++++--- 9 files changed, 39 insertions(+), 31 deletions(-) diff --git a/crates/swc_css_parser/src/parser/syntax/mod.rs b/crates/swc_css_parser/src/parser/syntax/mod.rs index 495496cbdc60..692758d0ad66 100644 --- a/crates/swc_css_parser/src/parser/syntax/mod.rs +++ b/crates/swc_css_parser/src/parser/syntax/mod.rs @@ -378,9 +378,10 @@ where // // This is a parse error. Return nothing. if is!(self, EOF) { - let span = self.input.cur_span(); - - return Err(Error::new(span, ErrorKind::Eof)); + return Err(Error::new( + span!(self, span.lo), + ErrorKind::EofButExpected("'{'"), + )); } match cur!(self) { diff --git a/crates/swc_css_parser/tests/recovery/at-rule/media/invalid-nesting/output.swc-stderr b/crates/swc_css_parser/tests/recovery/at-rule/media/invalid-nesting/output.swc-stderr index e7e00b1d1c03..587b7d879a6c 100644 --- a/crates/swc_css_parser/tests/recovery/at-rule/media/invalid-nesting/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/at-rule/media/invalid-nesting/output.swc-stderr @@ -1,6 +1,7 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/at-rule/media/invalid-nesting/input.css:3:1] + x Unexpected end of file, but expected '{' + ,-[$DIR/tests/recovery/at-rule/media/invalid-nesting/input.css:2:5] + 2 | max-inline-size: 1024px; + : ^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | } - : ^ `---- diff --git a/crates/swc_css_parser/tests/recovery/comments/bad-comment-1/output.swc-stderr b/crates/swc_css_parser/tests/recovery/comments/bad-comment-1/output.swc-stderr index 7cbea7c537f0..357dd752cb7d 100644 --- a/crates/swc_css_parser/tests/recovery/comments/bad-comment-1/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/comments/bad-comment-1/output.swc-stderr @@ -1,6 +1,6 @@ - x Unexpected end of file + x Unexpected end of file, but expected '{' ,-[$DIR/tests/recovery/comments/bad-comment-1/input.css:1:1] 1 | // comment - : ^ + : ^^^^^^^^^^ `---- diff --git a/crates/swc_css_parser/tests/recovery/hacks/output.swc-stderr b/crates/swc_css_parser/tests/recovery/hacks/output.swc-stderr index 39f669bb8585..c1abf4749afe 100644 --- a/crates/swc_css_parser/tests/recovery/hacks/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/hacks/output.swc-stderr @@ -167,10 +167,11 @@ : ^ `---- - x Unexpected end of file - ,-[$DIR/tests/recovery/hacks/input.css:114:1] - 114 | } - : ^ + x Unexpected end of file, but expected '{' + ,-[$DIR/tests/recovery/hacks/input.css:112:5] + 112 | ,-> &property: value; + 113 | `-> color: red; + 114 | } `---- x Unexpected tokens in at-rule prelude diff --git a/crates/swc_css_parser/tests/recovery/selector/attribute/unclosed/output.swc-stderr b/crates/swc_css_parser/tests/recovery/selector/attribute/unclosed/output.swc-stderr index 31096da6fc29..531f60e372d8 100644 --- a/crates/swc_css_parser/tests/recovery/selector/attribute/unclosed/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/selector/attribute/unclosed/output.swc-stderr @@ -1,11 +1,12 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/selector/attribute/unclosed/input.css:3:3] - 3 | - : ^ + x Unexpected end of file, but expected ']' + ,-[$DIR/tests/recovery/selector/attribute/unclosed/input.css:1:1] + 1 | ,-> .class[attr= { + 2 | | + 3 | `-> } `---- - x Unexpected end of file, but expected ']' + x Unexpected end of file, but expected '{' ,-[$DIR/tests/recovery/selector/attribute/unclosed/input.css:1:1] 1 | ,-> .class[attr= { 2 | | diff --git a/crates/swc_css_parser/tests/recovery/style-blocks-contents/basic/output.swc-stderr b/crates/swc_css_parser/tests/recovery/style-blocks-contents/basic/output.swc-stderr index 013404b4fd59..22bde2dbfc5d 100644 --- a/crates/swc_css_parser/tests/recovery/style-blocks-contents/basic/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/style-blocks-contents/basic/output.swc-stderr @@ -29,8 +29,9 @@ : ^ `---- - x Unexpected end of file - ,-[$DIR/tests/recovery/style-blocks-contents/basic/input.css:40:1] + x Unexpected end of file, but expected '{' + ,-[$DIR/tests/recovery/style-blocks-contents/basic/input.css:39:5] + 39 | & test; + : ^^^^^^^^ 40 | } - : ^ `---- diff --git a/crates/swc_css_parser/tests/recovery/style-blocks-contents/invalid-nested-2/output.swc-stderr b/crates/swc_css_parser/tests/recovery/style-blocks-contents/invalid-nested-2/output.swc-stderr index 4c1d145d5338..ce3fc6d40742 100644 --- a/crates/swc_css_parser/tests/recovery/style-blocks-contents/invalid-nested-2/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/style-blocks-contents/invalid-nested-2/output.swc-stderr @@ -1,6 +1,7 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/style-blocks-contents/invalid-nested-2/input.css:5:1] - 5 | } - : ^ + x Unexpected end of file, but expected '{' + ,-[$DIR/tests/recovery/style-blocks-contents/invalid-nested-2/input.css:3:5] + 3 | ,-> & test; + 4 | `-> background: red + 5 | } `---- diff --git a/crates/swc_css_parser/tests/recovery/style-blocks-contents/invalid-nested/output.swc-stderr b/crates/swc_css_parser/tests/recovery/style-blocks-contents/invalid-nested/output.swc-stderr index 1c99aacdda4a..8ccbdbc13215 100644 --- a/crates/swc_css_parser/tests/recovery/style-blocks-contents/invalid-nested/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/style-blocks-contents/invalid-nested/output.swc-stderr @@ -1,6 +1,7 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/style-blocks-contents/invalid-nested/input.css:5:1] - 5 | } - : ^ + x Unexpected end of file, but expected '{' + ,-[$DIR/tests/recovery/style-blocks-contents/invalid-nested/input.css:3:5] + 3 | ,-> & test; + 4 | `-> background: red; + 5 | } `---- diff --git a/crates/swc_css_parser/tests/recovery/vercel/001/output.swc-stderr b/crates/swc_css_parser/tests/recovery/vercel/001/output.swc-stderr index 725438d761ca..6521eb605cdf 100644 --- a/crates/swc_css_parser/tests/recovery/vercel/001/output.swc-stderr +++ b/crates/swc_css_parser/tests/recovery/vercel/001/output.swc-stderr @@ -1,6 +1,7 @@ - x Unexpected end of file - ,-[$DIR/tests/recovery/vercel/001/input.css:15:1] + x Unexpected end of file, but expected '{' + ,-[$DIR/tests/recovery/vercel/001/input.css:14:5] + 14 | __styled-jsx-placeholder__7 + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | } - : ^ `---- From 3202c0e3ab6507c64a692d7ceb41698897b6a25c Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Fri, 28 Oct 2022 03:15:59 +0300 Subject: [PATCH 05/12] refactor: declaration parsing --- .../swc_css_parser/src/parser/syntax/mod.rs | 242 +- .../src/parser/values_and_units/mod.rs | 265 +- .../tests/fixture/csstree/1/output.json | 251 +- .../tests/fixture/csstree/1/span.rust-debug | 70 +- .../tests/fixture/function/calc/output.json | 169 +- .../fixture/function/calc/span.rust-debug | 30 +- .../rome/custom-properties/output.json | 382 +- .../rome/custom-properties/span.rust-debug | 234 +- .../tests/fixture/style-block/output.json | 701 ++-- .../tests/fixture/style-block/span.rust-debug | 103 +- .../fixture/value/custom-property/output.json | 3588 ++++++++--------- .../value/custom-property/span.rust-debug | 881 ++-- .../bad-url-token/double-quotes/output.json | 62 +- .../double-quotes/output.swc-stderr | 6 - .../double-quotes/span.rust-debug | 44 +- .../bad-url-token/invalid-escape/output.json | 62 +- .../invalid-escape/output.swc-stderr | 6 - .../invalid-escape/span.rust-debug | 42 +- .../left-parenthesis/output.json | 62 +- .../left-parenthesis/output.swc-stderr | 6 - .../left-parenthesis/span.rust-debug | 44 +- .../bad-url-token/single-quotes/output.json | 62 +- .../single-quotes/output.swc-stderr | 6 - .../single-quotes/span.rust-debug | 44 +- .../whitespace-in-middle/output.json | 62 +- .../whitespace-in-middle/output.swc-stderr | 6 - .../whitespace-in-middle/span.rust-debug | 44 +- .../bad-url-token/whitespace/output.json | 62 +- .../whitespace/output.swc-stderr | 6 - .../bad-url-token/whitespace/span.rust-debug | 42 +- .../recovery/comments/declaration/output.json | 66 +- .../comments/declaration/span.rust-debug | 43 +- .../recovery/declaration/basic/output.json | 62 +- .../declaration/basic/output.swc-stderr | 4 +- .../declaration/basic/span.rust-debug | 44 +- .../recovery/declaration/important/input.css | 20 + .../declaration/important/output.json | 1206 +++++- .../declaration/important/output.swc-stderr | 34 +- .../declaration/important/span.rust-debug | 1155 +++++- .../recovery/delim-token/at-sign/output.json | 23 +- .../delim-token/at-sign/span.rust-debug | 14 +- .../recovery/delim-token/bang/output.json | 62 +- .../delim-token/bang/output.swc-stderr | 4 +- .../recovery/delim-token/bang/span.rust-debug | 44 +- .../delim-token/hash/output.swc-stderr | 6 - .../recovery/delim-token/minus/output.json | 48 +- .../delim-token/minus/span.rust-debug | 28 +- .../recovery/delim-token/plus/output.json | 48 +- .../recovery/delim-token/plus/span.rust-debug | 28 +- .../tests/recovery/function-token/output.json | 40 +- .../recovery/function-token/span.rust-debug | 18 +- .../function/bad-comment-2/output.json | 62 +- .../function/bad-comment-2/output.swc-stderr | 8 - .../function/bad-comment-2/span.rust-debug | 44 +- .../recovery/function/bad-comment/output.json | 62 +- .../function/bad-comment/output.swc-stderr | 8 - .../function/bad-comment/span.rust-debug | 44 +- .../tests/recovery/hacks/output.json | 62 +- .../tests/recovery/hacks/output.swc-stderr | 12 +- .../tests/recovery/hacks/span.rust-debug | 44 +- .../tests/recovery/ie-progid/output.json | 136 +- .../recovery/ie-progid/output.swc-stderr | 72 - .../tests/recovery/ie-progid/span.rust-debug | 36 +- .../tests/recovery/number/output.json | 184 +- .../tests/recovery/number/output.swc-stderr | 12 - .../tests/recovery/number/span.rust-debug | 93 +- .../tests/recovery/styled-jsx/1/output.json | 30 +- .../recovery/styled-jsx/1/span.rust-debug | 6 +- .../tests/recovery/styled-jsx/2/output.json | 10 +- .../recovery/styled-jsx/2/span.rust-debug | 2 +- .../tests/recovery/unicode-range/output.json | 58 +- .../recovery/unicode-range/span.rust-debug | 40 +- .../custom-properties/exclamation/output.json | 271 +- .../exclamation/span.rust-debug | 184 +- .../custom-properties/only-dashed/output.json | 46 +- .../only-dashed/span.rust-debug | 28 +- .../recovery/value/number/dot/output.json | 11 +- .../recovery/value/number/dot/span.rust-debug | 2 +- .../value/number/minus-dot/output.json | 11 +- .../value/number/minus-dot/span.rust-debug | 2 +- .../value/number/plus-dot/output.json | 11 +- .../value/number/plus-dot/span.rust-debug | 2 +- .../recovery/value/percentage/dot/output.json | 11 +- .../value/percentage/dot/output.swc-stderr | 6 - .../value/percentage/dot/span.rust-debug | 2 +- .../value/percentage/minus/output.json | 11 +- .../value/percentage/minus/output.swc-stderr | 6 - .../value/percentage/minus/span.rust-debug | 2 +- .../value/percentage/plus/output.json | 11 +- .../value/percentage/plus/output.swc-stderr | 6 - .../value/percentage/plus/span.rust-debug | 2 +- .../tests/recovery/value/quotes/output.json | 66 +- .../recovery/value/quotes/output.swc-stderr | 12 - .../recovery/value/quotes/span.rust-debug | 47 +- .../recovery/value/string/newline/output.json | 66 +- .../value/string/newline/output.swc-stderr | 6 - .../value/string/newline/span.rust-debug | 45 +- .../recovery/value/url/basic/output.json | 151 +- .../value/url/basic/output.swc-stderr | 12 - .../recovery/value/url/basic/span.rust-debug | 124 +- .../value/url/parenthesis/output.json | 51 +- .../value/url/parenthesis/output.swc-stderr | 6 - .../value/url/parenthesis/span.rust-debug | 30 +- .../tests/recovery/vercel/003/output.json | 10 +- .../tests/recovery/vercel/003/span.rust-debug | 2 +- 105 files changed, 6972 insertions(+), 5887 deletions(-) diff --git a/crates/swc_css_parser/src/parser/syntax/mod.rs b/crates/swc_css_parser/src/parser/syntax/mod.rs index 692758d0ad66..f619cc140536 100644 --- a/crates/swc_css_parser/src/parser/syntax/mod.rs +++ b/crates/swc_css_parser/src/parser/syntax/mod.rs @@ -764,23 +764,29 @@ where I: ParserInput, { fn parse(&mut self) -> PResult { - let span = self.input.cur_span(); + // To consume a declaration: // Consume the next input token. Create a new declaration with its name set // to the value of the current input token and its value initially set to an // empty list. + let span = self.input.cur_span(); let is_dashed_ident = match cur!(self) { Token::Ident { value, .. } => value.starts_with("--"), _ => { return Err(Error::new(span, ErrorKind::Expected("Ident"))); } }; - let name = if is_dashed_ident { DeclarationName::DashedIdent(self.parse()?) } else { DeclarationName::Ident(self.parse()?) }; + let mut declaration = Declaration { + span: Default::default(), + name, + value: vec![], + important: None, + }; // 1. While the next input token is a , consume the next input // token. @@ -794,124 +800,164 @@ where // token. self.input.skip_ws(); - let mut end = self.input.cur_span().hi; - let mut value = vec![]; - // 4. As long as the next input token is anything other than an , // consume a component value and append it to the declaration’s value. - if !is!(self, EOF) { - match is_dashed_ident { - true => { - value.extend(self.parse_declaration_value()?); - } - false => { - loop { - // TODO fix me - self.input.skip_ws(); - - // TODO fix me - if is_one_of!(self, EOF, "!", ";", "}", ")") { - break; - } + let mut last_whitespaces = (0, 0, 0); + let mut exclamation_point_span = None; + let mut important_ident = None; - let state = self.input.state(); - let ctx = Ctx { - block_contents_grammar: BlockContentsGrammar::DeclarationValue, - ..self.ctx - }; - let parsed = self.with_ctx(ctx).parse_generic_value(); - let value_or_token = match parsed { - Ok(value) => value, - Err(err) => { - self.errors.push(err); - self.input.reset(&state); + loop { + // TODO fix me `)`, workaround + if is_one_of!(self, EOF, ")") { + break; + } + + let component_value = self + .with_ctx(Ctx { + block_contents_grammar: BlockContentsGrammar::NoGrammar, + ..self.ctx + }) + .parse_as::()?; + + match &component_value { + // Optimization for step 5 + ComponentValue::PreservedToken( + token_and_span @ TokenAndSpan { + token: Token::Ident { value, .. }, + .. + }, + ) if exclamation_point_span.is_some() + && value.to_ascii_lowercase() == js_word!("important") => + { + important_ident = Some(token_and_span.clone()); + } + ComponentValue::PreservedToken(TokenAndSpan { + span, + token: Token::Delim { value: '!', .. }, + .. + }) => { + exclamation_point_span = Some(span.clone()); - let ctx = Ctx { - block_contents_grammar: BlockContentsGrammar::NoGrammar, - ..self.ctx - }; + if important_ident.is_some() { + important_ident = None; - self.with_ctx(ctx).parse_as::()? - } - }; + last_whitespaces = (last_whitespaces.2, 0, 0); + } + } + // Optimization for step 6 + ComponentValue::PreservedToken(TokenAndSpan { + token: Token::WhiteSpace { .. }, + .. + }) => match (&exclamation_point_span, &important_ident) { + (Some(_), Some(_)) => { + last_whitespaces.2 += 1; + } + (Some(_), None) => { + last_whitespaces.1 += 1; + } + (None, None) => { + last_whitespaces.0 += 1; + } + _ => { + unreachable!(); + } + }, + _ => { + last_whitespaces = (0, 0, 0); - value.push(value_or_token); - end = self.input.last_pos(); + if exclamation_point_span.is_some() { + important_ident = None; + exclamation_point_span = None; } } } - match value.last() { - Some(ComponentValue::PreservedToken(TokenAndSpan { - span, - token: Token::BadUrl { .. }, - .. - })) - | Some(ComponentValue::PreservedToken(TokenAndSpan { - span, - token: Token::BadString { .. }, - .. - })) => { - return Err(Error::new( - *span, - ErrorKind::Unexpected("token in "), - )); - } - _ => {} - }; + declaration.value.push(component_value); } // 5. If the last two non-s in the declaration’s value are a // with the value "!" followed by an with a value // that is an ASCII case-insensitive match for "important", remove them from the // declaration’s value and set the declaration’s important flag to true. - self.input.skip_ws(); - - let important = if is!(self, "!") { - let important_flag = self.parse()?; + if let (Some(exclamation_point_span), Some(important_ident)) = + (exclamation_point_span, important_ident) + { + let span = Span::new( + exclamation_point_span.lo, + important_ident.span_hi(), + Default::default(), + ); + let value = match important_ident.token { + Token::Ident { value, raw } => (value, raw), + _ => { + unreachable!(); + } + }; + let value = Ident { + span: important_ident.span, + value: value.0, + raw: Some(value.1), + }; - end = self.input.last_pos(); + declaration.important = Some(ImportantFlag { span, value }); + } - Some(important_flag) + // 6. While the last token in the declaration’s value is a , + // remove that token. + let len = if declaration.important.is_some() { + declaration.value.len() + - (last_whitespaces.0 + last_whitespaces.1 + last_whitespaces.2 + 2) } else { - None + declaration.value.len() - (last_whitespaces.0 + last_whitespaces.1 + last_whitespaces.2) }; - // 6. While the last token in the declaration’s value is a , - // remove that token. - self.input.skip_ws(); + declaration.value.truncate(len); - // 7. Return the declaration. - Ok(Declaration { - span: Span::new(span.lo, end, Default::default()), - name, - value, - important, - }) - } -} + // Update span + // TODO for commit history + if let Some(important) = &declaration.important { + declaration.span = Span::new(span.lo, important.span_hi(), Default::default()); + } else if let Some(last) = declaration.value.last() { + declaration.span = Span::new(span.lo, last.span_hi(), Default::default()); + } else { + declaration.span = span!(self, span.lo); + } -impl Parse for Parser -where - I: ParserInput, -{ - fn parse(&mut self) -> PResult { - let span = self.input.cur_span(); + if is_dashed_ident { + // Don't parse custom properties + // + // 7. Return the declaration. + return Ok(declaration); + } - expect!(self, "!"); + // Grammar parsing + let locv = self.create_locv(declaration.value); - self.input.skip_ws(); + declaration.value = match self.parse_according_to_grammar(&locv, |parser| { + let mut values = vec![]; - let ident: Ident = self.parse()?; + loop { + if is!(parser, EOF) { + break; + } - if &*ident.value.to_ascii_lowercase() != "important" { - return Err(Error::new(span, ErrorKind::Expected("important"))); - } + values.push(parser.parse_generic_value()?); + } - Ok(ImportantFlag { - span: span!(self, span.lo), - value: ident, - }) + Ok(values) + }) { + Ok(values) => values, + Err(err) => { + if *err.kind() != ErrorKind::Ignore { + self.errors.push(err); + } + + locv.children + } + }; + + // 7. Return the declaration. + Ok(declaration) } } @@ -930,7 +976,11 @@ where } // Otherwise, if the current input token is a , consume a // function and return it. - tok!("function") => Ok(ComponentValue::Function(self.parse()?)), + tok!("function") => { + let function = self.parse()?; + + Ok(ComponentValue::Function(function)) + } // Otherwise, return the current input token. _ => { let token = self.input.bump(); @@ -951,6 +1001,10 @@ where I: ParserInput, { fn parse(&mut self) -> PResult { + // To consume a simple block: + + // Create a simple block with its associated token set to the current input + // token and with its value initially set to an empty list. let span = self.input.cur_span(); let name = match cur!(self) { tok!("{") | tok!("(") | tok!("[") => self.input.bump().unwrap(), @@ -961,8 +1015,6 @@ where )); } }; - // Create a simple block with its associated token set to the current input - // token and with its value initially set to an empty list. let mut simple_block = SimpleBlock { span: Default::default(), name, diff --git a/crates/swc_css_parser/src/parser/values_and_units/mod.rs b/crates/swc_css_parser/src/parser/values_and_units/mod.rs index fa51fe8d103e..6781629406cf 100644 --- a/crates/swc_css_parser/src/parser/values_and_units/mod.rs +++ b/crates/swc_css_parser/src/parser/values_and_units/mod.rs @@ -38,7 +38,13 @@ where return Ok(ComponentValue::Color(self.parse()?)); } _ => { - return Ok(ComponentValue::Function(self.parse()?)); + return Ok(ComponentValue::Function( + self.with_ctx(Ctx { + block_contents_grammar: BlockContentsGrammar::DeclarationValue, + ..self.ctx + }) + .parse_as::()?, + )); } }, @@ -465,7 +471,15 @@ where } tok!("number") => Ok(Some(ComponentValue::Number(parser.parse()?))), Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { is_legacy_syntax = false; @@ -523,7 +537,15 @@ where } } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } _ => { if !has_variable_before { @@ -578,7 +600,15 @@ where } tok!("number") => Ok(Some(ComponentValue::Number(parser.parse()?))), Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") if !is_legacy_syntax => { let ident: Ident = parser.parse()?; @@ -622,7 +652,15 @@ where Ok(Some(ComponentValue::Percentage(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -690,7 +728,15 @@ where } tok!("number") => Ok(Some(ComponentValue::Number(parser.parse()?))), Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") if !is_legacy_syntax => { let ident: Ident = parser.parse()?; @@ -734,7 +780,15 @@ where Ok(Some(ComponentValue::Percentage(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -787,7 +841,15 @@ where Ok(Some(ComponentValue::AlphaValue(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } _ => { if !has_variable_before { @@ -821,7 +883,15 @@ where Ok(Some(ComponentValue::AlphaValue(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -895,7 +965,15 @@ where Ok(Some(ComponentValue::Hue(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -940,7 +1018,15 @@ where } tok!("number") => Ok(Some(ComponentValue::Number(parser.parse()?))), Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -1003,7 +1089,15 @@ where Ok(Some(ComponentValue::Percentage(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -1052,7 +1146,15 @@ where Ok(Some(ComponentValue::Number(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -1120,7 +1222,15 @@ where Ok(Some(ComponentValue::Percentage(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -1169,7 +1279,15 @@ where Ok(Some(ComponentValue::Number(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -1215,7 +1333,15 @@ where Ok(Some(ComponentValue::Hue(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -1298,7 +1424,15 @@ where Ok(Some(ComponentValue::AlphaValue(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") if !matches!(function_name, "device-cmyk") => { let ident: Ident = parser.parse()?; @@ -1407,7 +1541,15 @@ where Ok(Some(ComponentValue::Percentage(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -1458,7 +1600,14 @@ where "var" | "env" | "constant" ) => { - ComponentValue::Function(self.parse()?) + ComponentValue::Function( + self.with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..self.ctx + }) + .parse_as::()?, + ) } tok!("ident") => { let ident: Ident = self.parse()?; @@ -1489,7 +1638,15 @@ where Ok(Some(ComponentValue::Percentage(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") => { let ident: Ident = parser.parse()?; @@ -1545,7 +1702,15 @@ where } } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } _ => { if !has_variable_before { @@ -1582,7 +1747,15 @@ where Ok(Some(ComponentValue::AlphaValue(parser.parse()?))) } Token::Function { value, .. } if is_math_function(value) => { - Ok(Some(ComponentValue::Function(parser.parse()?))) + Ok(Some(ComponentValue::Function( + parser + .with_ctx(Ctx { + block_contents_grammar: + BlockContentsGrammar::DeclarationValue, + ..parser.ctx + }) + .parse_as::()?, + ))) } tok!("ident") if !matches!(function_name, "device-cmyk") => { let ident: Ident = parser.parse()?; @@ -1687,7 +1860,13 @@ where { *has_before_variable = true; - Ok(Some(ComponentValue::Function(self.parse()?))) + Ok(Some(ComponentValue::Function( + self.with_ctx(Ctx { + block_contents_grammar: BlockContentsGrammar::DeclarationValue, + ..self.ctx + }) + .parse_as::()?, + ))) } _ => fallback(self, *has_before_variable), } @@ -2373,7 +2552,13 @@ where } // Token::Function { value, .. } if value.as_ref().eq_ignore_ascii_case("device-cmyk") => { - Ok(Color::Function(self.parse()?)) + Ok(Color::Function( + self.with_ctx(Ctx { + block_contents_grammar: BlockContentsGrammar::DeclarationValue, + ..self.ctx + }) + .parse_as::()?, + )) } // _ => match self.parse() { @@ -2414,7 +2599,13 @@ where Ok(AbsoluteColorBase::NamedColorOrTransparent(self.parse()?)) } Token::Function { value, .. } if is_absolute_color_base_function(value) => { - Ok(AbsoluteColorBase::Function(self.parse()?)) + Ok(AbsoluteColorBase::Function( + self.with_ctx(Ctx { + block_contents_grammar: BlockContentsGrammar::DeclarationValue, + ..self.ctx + }) + .parse_as::()?, + )) } _ => { return Err(Error::new( @@ -2525,7 +2716,13 @@ where return Err(Error::new(span, ErrorKind::Expected("math function token"))); } - Ok(CmykComponent::Function(self.parse()?)) + Ok(CmykComponent::Function( + self.with_ctx(Ctx { + block_contents_grammar: BlockContentsGrammar::DeclarationValue, + ..self.ctx + }) + .parse_as::()?, + )) } _ => { unreachable!() @@ -2678,7 +2875,13 @@ where modifiers.push(UrlModifier::Ident(self.parse()?)); } tok!("function") => { - modifiers.push(UrlModifier::Function(self.parse()?)); + modifiers.push(UrlModifier::Function( + self.with_ctx(Ctx { + block_contents_grammar: BlockContentsGrammar::DeclarationValue, + ..self.ctx + }) + .parse_as::()?, + )); } _ => { let span = self.input.cur_span(); @@ -3307,7 +3510,13 @@ where Ok(CalcValue::Sum(calc_sum_in_parens)) } - tok!("function") => Ok(CalcValue::Function(self.parse()?)), + tok!("function") => Ok(CalcValue::Function( + self.with_ctx(Ctx { + block_contents_grammar: BlockContentsGrammar::DeclarationValue, + ..self.ctx + }) + .parse_as::()?, + )), _ => { let span = self.input.cur_span(); diff --git a/crates/swc_css_parser/tests/fixture/csstree/1/output.json b/crates/swc_css_parser/tests/fixture/csstree/1/output.json index 60a4ac03d540..5bce9650a128 100644 --- a/crates/swc_css_parser/tests/fixture/csstree/1/output.json +++ b/crates/swc_css_parser/tests/fixture/csstree/1/output.json @@ -2331,7 +2331,7 @@ "type": "Declaration", "span": { "start": 815, - "end": 827, + "end": 850, "ctxt": 0 }, "name": { @@ -2346,102 +2346,103 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 826, - "end": 827, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 827, - "end": 828, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 828, - "end": 837, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "something", - "raw": "something" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 837, - "end": 838, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 838, - "end": 839, - "ctxt": 0 - }, - "token": { - "Delim": { - "value": "!" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 839, - "end": 848, + "end": 850, "ctxt": 0 }, - "token": { - "Ident": { - "value": "important", - "raw": "important" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 848, - "end": 849, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 826, + "end": 827, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": { - "WhiteSpace": { - "value": " " + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 827, + "end": 828, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 828, + "end": 837, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "something", + "raw": "something" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 837, + "end": 838, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 838, + "end": 839, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "!" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 839, + "end": 848, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "important", + "raw": "important" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 848, + "end": 849, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 849, - "end": 850, - "ctxt": 0 - }, - "token": "RBrace" + ] } ], "important": null @@ -2465,53 +2466,41 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 871, - "end": 872, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 872, - "end": 873, - "ctxt": 0 - }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 873, - "end": 874, - "ctxt": 0 - }, - "token": "RBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 874, "end": 875, "ctxt": 0 }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 875, - "end": 876, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 871, + "end": 872, + "ctxt": 0 + }, + "token": "LParen" }, - "token": { - "WhiteSpace": { - "value": " " + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 872, + "end": 874, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 872, + "end": 873, + "ctxt": 0 + }, + "token": "LBracket" + }, + "value": [] } - } + ] } ], "important": { diff --git a/crates/swc_css_parser/tests/fixture/csstree/1/span.rust-debug b/crates/swc_css_parser/tests/fixture/csstree/1/span.rust-debug index aefceb99a317..ff110b799468 100644 --- a/crates/swc_css_parser/tests/fixture/csstree/1/span.rust-debug +++ b/crates/swc_css_parser/tests/fixture/csstree/1/span.rust-debug @@ -2404,19 +2404,19 @@ x ComponentValue ,-[$DIR/tests/fixture/csstree/1/input.css:27:9] 27 | --custom1: { something !important }; - : ^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/csstree/1/input.css:27:9] 27 | --custom1: { something !important }; - : ^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/csstree/1/input.css:27:9] 27 | --custom1: { something !important }; - : ^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -2434,7 +2434,13 @@ x ComponentValue ,-[$DIR/tests/fixture/csstree/1/input.css:27:9] 27 | --custom1: { something !important }; - : ^ + : ^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/csstree/1/input.css:27:9] + 27 | --custom1: { something !important }; + : ^^^^^^^^^^^^^^^^^^^^^^^^ `---- x LBrace @@ -2515,18 +2521,6 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/csstree/1/input.css:27:9] - 27 | --custom1: { something !important }; - : ^ - `---- - - x RBrace - ,-[$DIR/tests/fixture/csstree/1/input.css:27:9] - 27 | --custom1: { something !important }; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] 28 | --custom2: ([]) !important; @@ -2560,61 +2554,37 @@ x ComponentValue ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] 28 | --custom2: ([]) !important; - : ^ - `---- - - x LParen - ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] - 28 | --custom2: ([]) !important; - : ^ - `---- - - x ComponentValue - ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] - 28 | --custom2: ([]) !important; - : ^ - `---- - - x LBracket - ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] - 28 | --custom2: ([]) !important; - : ^ + : ^^^^ `---- - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] 28 | --custom2: ([]) !important; - : ^ + : ^^^^ `---- - x RBracket + x LParen ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] 28 | --custom2: ([]) !important; - : ^ + : ^ `---- x ComponentValue ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] 28 | --custom2: ([]) !important; - : ^ + : ^^ `---- - x RParen - ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] - 28 | --custom2: ([]) !important; - : ^ - `---- - - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] 28 | --custom2: ([]) !important; - : ^ + : ^^ `---- - x WhiteSpace { value: Atom(' ' type=inline) } + x LBracket ,-[$DIR/tests/fixture/csstree/1/input.css:28:9] 28 | --custom2: ([]) !important; - : ^ + : ^ `---- x ImportantFlag diff --git a/crates/swc_css_parser/tests/fixture/function/calc/output.json b/crates/swc_css_parser/tests/fixture/function/calc/output.json index 16a6ba7703f0..620195d6a2d8 100644 --- a/crates/swc_css_parser/tests/fixture/function/calc/output.json +++ b/crates/swc_css_parser/tests/fixture/function/calc/output.json @@ -277,7 +277,7 @@ "type": "Declaration", "span": { "start": 55, - "end": 69, + "end": 80, "ctxt": 0 }, "name": { @@ -292,97 +292,94 @@ }, "value": [ { - "type": "PreservedToken", + "type": "Function", "span": { "start": 64, - "end": 69, - "ctxt": 0 - }, - "token": { - "Function": { - "value": "calc", - "raw": "calc" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 69, - "end": 72, - "ctxt": 0 - }, - "token": { - "Percentage": { - "value": 10.0, - "raw": "10" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 72, - "end": 73, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 73, - "end": 74, - "ctxt": 0 - }, - "token": { - "Delim": { - "value": "+" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 74, - "end": 75, + "end": 80, "ctxt": 0 }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 75, - "end": 79, - "ctxt": 0 + "name": { + "type": "Ident", + "span": { + "start": 64, + "end": 68, + "ctxt": 0 + }, + "value": "calc", + "raw": "calc" }, - "token": { - "Dimension": { - "value": 30.0, - "raw_value": "30", - "unit": "px", - "raw_unit": "px", - "type": "integer" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 69, + "end": 72, + "ctxt": 0 + }, + "token": { + "Percentage": { + "value": 10.0, + "raw": "10" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 72, + "end": 73, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 73, + "end": 74, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "+" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 74, + "end": 75, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 75, + "end": 79, + "ctxt": 0 + }, + "token": { + "Dimension": { + "value": 30.0, + "raw_value": "30", + "unit": "px", + "raw_unit": "px", + "type": "integer" + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 79, - "end": 80, - "ctxt": 0 - }, - "token": "RParen" + ] } ], "important": null diff --git a/crates/swc_css_parser/tests/fixture/function/calc/span.rust-debug b/crates/swc_css_parser/tests/fixture/function/calc/span.rust-debug index 47ac272ba108..bd60bc372ec0 100644 --- a/crates/swc_css_parser/tests/fixture/function/calc/span.rust-debug +++ b/crates/swc_css_parser/tests/fixture/function/calc/span.rust-debug @@ -497,19 +497,19 @@ x ComponentValue ,-[$DIR/tests/fixture/function/calc/input.css:6:5] 6 | --width: calc(10% + 30px); - : ^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/function/calc/input.css:6:5] 6 | --width: calc(10% + 30px); - : ^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/function/calc/input.css:6:5] 6 | --width: calc(10% + 30px); - : ^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -527,13 +527,19 @@ x ComponentValue ,-[$DIR/tests/fixture/function/calc/input.css:6:5] 6 | --width: calc(10% + 30px); - : ^^^^^ + : ^^^^^^^^^^^^^^^^ `---- - x Function { value: Atom('calc' type=static), raw: Atom('calc' type=static) } + x Function + ,-[$DIR/tests/fixture/function/calc/input.css:6:5] + 6 | --width: calc(10% + 30px); + : ^^^^^^^^^^^^^^^^ + `---- + + x Ident ,-[$DIR/tests/fixture/function/calc/input.css:6:5] 6 | --width: calc(10% + 30px); - : ^^^^^ + : ^^^^ `---- x ComponentValue @@ -596,18 +602,6 @@ : ^^^^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/function/calc/input.css:6:5] - 6 | --width: calc(10% + 30px); - : ^ - `---- - - x RParen - ,-[$DIR/tests/fixture/function/calc/input.css:6:5] - 6 | --width: calc(10% + 30px); - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/function/calc/input.css:8:5] 8 | width: calc(0px); diff --git a/crates/swc_css_parser/tests/fixture/rome/custom-properties/output.json b/crates/swc_css_parser/tests/fixture/rome/custom-properties/output.json index 600bbf1cd93f..1f7fc4cae200 100644 --- a/crates/swc_css_parser/tests/fixture/rome/custom-properties/output.json +++ b/crates/swc_css_parser/tests/fixture/rome/custom-properties/output.json @@ -372,7 +372,7 @@ "type": "Declaration", "span": { "start": 149, - "end": 165, + "end": 166, "ctxt": 0 }, "name": { @@ -387,27 +387,23 @@ }, "value": [ { - "type": "PreservedToken", + "type": "Function", "span": { "start": 161, - "end": 165, - "ctxt": 0 - }, - "token": { - "Function": { - "value": "foo", - "raw": "foo" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 165, "end": 166, "ctxt": 0 }, - "token": "RParen" + "name": { + "type": "Ident", + "span": { + "start": 161, + "end": 164, + "ctxt": 0 + }, + "value": "foo", + "raw": "foo" + }, + "value": [] } ], "important": null @@ -416,7 +412,7 @@ "type": "Declaration", "span": { "start": 169, - "end": 192, + "end": 198, "ctxt": 0 }, "name": { @@ -431,50 +427,43 @@ }, "value": [ { - "type": "PreservedToken", + "type": "Function", "span": { "start": 188, - "end": 192, + "end": 198, "ctxt": 0 }, - "token": { - "Function": { - "value": "foo", - "raw": "foo" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 192, - "end": 196, - "ctxt": 0 + "name": { + "type": "Ident", + "span": { + "start": 188, + "end": 191, + "ctxt": 0 + }, + "value": "foo", + "raw": "foo" }, - "token": { - "Function": { - "value": "bar", - "raw": "bar" + "value": [ + { + "type": "Function", + "span": { + "start": 192, + "end": 197, + "ctxt": 0 + }, + "name": { + "type": "Ident", + "span": { + "start": 192, + "end": 195, + "ctxt": 0 + }, + "value": "bar", + "raw": "bar" + }, + "value": [] } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 196, - "end": 197, - "ctxt": 0 - }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 197, - "end": 198, - "ctxt": 0 - }, - "token": "RParen" + ] } ], "important": null @@ -483,7 +472,7 @@ "type": "Declaration", "span": { "start": 201, - "end": 217, + "end": 219, "ctxt": 0 }, "name": { @@ -498,35 +487,36 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 216, - "end": 217, + "end": 219, "ctxt": 0 }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 217, - "end": 218, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 216, + "end": 217, + "ctxt": 0 + }, + "token": "LParen" }, - "token": { - "WhiteSpace": { - "value": " " + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 217, + "end": 218, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 218, - "end": 219, - "ctxt": 0 - }, - "token": "RParen" + ] } ], "important": null @@ -535,7 +525,7 @@ "type": "Declaration", "span": { "start": 222, - "end": 233, + "end": 235, "ctxt": 0 }, "name": { @@ -550,35 +540,36 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 232, - "end": 233, + "end": 235, "ctxt": 0 }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 233, - "end": 234, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 232, + "end": 233, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": { - "WhiteSpace": { - "value": " " + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 233, + "end": 234, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 234, - "end": 235, - "ctxt": 0 - }, - "token": "RBrace" + ] } ], "important": null @@ -587,7 +578,7 @@ "type": "Declaration", "span": { "start": 238, - "end": 251, + "end": 253, "ctxt": 0 }, "name": { @@ -602,35 +593,36 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 250, - "end": 251, + "end": 253, "ctxt": 0 }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 251, - "end": 252, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 250, + "end": 251, + "ctxt": 0 + }, + "token": "LBracket" }, - "token": { - "WhiteSpace": { - "value": " " + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 251, + "end": 252, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 252, - "end": 253, - "ctxt": 0 - }, - "token": "RBracket" + ] } ], "important": null @@ -709,7 +701,7 @@ "type": "Declaration", "span": { "start": 317, - "end": 352, + "end": 355, "ctxt": 0 }, "name": { @@ -751,22 +743,22 @@ } }, { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 353, - "end": 354, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 354, "end": 355, "ctxt": 0 }, - "token": "RBrace" + "name": { + "type": "PreservedToken", + "span": { + "start": 353, + "end": 354, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [] } ], "important": null @@ -775,7 +767,7 @@ "type": "Declaration", "span": { "start": 358, - "end": 390, + "end": 393, "ctxt": 0 }, "name": { @@ -817,22 +809,22 @@ } }, { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 391, - "end": 392, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 392, "end": 393, "ctxt": 0 }, - "token": "RBrace" + "name": { + "type": "PreservedToken", + "span": { + "start": 391, + "end": 392, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [] } ], "important": null @@ -901,7 +893,7 @@ "type": "Declaration", "span": { "start": 449, - "end": 471, + "end": 476, "ctxt": 0 }, "name": { @@ -916,31 +908,32 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 470, - "end": 471, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 471, - "end": 475, - "ctxt": 0 - }, - "token": "CDO" - }, - { - "type": "PreservedToken", - "span": { - "start": 475, "end": 476, "ctxt": 0 }, - "token": "RParen" + "name": { + "type": "PreservedToken", + "span": { + "start": 470, + "end": 471, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 471, + "end": 475, + "ctxt": 0 + }, + "token": "CDO" + } + ] } ], "important": null @@ -949,7 +942,7 @@ "type": "Declaration", "span": { "start": 479, - "end": 501, + "end": 505, "ctxt": 0 }, "name": { @@ -964,31 +957,32 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 500, - "end": 501, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 501, - "end": 504, - "ctxt": 0 - }, - "token": "CDC" - }, - { - "type": "PreservedToken", - "span": { - "start": 504, "end": 505, "ctxt": 0 }, - "token": "RParen" + "name": { + "type": "PreservedToken", + "span": { + "start": 500, + "end": 501, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 501, + "end": 504, + "ctxt": 0 + }, + "token": "CDC" + } + ] } ], "important": null diff --git a/crates/swc_css_parser/tests/fixture/rome/custom-properties/span.rust-debug b/crates/swc_css_parser/tests/fixture/rome/custom-properties/span.rust-debug index dca75d85661a..624008c2cbba 100644 --- a/crates/swc_css_parser/tests/fixture/rome/custom-properties/span.rust-debug +++ b/crates/swc_css_parser/tests/fixture/rome/custom-properties/span.rust-debug @@ -488,19 +488,19 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:10:5] 10 | --function: foo(); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:10:5] 10 | --function: foo(); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/rome/custom-properties/input.css:10:5] 10 | --function: foo(); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -518,43 +518,37 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:10:5] 10 | --function: foo(); - : ^^^^ + : ^^^^^ `---- - x Function { value: Atom('foo' type=inline), raw: Atom('foo' type=inline) } + x Function ,-[$DIR/tests/fixture/rome/custom-properties/input.css:10:5] 10 | --function: foo(); - : ^^^^ + : ^^^^^ `---- - x ComponentValue + x Ident ,-[$DIR/tests/fixture/rome/custom-properties/input.css:10:5] 10 | --function: foo(); - : ^ - `---- - - x RParen - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:10:5] - 10 | --function: foo(); - : ^ + : ^^^ `---- x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -572,67 +566,55 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^^^^ + : ^^^^^^^^^^ `---- - x Function { value: Atom('foo' type=inline), raw: Atom('foo' type=inline) } + x Function ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^^^^ + : ^^^^^^^^^^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] - 11 | --nested-function: foo(bar()); - : ^^^^ - `---- - - x Function { value: Atom('bar' type=inline), raw: Atom('bar' type=inline) } + x Ident ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^^^^ + : ^^^ `---- x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^ + : ^^^^^ `---- - x RParen - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] - 11 | --nested-function: foo(bar()); - : ^ - `---- - - x ComponentValue + x Function ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^ + : ^^^^^ `---- - x RParen + x Ident ,-[$DIR/tests/fixture/rome/custom-properties/input.css:11:5] 11 | --nested-function: foo(bar()); - : ^ + : ^^^ `---- x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:12:5] 12 | --parentheses: ( ); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:12:5] 12 | --parentheses: ( ); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/rome/custom-properties/input.css:12:5] 12 | --parentheses: ( ); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -650,7 +632,13 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:12:5] 12 | --parentheses: ( ); - : ^ + : ^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/rome/custom-properties/input.css:12:5] + 12 | --parentheses: ( ); + : ^^^ `---- x LParen @@ -671,34 +659,22 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:12:5] - 12 | --parentheses: ( ); - : ^ - `---- - - x RParen - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:12:5] - 12 | --parentheses: ( ); - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:13:5] 13 | --braces: { }; - : ^^^^^^^^^^^ + : ^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:13:5] 13 | --braces: { }; - : ^^^^^^^^^^^ + : ^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/rome/custom-properties/input.css:13:5] 13 | --braces: { }; - : ^^^^^^^^^^^ + : ^^^^^^^^^^^^^ `---- x DeclarationName @@ -716,7 +692,13 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:13:5] 13 | --braces: { }; - : ^ + : ^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/rome/custom-properties/input.css:13:5] + 13 | --braces: { }; + : ^^^ `---- x LBrace @@ -737,34 +719,22 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:13:5] - 13 | --braces: { }; - : ^ - `---- - - x RBrace - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:13:5] - 13 | --braces: { }; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:14:5] 14 | --brackets: [ ]; - : ^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:14:5] 14 | --brackets: [ ]; - : ^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/rome/custom-properties/input.css:14:5] 14 | --brackets: [ ]; - : ^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -782,7 +752,13 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:14:5] 14 | --brackets: [ ]; - : ^ + : ^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/rome/custom-properties/input.css:14:5] + 14 | --brackets: [ ]; + : ^^^ `---- x LBracket @@ -803,18 +779,6 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:14:5] - 14 | --brackets: [ ]; - : ^ - `---- - - x RBracket - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:14:5] - 14 | --brackets: [ ]; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:15:5] 15 | --at-keyword-unknown: @foobar; @@ -902,19 +866,19 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:17:5] 17 | --at-keyword-unknown-block: @foobar {}; - : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:17:5] 17 | --at-keyword-unknown-block: @foobar {}; - : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/rome/custom-properties/input.css:17:5] 17 | --at-keyword-unknown-block: @foobar {}; - : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -956,43 +920,37 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:17:5] 17 | --at-keyword-unknown-block: @foobar {}; - : ^ + : ^^ `---- - x LBrace - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:17:5] - 17 | --at-keyword-unknown-block: @foobar {}; - : ^ - `---- - - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:17:5] 17 | --at-keyword-unknown-block: @foobar {}; - : ^ + : ^^ `---- - x RBrace + x LBrace ,-[$DIR/tests/fixture/rome/custom-properties/input.css:17:5] 17 | --at-keyword-unknown-block: @foobar {}; - : ^ + : ^ `---- x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:18:5] 18 | --at-keyword-known-block: @media {}; - : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:18:5] 18 | --at-keyword-known-block: @media {}; - : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/rome/custom-properties/input.css:18:5] 18 | --at-keyword-known-block: @media {}; - : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1034,25 +992,19 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:18:5] 18 | --at-keyword-known-block: @media {}; - : ^ + : ^^ `---- - x LBrace - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:18:5] - 18 | --at-keyword-known-block: @media {}; - : ^ - `---- - - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:18:5] 18 | --at-keyword-known-block: @media {}; - : ^ + : ^^ `---- - x RBrace + x LBrace ,-[$DIR/tests/fixture/rome/custom-properties/input.css:18:5] 18 | --at-keyword-known-block: @media {}; - : ^ + : ^ `---- x ComponentValue @@ -1142,19 +1094,19 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:21:5] 21 | --cdo-not-top-level: (); - : ^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/rome/custom-properties/input.css:22:5] 22 | --cdc-not-top-level: (-->); - : ^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/rome/custom-properties/input.css:22:5] 22 | --cdc-not-top-level: (-->); - : ^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1238,7 +1184,13 @@ x ComponentValue ,-[$DIR/tests/fixture/rome/custom-properties/input.css:22:5] 22 | --cdc-not-top-level: (-->); - : ^ + : ^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/rome/custom-properties/input.css:22:5] + 22 | --cdc-not-top-level: (-->); + : ^^^^^ `---- x LParen @@ -1258,15 +1210,3 @@ 22 | --cdc-not-top-level: (-->); : ^^^ `---- - - x ComponentValue - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:22:5] - 22 | --cdc-not-top-level: (-->); - : ^ - `---- - - x RParen - ,-[$DIR/tests/fixture/rome/custom-properties/input.css:22:5] - 22 | --cdc-not-top-level: (-->); - : ^ - `---- diff --git a/crates/swc_css_parser/tests/fixture/style-block/output.json b/crates/swc_css_parser/tests/fixture/style-block/output.json index 97a2708e70c0..3ced83496c60 100644 --- a/crates/swc_css_parser/tests/fixture/style-block/output.json +++ b/crates/swc_css_parser/tests/fixture/style-block/output.json @@ -4037,7 +4037,7 @@ "type": "Declaration", "span": { "start": 1312, - "end": 1326, + "end": 1369, "ctxt": 0 }, "name": { @@ -4052,181 +4052,182 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 1325, - "end": 1326, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 1326, - "end": 1335, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1335, - "end": 1340, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "width", - "raw": "width" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1340, - "end": 1341, - "ctxt": 0 - }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 1341, - "end": 1342, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1342, - "end": 1343, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 0.0, - "raw": "0", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1343, - "end": 1344, - "ctxt": 0 - }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1344, - "end": 1353, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1353, - "end": 1359, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "height", - "raw": "height" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1359, - "end": 1360, - "ctxt": 0 - }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 1360, - "end": 1361, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1361, - "end": 1362, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 0.0, - "raw": "0", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1362, - "end": 1363, + "end": 1369, "ctxt": 0 }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1363, - "end": 1368, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 1325, + "end": 1326, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": { - "WhiteSpace": { - "value": "\n " + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 1326, + "end": 1335, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1335, + "end": 1340, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "width", + "raw": "width" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1340, + "end": 1341, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 1341, + "end": 1342, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1342, + "end": 1343, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 0.0, + "raw": "0", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1343, + "end": 1344, + "ctxt": 0 + }, + "token": "Semi" + }, + { + "type": "PreservedToken", + "span": { + "start": 1344, + "end": 1353, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1353, + "end": 1359, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "height", + "raw": "height" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1359, + "end": 1360, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 1360, + "end": 1361, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1361, + "end": 1362, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 0.0, + "raw": "0", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1362, + "end": 1363, + "ctxt": 0 + }, + "token": "Semi" + }, + { + "type": "PreservedToken", + "span": { + "start": 1363, + "end": 1368, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1368, - "end": 1369, - "ctxt": 0 - }, - "token": "RBrace" + ] } ], "important": null @@ -4235,7 +4236,7 @@ "type": "Declaration", "span": { "start": 1375, - "end": 1390, + "end": 1439, "ctxt": 0 }, "name": { @@ -4250,198 +4251,186 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 1389, - "end": 1390, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 1390, - "end": 1399, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1399, - "end": 1404, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "width", - "raw": "width" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1404, - "end": 1405, - "ctxt": 0 - }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 1405, - "end": 1406, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1406, - "end": 1410, - "ctxt": 0 - }, - "token": { - "Dimension": { - "value": 16.0, - "raw_value": "16", - "unit": "px", - "raw_unit": "px", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1410, - "end": 1411, - "ctxt": 0 - }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1411, - "end": 1420, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1420, - "end": 1426, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "height", - "raw": "height" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1426, - "end": 1427, - "ctxt": 0 - }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 1427, - "end": 1428, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1428, - "end": 1432, - "ctxt": 0 - }, - "token": { - "Dimension": { - "value": 16.0, - "raw_value": "16", - "unit": "px", - "raw_unit": "px", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1432, - "end": 1433, - "ctxt": 0 - }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1433, - "end": 1438, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1438, "end": 1439, "ctxt": 0 }, - "token": "RBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 1439, - "end": 1440, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 1389, + "end": 1390, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": { - "WhiteSpace": { - "value": "\n" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 1390, + "end": 1399, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1399, + "end": 1404, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "width", + "raw": "width" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1404, + "end": 1405, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 1405, + "end": 1406, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1406, + "end": 1410, + "ctxt": 0 + }, + "token": { + "Dimension": { + "value": 16.0, + "raw_value": "16", + "unit": "px", + "raw_unit": "px", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1410, + "end": 1411, + "ctxt": 0 + }, + "token": "Semi" + }, + { + "type": "PreservedToken", + "span": { + "start": 1411, + "end": 1420, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1420, + "end": 1426, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "height", + "raw": "height" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1426, + "end": 1427, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 1427, + "end": 1428, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1428, + "end": 1432, + "ctxt": 0 + }, + "token": { + "Dimension": { + "value": 16.0, + "raw_value": "16", + "unit": "px", + "raw_unit": "px", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1432, + "end": 1433, + "ctxt": 0 + }, + "token": "Semi" + }, + { + "type": "PreservedToken", + "span": { + "start": 1433, + "end": 1438, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } } - } + ] } ], "important": null diff --git a/crates/swc_css_parser/tests/fixture/style-block/span.rust-debug b/crates/swc_css_parser/tests/fixture/style-block/span.rust-debug index 98a25db4194a..843cb0e8a0b3 100644 --- a/crates/swc_css_parser/tests/fixture/style-block/span.rust-debug +++ b/crates/swc_css_parser/tests/fixture/style-block/span.rust-debug @@ -4346,20 +4346,26 @@ x ComponentValue ,-[$DIR/tests/fixture/style-block/input.css:106:5] - 106 | --zero-size: { - : ^^^^^^^^^^^^^^ + 106 | ,-> --zero-size: { + 107 | | width: 0; + 108 | | height: 0; + 109 | `-> }; `---- x StyleBlock ,-[$DIR/tests/fixture/style-block/input.css:106:5] - 106 | --zero-size: { - : ^^^^^^^^^^^^^^ + 106 | ,-> --zero-size: { + 107 | | width: 0; + 108 | | height: 0; + 109 | `-> }; `---- x Declaration ,-[$DIR/tests/fixture/style-block/input.css:106:5] - 106 | --zero-size: { - : ^^^^^^^^^^^^^^ + 106 | ,-> --zero-size: { + 107 | | width: 0; + 108 | | height: 0; + 109 | `-> }; `---- x DeclarationName @@ -4376,8 +4382,18 @@ x ComponentValue ,-[$DIR/tests/fixture/style-block/input.css:106:5] - 106 | --zero-size: { - : ^ + 106 | ,-> --zero-size: { + 107 | | width: 0; + 108 | | height: 0; + 109 | `-> }; + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/style-block/input.css:106:5] + 106 | ,-> --zero-size: { + 107 | | width: 0; + 108 | | height: 0; + 109 | `-> }; `---- x LBrace @@ -4545,34 +4561,28 @@ 109 | `-> }; `---- - x ComponentValue - ,-[$DIR/tests/fixture/style-block/input.css:109:5] - 109 | }; - : ^ - `---- - - x RBrace - ,-[$DIR/tests/fixture/style-block/input.css:109:5] - 109 | }; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/style-block/input.css:110:5] - 110 | --small-icon: { - : ^^^^^^^^^^^^^^^ + 110 | ,-> --small-icon: { + 111 | | width: 16px; + 112 | | height: 16px; + 113 | `-> } `---- x StyleBlock ,-[$DIR/tests/fixture/style-block/input.css:110:5] - 110 | --small-icon: { - : ^^^^^^^^^^^^^^^ + 110 | ,-> --small-icon: { + 111 | | width: 16px; + 112 | | height: 16px; + 113 | `-> } `---- x Declaration ,-[$DIR/tests/fixture/style-block/input.css:110:5] - 110 | --small-icon: { - : ^^^^^^^^^^^^^^^ + 110 | ,-> --small-icon: { + 111 | | width: 16px; + 112 | | height: 16px; + 113 | `-> } `---- x DeclarationName @@ -4589,8 +4599,18 @@ x ComponentValue ,-[$DIR/tests/fixture/style-block/input.css:110:5] - 110 | --small-icon: { - : ^ + 110 | ,-> --small-icon: { + 111 | | width: 16px; + 112 | | height: 16px; + 113 | `-> } + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/style-block/input.css:110:5] + 110 | ,-> --small-icon: { + 111 | | width: 16px; + 112 | | height: 16px; + 113 | `-> } `---- x LBrace @@ -4757,30 +4777,3 @@ 112 | ,-> height: 16px; 113 | `-> } `---- - - x ComponentValue - ,-[$DIR/tests/fixture/style-block/input.css:113:5] - 113 | } - : ^ - `---- - - x RBrace - ,-[$DIR/tests/fixture/style-block/input.css:113:5] - 113 | } - : ^ - `---- - - x ComponentValue - ,-[$DIR/tests/fixture/style-block/input.css:113:5] - 113 | } - : ^ - 114 | ; - `---- - - x WhiteSpace { value: Atom(' - | ' type=inline) } - ,-[$DIR/tests/fixture/style-block/input.css:113:5] - 113 | } - : ^ - 114 | ; - `---- diff --git a/crates/swc_css_parser/tests/fixture/value/custom-property/output.json b/crates/swc_css_parser/tests/fixture/value/custom-property/output.json index 4459013c2b48..ebeed8a1c6eb 100644 --- a/crates/swc_css_parser/tests/fixture/value/custom-property/output.json +++ b/crates/swc_css_parser/tests/fixture/value/custom-property/output.json @@ -251,19 +251,6 @@ "raw": "value" } } - }, - { - "type": "PreservedToken", - "span": { - "start": 116, - "end": 117, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } } ], "important": { @@ -316,19 +303,6 @@ "raw": "value" } } - }, - { - "type": "PreservedToken", - "span": { - "start": 151, - "end": 152, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } } ], "important": { @@ -369,42 +343,39 @@ }, "value": [ { - "type": "PreservedToken", + "type": "Function", "span": { "start": 182, - "end": 187, + "end": 189, "ctxt": 0 }, - "token": { - "Function": { - "value": "calc", - "raw": "calc" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 187, - "end": 188, - "ctxt": 0 + "name": { + "type": "Ident", + "span": { + "start": 182, + "end": 186, + "ctxt": 0 + }, + "value": "calc", + "raw": "calc" }, - "token": { - "Number": { - "value": 1.0, - "raw": "1", - "type": "integer" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 187, + "end": 188, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 1.0, + "raw": "1", + "type": "integer" + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 188, - "end": 189, - "ctxt": 0 - }, - "token": "RParen" + ] } ], "important": { @@ -709,7 +680,7 @@ "type": "Declaration", "span": { "start": 411, - "end": 428, + "end": 434, "ctxt": 0 }, "name": { @@ -724,96 +695,93 @@ }, "value": [ { - "type": "PreservedToken", + "type": "Function", "span": { "start": 423, - "end": 428, - "ctxt": 0 - }, - "token": { - "Function": { - "value": "calc", - "raw": "calc" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 428, - "end": 429, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 1.0, - "raw": "1", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 429, - "end": 430, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 430, - "end": 431, - "ctxt": 0 - }, - "token": { - "Delim": { - "value": "+" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 431, - "end": 432, + "end": 434, "ctxt": 0 }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 432, - "end": 433, - "ctxt": 0 + "name": { + "type": "Ident", + "span": { + "start": 423, + "end": 427, + "ctxt": 0 + }, + "value": "calc", + "raw": "calc" }, - "token": { - "Number": { - "value": 1.0, - "raw": "1", - "type": "integer" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 428, + "end": 429, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 1.0, + "raw": "1", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 429, + "end": 430, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 430, + "end": 431, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "+" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 431, + "end": 432, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 432, + "end": 433, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 1.0, + "raw": "1", + "type": "integer" + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 433, - "end": 434, - "ctxt": 0 - }, - "token": "RParen" + ] } ], "important": null @@ -822,7 +790,7 @@ "type": "Declaration", "span": { "start": 440, - "end": 456, + "end": 463, "ctxt": 0 }, "name": { @@ -837,41 +805,38 @@ }, "value": [ { - "type": "PreservedToken", + "type": "Function", "span": { "start": 452, - "end": 456, + "end": 463, "ctxt": 0 }, - "token": { - "Function": { - "value": "var", - "raw": "var" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 456, - "end": 462, - "ctxt": 0 + "name": { + "type": "Ident", + "span": { + "start": 452, + "end": 455, + "ctxt": 0 + }, + "value": "var", + "raw": "var" }, - "token": { - "Ident": { - "value": "--unit", - "raw": "--unit" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 456, + "end": 462, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "--unit", + "raw": "--unit" + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 462, - "end": 463, - "ctxt": 0 - }, - "token": "RParen" + ] } ], "important": null @@ -950,7 +915,7 @@ "type": "Declaration", "span": { "start": 547, - "end": 564, + "end": 572, "ctxt": 0 }, "name": { @@ -965,189 +930,190 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 563, - "end": 564, + "end": 572, "ctxt": 0 }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 564, - "end": 565, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 563, + "end": 564, + "ctxt": 0 + }, + "token": "LBracket" }, - "token": { - "Number": { - "value": 1.0, - "raw": "1", - "type": "integer" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 564, + "end": 565, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 1.0, + "raw": "1", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 565, + "end": 566, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 566, + "end": 567, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 567, + "end": 568, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 2.0, + "raw": "2", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 568, + "end": 569, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 569, + "end": 570, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 570, + "end": 571, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 3.0, + "raw": "3", + "type": "integer" + } + } } - } + ] + } + ], + "important": null + }, + { + "type": "Declaration", + "span": { + "start": 578, + "end": 597, + "ctxt": 0 + }, + "name": { + "type": "DashedIdent", + "span": { + "start": 578, + "end": 593, + "ctxt": 0 }, + "value": "square-block1", + "raw": "--square-block1" + }, + "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 565, - "end": 566, + "start": 595, + "end": 597, "ctxt": 0 }, - "token": "Comma" + "name": { + "type": "PreservedToken", + "span": { + "start": 595, + "end": 596, + "ctxt": 0 + }, + "token": "LBracket" + }, + "value": [] + } + ], + "important": null + }, + { + "type": "Declaration", + "span": { + "start": 603, + "end": 621, + "ctxt": 0 + }, + "name": { + "type": "DashedIdent", + "span": { + "start": 603, + "end": 618, + "ctxt": 0 }, + "value": "square-block2", + "raw": "--square-block2" + }, + "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 566, - "end": 567, + "start": 619, + "end": 621, "ctxt": 0 }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 567, - "end": 568, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 2.0, - "raw": "2", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 568, - "end": 569, - "ctxt": 0 - }, - "token": "Comma" - }, - { - "type": "PreservedToken", - "span": { - "start": 569, - "end": 570, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 570, - "end": 571, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 3.0, - "raw": "3", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 571, - "end": 572, - "ctxt": 0 - }, - "token": "RBracket" - } - ], - "important": null - }, - { - "type": "Declaration", - "span": { - "start": 578, - "end": 596, - "ctxt": 0 - }, - "name": { - "type": "DashedIdent", - "span": { - "start": 578, - "end": 593, - "ctxt": 0 - }, - "value": "square-block1", - "raw": "--square-block1" - }, - "value": [ - { - "type": "PreservedToken", - "span": { - "start": 595, - "end": 596, - "ctxt": 0 - }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 596, - "end": 597, - "ctxt": 0 - }, - "token": "RBracket" - } - ], - "important": null - }, - { - "type": "Declaration", - "span": { - "start": 603, - "end": 620, - "ctxt": 0 - }, - "name": { - "type": "DashedIdent", - "span": { - "start": 603, - "end": 618, - "ctxt": 0 - }, - "value": "square-block2", - "raw": "--square-block2" - }, - "value": [ - { - "type": "PreservedToken", - "span": { - "start": 619, - "end": 620, - "ctxt": 0 - }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 620, - "end": 621, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 619, + "end": 620, + "ctxt": 0 + }, + "token": "LBracket" }, - "token": "RBracket" + "value": [] } ], "important": null @@ -1156,7 +1122,7 @@ "type": "Declaration", "span": { "start": 627, - "end": 643, + "end": 651, "ctxt": 0 }, "name": { @@ -1171,111 +1137,112 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 642, - "end": 643, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 643, - "end": 644, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 1.0, - "raw": "1", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 644, - "end": 645, - "ctxt": 0 - }, - "token": "Comma" - }, - { - "type": "PreservedToken", - "span": { - "start": 645, - "end": 646, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 646, - "end": 647, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 2.0, - "raw": "2", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 647, - "end": 648, - "ctxt": 0 - }, - "token": "Comma" - }, - { - "type": "PreservedToken", - "span": { - "start": 648, - "end": 649, + "end": 651, "ctxt": 0 }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 649, - "end": 650, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 642, + "end": 643, + "ctxt": 0 + }, + "token": "LParen" }, - "token": { - "Number": { - "value": 3.0, - "raw": "3", - "type": "integer" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 643, + "end": 644, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 1.0, + "raw": "1", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 644, + "end": 645, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 645, + "end": 646, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 646, + "end": 647, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 2.0, + "raw": "2", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 647, + "end": 648, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 648, + "end": 649, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 649, + "end": 650, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 3.0, + "raw": "3", + "type": "integer" + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 650, - "end": 651, - "ctxt": 0 - }, - "token": "RParen" + ] } ], "important": null @@ -1284,7 +1251,7 @@ "type": "Declaration", "span": { "start": 657, - "end": 674, + "end": 675, "ctxt": 0 }, "name": { @@ -1299,22 +1266,22 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 673, - "end": 674, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 674, "end": 675, "ctxt": 0 }, - "token": "RParen" + "name": { + "type": "PreservedToken", + "span": { + "start": 673, + "end": 674, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [] } ], "important": null @@ -1323,7 +1290,7 @@ "type": "Declaration", "span": { "start": 681, - "end": 697, + "end": 698, "ctxt": 0 }, "name": { @@ -1338,22 +1305,22 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 696, - "end": 697, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 697, "end": 698, "ctxt": 0 }, - "token": "RParen" + "name": { + "type": "PreservedToken", + "span": { + "start": 696, + "end": 697, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [] } ], "important": null @@ -1362,7 +1329,7 @@ "type": "Declaration", "span": { "start": 704, - "end": 722, + "end": 730, "ctxt": 0 }, "name": { @@ -1377,111 +1344,112 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 721, - "end": 722, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 722, - "end": 723, + "end": 730, "ctxt": 0 }, - "token": { - "Number": { - "value": 1.0, - "raw": "1", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 723, - "end": 724, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 721, + "end": 722, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": "Comma" - }, - { - "type": "PreservedToken", - "span": { - "start": 724, - "end": 725, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 725, - "end": 726, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 2.0, - "raw": "2", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 726, - "end": 727, - "ctxt": 0 - }, - "token": "Comma" - }, - { - "type": "PreservedToken", - "span": { - "start": 727, - "end": 728, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 728, - "end": 729, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 3.0, - "raw": "3", - "type": "integer" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 722, + "end": 723, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 1.0, + "raw": "1", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 723, + "end": 724, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 724, + "end": 725, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 725, + "end": 726, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 2.0, + "raw": "2", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 726, + "end": 727, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 727, + "end": 728, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 728, + "end": 729, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 3.0, + "raw": "3", + "type": "integer" + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 729, - "end": 730, - "ctxt": 0 - }, - "token": "RBrace" + ] } ], "important": null @@ -1490,7 +1458,7 @@ "type": "Declaration", "span": { "start": 736, - "end": 755, + "end": 756, "ctxt": 0 }, "name": { @@ -1505,22 +1473,22 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 754, - "end": 755, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 755, "end": 756, "ctxt": 0 }, - "token": "RBrace" + "name": { + "type": "PreservedToken", + "span": { + "start": 754, + "end": 755, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [] } ], "important": null @@ -1529,7 +1497,7 @@ "type": "Declaration", "span": { "start": 762, - "end": 780, + "end": 781, "ctxt": 0 }, "name": { @@ -1544,22 +1512,22 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 779, - "end": 780, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 780, "end": 781, "ctxt": 0 }, - "token": "RBrace" + "name": { + "type": "PreservedToken", + "span": { + "start": 779, + "end": 780, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [] } ], "important": null @@ -1568,7 +1536,7 @@ "type": "Declaration", "span": { "start": 789, - "end": 798, + "end": 830, "ctxt": 0 }, "name": { @@ -1583,43 +1551,325 @@ }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { "start": 797, - "end": 798, + "end": 830, "ctxt": 0 }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 798, - "end": 799, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 797, + "end": 798, + "ctxt": 0 + }, + "token": "LBracket" }, - "token": { - "Number": { - "value": 1.0, - "raw": "1", - "type": "integer" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 798, + "end": 799, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 1.0, + "raw": "1", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 799, + "end": 800, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 800, + "end": 801, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 801, + "end": 804, + "ctxt": 0 + }, + "token": { + "String": { + "value": "2", + "raw": "\"2\"" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 804, + "end": 805, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 805, + "end": 806, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "SimpleBlock", + "span": { + "start": 806, + "end": 824, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 806, + "end": 807, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 807, + "end": 814, + "ctxt": 0 + }, + "token": { + "String": { + "value": "three", + "raw": "\"three\"" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 814, + "end": 815, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 815, + "end": 816, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "SimpleBlock", + "span": { + "start": 816, + "end": 823, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 816, + "end": 817, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 817, + "end": 820, + "ctxt": 0 + }, + "token": { + "String": { + "value": "a", + "raw": "\"a\"" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 820, + "end": 821, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 821, + "end": 822, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 1.0, + "raw": "1", + "type": "integer" + } + } + } + ] + } + ] + }, + { + "type": "PreservedToken", + "span": { + "start": 824, + "end": 825, + "ctxt": 0 + }, + "token": "Comma" + }, + { + "type": "PreservedToken", + "span": { + "start": 825, + "end": 826, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "SimpleBlock", + "span": { + "start": 826, + "end": 829, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 826, + "end": 827, + "ctxt": 0 + }, + "token": "LBracket" + }, + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 827, + "end": 828, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 4.0, + "raw": "4", + "type": "integer" + } + } + } + ] } - } + ] + } + ], + "important": null + }, + { + "type": "Declaration", + "span": { + "start": 836, + "end": 886, + "ctxt": 0 + }, + "name": { + "type": "DashedIdent", + "span": { + "start": 836, + "end": 848, + "ctxt": 0 }, + "value": "javascript", + "raw": "--javascript" + }, + "value": [ { - "type": "PreservedToken", + "type": "Function", "span": { - "start": 799, - "end": 800, + "start": 850, + "end": 864, "ctxt": 0 }, - "token": "Comma" + "name": { + "type": "Ident", + "span": { + "start": 850, + "end": 858, + "ctxt": 0 + }, + "value": "function", + "raw": "function" + }, + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 859, + "end": 863, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "rule", + "raw": "rule" + } + } + } + ] }, { "type": "PreservedToken", "span": { - "start": 800, - "end": 801, + "start": 864, + "end": 865, "ctxt": 0 }, "token": { @@ -1629,214 +1879,586 @@ } }, { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 801, - "end": 804, + "start": 865, + "end": 886, "ctxt": 0 }, - "token": { - "String": { - "value": "2", - "raw": "\"2\"" + "name": { + "type": "PreservedToken", + "span": { + "start": 865, + "end": 866, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 866, + "end": 867, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 867, + "end": 874, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "console", + "raw": "console" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 874, + "end": 875, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "." + } + } + }, + { + "type": "Function", + "span": { + "start": 875, + "end": 884, + "ctxt": 0 + }, + "name": { + "type": "Ident", + "span": { + "start": 875, + "end": 878, + "ctxt": 0 + }, + "value": "log", + "raw": "log" + }, + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 879, + "end": 883, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "rule", + "raw": "rule" + } + } + } + ] + }, + { + "type": "PreservedToken", + "span": { + "start": 884, + "end": 885, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } } - } + ] + } + ], + "important": null + }, + { + "type": "Declaration", + "span": { + "start": 893, + "end": 904, + "ctxt": 0 + }, + "name": { + "type": "DashedIdent", + "span": { + "start": 893, + "end": 898, + "ctxt": 0 }, + "value": "CDO", + "raw": "--CDO" + }, + "value": [ { "type": "PreservedToken", "span": { - "start": 804, - "end": 805, + "start": 900, + "end": 904, "ctxt": 0 }, - "token": "Comma" - }, - { - "type": "PreservedToken", - "span": { - "start": 805, - "end": 806, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 806, - "end": 807, - "ctxt": 0 - }, - "token": "LBrace" + "token": "CDO" + } + ], + "important": null + }, + { + "type": "Declaration", + "span": { + "start": 910, + "end": 920, + "ctxt": 0 + }, + "name": { + "type": "DashedIdent", + "span": { + "start": 910, + "end": 915, + "ctxt": 0 }, + "value": "CDC", + "raw": "--CDC" + }, + "value": [ { "type": "PreservedToken", "span": { - "start": 807, - "end": 814, + "start": 917, + "end": 920, "ctxt": 0 }, - "token": { - "String": { - "value": "three", - "raw": "\"three\"" - } - } + "token": "CDC" + } + ], + "important": null + }, + { + "type": "Declaration", + "span": { + "start": 927, + "end": 976, + "ctxt": 0 + }, + "name": { + "type": "DashedIdent", + "span": { + "start": 927, + "end": 945, + "ctxt": 0 }, + "value": "complex-balanced", + "raw": "--complex-balanced" + }, + "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 814, - "end": 815, + "start": 946, + "end": 966, "ctxt": 0 }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 815, - "end": 816, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 946, + "end": 947, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": { - "WhiteSpace": { - "value": " " + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 947, + "end": 965, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 947, + "end": 948, + "ctxt": 0 + }, + "token": "LBracket" + }, + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 948, + "end": 954, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 948, + "end": 949, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 949, + "end": 953, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 949, + "end": 950, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 950, + "end": 952, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 950, + "end": 951, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [] + } + ] + } + ] + }, + { + "type": "SimpleBlock", + "span": { + "start": 954, + "end": 956, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 954, + "end": 955, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [] + }, + { + "type": "SimpleBlock", + "span": { + "start": 956, + "end": 958, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 956, + "end": 957, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [] + }, + { + "type": "SimpleBlock", + "span": { + "start": 958, + "end": 964, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 958, + "end": 959, + "ctxt": 0 + }, + "token": "LBracket" + }, + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 959, + "end": 963, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 959, + "end": 960, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 960, + "end": 962, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 960, + "end": 961, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [] + } + ] + } + ] + } + ] } - } + ] }, { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 816, - "end": 817, + "start": 966, + "end": 972, "ctxt": 0 }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 817, - "end": 820, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 966, + "end": 967, + "ctxt": 0 + }, + "token": "LBracket" }, - "token": { - "String": { - "value": "a", - "raw": "\"a\"" + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 967, + "end": 971, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 967, + "end": 968, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 968, + "end": 970, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 968, + "end": 969, + "ctxt": 0 + }, + "token": "LParen" + }, + "value": [] + } + ] } - } + ] }, { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 820, - "end": 821, + "start": 972, + "end": 976, "ctxt": 0 }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 821, - "end": 822, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 972, + "end": 973, + "ctxt": 0 + }, + "token": "LParen" }, - "token": { - "Number": { - "value": 1.0, - "raw": "1", - "type": "integer" + "value": [ + { + "type": "SimpleBlock", + "span": { + "start": 973, + "end": 975, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 973, + "end": 974, + "ctxt": 0 + }, + "token": "LBracket" + }, + "value": [] } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 822, - "end": 823, - "ctxt": 0 - }, - "token": "RBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 823, - "end": 824, - "ctxt": 0 - }, - "token": "RBrace" + ] + } + ], + "important": null + }, + { + "type": "Declaration", + "span": { + "start": 982, + "end": 1011, + "ctxt": 0 + }, + "name": { + "type": "DashedIdent", + "span": { + "start": 982, + "end": 998, + "ctxt": 0 }, + "value": "fake-important", + "raw": "--fake-important" + }, + "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 824, - "end": 825, + "start": 999, + "end": 1011, "ctxt": 0 }, - "token": "Comma" - }, - { - "type": "PreservedToken", - "span": { - "start": 825, - "end": 826, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 999, + "end": 1000, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": { - "WhiteSpace": { - "value": " " + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 1000, + "end": 1001, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "!" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1001, + "end": 1010, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "important", + "raw": "important" + } + } } - } + ] + } + ], + "important": null + }, + { + "type": "Declaration", + "span": { + "start": 1017, + "end": 1047, + "ctxt": 0 + }, + "name": { + "type": "DashedIdent", + "span": { + "start": 1017, + "end": 1042, + "ctxt": 0 }, + "value": "semicolon-not-top-level", + "raw": "--semicolon-not-top-level" + }, + "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 826, - "end": 827, + "start": 1044, + "end": 1047, "ctxt": 0 }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 827, - "end": 828, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 1044, + "end": 1045, + "ctxt": 0 + }, + "token": "LParen" }, - "token": { - "Number": { - "value": 4.0, - "raw": "4", - "type": "integer" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 1045, + "end": 1046, + "ctxt": 0 + }, + "token": "Semi" } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 828, - "end": 829, - "ctxt": 0 - }, - "token": "RBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 829, - "end": 830, - "ctxt": 0 - }, - "token": "RBracket" + ] } ], "important": null @@ -1844,178 +2466,52 @@ { "type": "Declaration", "span": { - "start": 836, - "end": 859, + "start": 1053, + "end": 1079, "ctxt": 0 }, "name": { "type": "DashedIdent", "span": { - "start": 836, - "end": 848, + "start": 1053, + "end": 1074, "ctxt": 0 }, - "value": "javascript", - "raw": "--javascript" + "value": "delim-not-top-level", + "raw": "--delim-not-top-level" }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 850, - "end": 859, + "start": 1076, + "end": 1079, "ctxt": 0 }, - "token": { - "Function": { - "value": "function", - "raw": "function" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 859, - "end": 863, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "rule", - "raw": "rule" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 863, - "end": 864, - "ctxt": 0 - }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 864, - "end": 865, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 865, - "end": 866, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 866, - "end": 867, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 867, - "end": 874, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "console", - "raw": "console" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 874, - "end": 875, - "ctxt": 0 - }, - "token": { - "Delim": { - "value": "." - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 875, - "end": 879, - "ctxt": 0 - }, - "token": { - "Function": { - "value": "log", - "raw": "log" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 879, - "end": 883, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "rule", - "raw": "rule" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 883, - "end": 884, - "ctxt": 0 - }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 884, - "end": 885, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 1076, + "end": 1077, + "ctxt": 0 + }, + "token": "LParen" }, - "token": { - "WhiteSpace": { - "value": " " + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 1077, + "end": 1078, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "!" + } + } } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 885, - "end": 886, - "ctxt": 0 - }, - "token": "RBrace" + ] } ], "important": null @@ -2023,59 +2519,198 @@ { "type": "Declaration", "span": { - "start": 893, - "end": 904, + "start": 1085, + "end": 1142, "ctxt": 0 }, "name": { "type": "DashedIdent", "span": { - "start": 893, - "end": 898, + "start": 1085, + "end": 1096, "ctxt": 0 }, - "value": "CDO", - "raw": "--CDO" + "value": "zero-size", + "raw": "--zero-size" }, "value": [ { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 900, - "end": 904, + "start": 1098, + "end": 1142, "ctxt": 0 }, - "token": "CDO" - } - ], - "important": null - }, - { - "type": "Declaration", - "span": { - "start": 910, - "end": 920, - "ctxt": 0 - }, - "name": { - "type": "DashedIdent", - "span": { - "start": 910, - "end": 915, - "ctxt": 0 - }, - "value": "CDC", - "raw": "--CDC" - }, - "value": [ - { - "type": "PreservedToken", - "span": { - "start": 917, - "end": 920, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 1098, + "end": 1099, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": "CDC" + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 1099, + "end": 1108, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1108, + "end": 1113, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "width", + "raw": "width" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1113, + "end": 1114, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 1114, + "end": 1115, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1115, + "end": 1116, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 0.0, + "raw": "0", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1116, + "end": 1117, + "ctxt": 0 + }, + "token": "Semi" + }, + { + "type": "PreservedToken", + "span": { + "start": 1117, + "end": 1126, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1126, + "end": 1132, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "height", + "raw": "height" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1132, + "end": 1133, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 1133, + "end": 1134, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1134, + "end": 1135, + "ctxt": 0 + }, + "token": { + "Number": { + "value": 0.0, + "raw": "0", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1135, + "end": 1136, + "ctxt": 0 + }, + "token": "Semi" + }, + { + "type": "PreservedToken", + "span": { + "start": 1136, + "end": 1141, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + } + ] } ], "important": null @@ -2083,869 +2718,202 @@ { "type": "Declaration", "span": { - "start": 927, - "end": 947, + "start": 1148, + "end": 1212, "ctxt": 0 }, "name": { "type": "DashedIdent", "span": { - "start": 927, - "end": 945, + "start": 1148, + "end": 1160, "ctxt": 0 }, - "value": "complex-balanced", - "raw": "--complex-balanced" + "value": "small-icon", + "raw": "--small-icon" }, "value": [ { - "type": "PreservedToken", - "span": { - "start": 946, - "end": 947, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 947, - "end": 948, - "ctxt": 0 - }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 948, - "end": 949, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 949, - "end": 950, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", + "type": "SimpleBlock", "span": { - "start": 950, - "end": 951, + "start": 1162, + "end": 1212, "ctxt": 0 }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 951, - "end": 952, - "ctxt": 0 + "name": { + "type": "PreservedToken", + "span": { + "start": 1162, + "end": 1163, + "ctxt": 0 + }, + "token": "LBrace" }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 952, - "end": 953, - "ctxt": 0 - }, - "token": "RBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 953, - "end": 954, - "ctxt": 0 - }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 954, - "end": 955, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 955, - "end": 956, - "ctxt": 0 - }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 956, - "end": 957, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 957, - "end": 958, - "ctxt": 0 - }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 958, - "end": 959, - "ctxt": 0 - }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 959, - "end": 960, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 960, - "end": 961, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 961, - "end": 962, - "ctxt": 0 - }, - "token": "RBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 962, - "end": 963, - "ctxt": 0 - }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 963, - "end": 964, - "ctxt": 0 - }, - "token": "RBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 964, - "end": 965, - "ctxt": 0 - }, - "token": "RBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 965, - "end": 966, - "ctxt": 0 - }, - "token": "RBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 966, - "end": 967, - "ctxt": 0 - }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 967, - "end": 968, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 968, - "end": 969, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 969, - "end": 970, - "ctxt": 0 - }, - "token": "RParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 970, - "end": 971, - "ctxt": 0 - }, - "token": "RBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 971, - "end": 972, - "ctxt": 0 - }, - "token": "RBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 972, - "end": 973, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 973, - "end": 974, - "ctxt": 0 - }, - "token": "LBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 974, - "end": 975, - "ctxt": 0 - }, - "token": "RBracket" - }, - { - "type": "PreservedToken", - "span": { - "start": 975, - "end": 976, - "ctxt": 0 - }, - "token": "RParen" - } - ], - "important": null - }, - { - "type": "Declaration", - "span": { - "start": 982, - "end": 1000, - "ctxt": 0 - }, - "name": { - "type": "DashedIdent", - "span": { - "start": 982, - "end": 998, - "ctxt": 0 - }, - "value": "fake-important", - "raw": "--fake-important" - }, - "value": [ - { - "type": "PreservedToken", - "span": { - "start": 999, - "end": 1000, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 1000, - "end": 1001, - "ctxt": 0 - }, - "token": { - "Delim": { - "value": "!" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1001, - "end": 1010, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "important", - "raw": "important" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1010, - "end": 1011, - "ctxt": 0 - }, - "token": "RBrace" - } - ], - "important": null - }, - { - "type": "Declaration", - "span": { - "start": 1017, - "end": 1045, - "ctxt": 0 - }, - "name": { - "type": "DashedIdent", - "span": { - "start": 1017, - "end": 1042, - "ctxt": 0 - }, - "value": "semicolon-not-top-level", - "raw": "--semicolon-not-top-level" - }, - "value": [ - { - "type": "PreservedToken", - "span": { - "start": 1044, - "end": 1045, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 1045, - "end": 1046, - "ctxt": 0 - }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1046, - "end": 1047, - "ctxt": 0 - }, - "token": "RParen" - } - ], - "important": null - }, - { - "type": "Declaration", - "span": { - "start": 1053, - "end": 1077, - "ctxt": 0 - }, - "name": { - "type": "DashedIdent", - "span": { - "start": 1053, - "end": 1074, - "ctxt": 0 - }, - "value": "delim-not-top-level", - "raw": "--delim-not-top-level" - }, - "value": [ - { - "type": "PreservedToken", - "span": { - "start": 1076, - "end": 1077, - "ctxt": 0 - }, - "token": "LParen" - }, - { - "type": "PreservedToken", - "span": { - "start": 1077, - "end": 1078, - "ctxt": 0 - }, - "token": { - "Delim": { - "value": "!" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1078, - "end": 1079, - "ctxt": 0 - }, - "token": "RParen" - } - ], - "important": null - }, - { - "type": "Declaration", - "span": { - "start": 1085, - "end": 1099, - "ctxt": 0 - }, - "name": { - "type": "DashedIdent", - "span": { - "start": 1085, - "end": 1096, - "ctxt": 0 - }, - "value": "zero-size", - "raw": "--zero-size" - }, - "value": [ - { - "type": "PreservedToken", - "span": { - "start": 1098, - "end": 1099, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 1099, - "end": 1108, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1108, - "end": 1113, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "width", - "raw": "width" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1113, - "end": 1114, - "ctxt": 0 - }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 1114, - "end": 1115, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1115, - "end": 1116, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 0.0, - "raw": "0", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1116, - "end": 1117, - "ctxt": 0 - }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1117, - "end": 1126, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1126, - "end": 1132, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "height", - "raw": "height" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1132, - "end": 1133, - "ctxt": 0 - }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 1133, - "end": 1134, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1134, - "end": 1135, - "ctxt": 0 - }, - "token": { - "Number": { - "value": 0.0, - "raw": "0", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1135, - "end": 1136, - "ctxt": 0 - }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1136, - "end": 1141, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1141, - "end": 1142, - "ctxt": 0 - }, - "token": "RBrace" - } - ], - "important": null - }, - { - "type": "Declaration", - "span": { - "start": 1148, - "end": 1163, - "ctxt": 0 - }, - "name": { - "type": "DashedIdent", - "span": { - "start": 1148, - "end": 1160, - "ctxt": 0 - }, - "value": "small-icon", - "raw": "--small-icon" - }, - "value": [ - { - "type": "PreservedToken", - "span": { - "start": 1162, - "end": 1163, - "ctxt": 0 - }, - "token": "LBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 1163, - "end": 1172, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1172, - "end": 1177, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "width", - "raw": "width" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1177, - "end": 1178, - "ctxt": 0 - }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 1178, - "end": 1179, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1179, - "end": 1183, - "ctxt": 0 - }, - "token": { - "Dimension": { - "value": 16.0, - "raw_value": "16", - "unit": "px", - "raw_unit": "px", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1183, - "end": 1184, - "ctxt": 0 - }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1184, - "end": 1193, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1193, - "end": 1199, - "ctxt": 0 - }, - "token": { - "Ident": { - "value": "height", - "raw": "height" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1199, - "end": 1200, - "ctxt": 0 - }, - "token": "Colon" - }, - { - "type": "PreservedToken", - "span": { - "start": 1200, - "end": 1201, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": " " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1201, - "end": 1205, - "ctxt": 0 - }, - "token": { - "Dimension": { - "value": 16.0, - "raw_value": "16", - "unit": "px", - "raw_unit": "px", - "type": "integer" - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1205, - "end": 1206, - "ctxt": 0 - }, - "token": "Semi" - }, - { - "type": "PreservedToken", - "span": { - "start": 1206, - "end": 1211, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " - } - } - }, - { - "type": "PreservedToken", - "span": { - "start": 1211, - "end": 1212, - "ctxt": 0 - }, - "token": "RBrace" - }, - { - "type": "PreservedToken", - "span": { - "start": 1212, - "end": 1217, - "ctxt": 0 - }, - "token": { - "WhiteSpace": { - "value": "\n " + "value": [ + { + "type": "PreservedToken", + "span": { + "start": 1163, + "end": 1172, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1172, + "end": 1177, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "width", + "raw": "width" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1177, + "end": 1178, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 1178, + "end": 1179, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1179, + "end": 1183, + "ctxt": 0 + }, + "token": { + "Dimension": { + "value": 16.0, + "raw_value": "16", + "unit": "px", + "raw_unit": "px", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1183, + "end": 1184, + "ctxt": 0 + }, + "token": "Semi" + }, + { + "type": "PreservedToken", + "span": { + "start": 1184, + "end": 1193, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1193, + "end": 1199, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "height", + "raw": "height" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1199, + "end": 1200, + "ctxt": 0 + }, + "token": "Colon" + }, + { + "type": "PreservedToken", + "span": { + "start": 1200, + "end": 1201, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": " " + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1201, + "end": 1205, + "ctxt": 0 + }, + "token": { + "Dimension": { + "value": 16.0, + "raw_value": "16", + "unit": "px", + "raw_unit": "px", + "type": "integer" + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 1205, + "end": 1206, + "ctxt": 0 + }, + "token": "Semi" + }, + { + "type": "PreservedToken", + "span": { + "start": 1206, + "end": 1211, + "ctxt": 0 + }, + "token": { + "WhiteSpace": { + "value": "\n " + } + } } - } + ] } ], "important": null diff --git a/crates/swc_css_parser/tests/fixture/value/custom-property/span.rust-debug b/crates/swc_css_parser/tests/fixture/value/custom-property/span.rust-debug index a7094dcd6cd2..6458efb4210e 100644 --- a/crates/swc_css_parser/tests/fixture/value/custom-property/span.rust-debug +++ b/crates/swc_css_parser/tests/fixture/value/custom-property/span.rust-debug @@ -487,18 +487,6 @@ : ^^^^^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:6:5] - 6 | --important2: value !important; - : ^ - `---- - - x WhiteSpace { value: Atom(' ' type=inline) } - ,-[$DIR/tests/fixture/value/custom-property/input.css:6:5] - 6 | --important2: value !important; - : ^ - `---- - x ImportantFlag ,-[$DIR/tests/fixture/value/custom-property/input.css:6:5] 6 | --important2: value !important; @@ -553,18 +541,6 @@ : ^^^^^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:7:5] - 7 | --important3:value !important; - : ^ - `---- - - x WhiteSpace { value: Atom(' ' type=inline) } - ,-[$DIR/tests/fixture/value/custom-property/input.css:7:5] - 7 | --important3:value !important; - : ^ - `---- - x ImportantFlag ,-[$DIR/tests/fixture/value/custom-property/input.css:7:5] 7 | --important3:value !important; @@ -610,37 +586,31 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:8:5] 8 | --important4: calc(1)!important; - : ^^^^^ - `---- - - x Function { value: Atom('calc' type=static), raw: Atom('calc' type=static) } - ,-[$DIR/tests/fixture/value/custom-property/input.css:8:5] - 8 | --important4: calc(1)!important; - : ^^^^^ + : ^^^^^^^ `---- - x ComponentValue + x Function ,-[$DIR/tests/fixture/value/custom-property/input.css:8:5] 8 | --important4: calc(1)!important; - : ^ + : ^^^^^^^ `---- - x Number { value: 1.0, raw: Atom('1' type=inline), type_flag: Integer } + x Ident ,-[$DIR/tests/fixture/value/custom-property/input.css:8:5] 8 | --important4: calc(1)!important; - : ^ + : ^^^^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:8:5] 8 | --important4: calc(1)!important; - : ^ + : ^ `---- - x RParen + x Number { value: 1.0, raw: Atom('1' type=inline), type_flag: Integer } ,-[$DIR/tests/fixture/value/custom-property/input.css:8:5] 8 | --important4: calc(1)!important; - : ^ + : ^ `---- x ImportantFlag @@ -1000,19 +970,19 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:21:5] 21 | --function: calc(1 + 1); - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:21:5] 21 | --function: calc(1 + 1); - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:21:5] 21 | --function: calc(1 + 1); - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1030,13 +1000,19 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:21:5] 21 | --function: calc(1 + 1); - : ^^^^^ + : ^^^^^^^^^^^ + `---- + + x Function + ,-[$DIR/tests/fixture/value/custom-property/input.css:21:5] + 21 | --function: calc(1 + 1); + : ^^^^^^^^^^^ `---- - x Function { value: Atom('calc' type=static), raw: Atom('calc' type=static) } + x Ident ,-[$DIR/tests/fixture/value/custom-property/input.css:21:5] 21 | --function: calc(1 + 1); - : ^^^^^ + : ^^^^ `---- x ComponentValue @@ -1099,34 +1075,22 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:21:5] - 21 | --function: calc(1 + 1); - : ^ - `---- - - x RParen - ,-[$DIR/tests/fixture/value/custom-property/input.css:21:5] - 21 | --function: calc(1 + 1); - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] 22 | --variable: var(--unit); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] 22 | --variable: var(--unit); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] 22 | --variable: var(--unit); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1144,37 +1108,31 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] 22 | --variable: var(--unit); - : ^^^^ - `---- - - x Function { value: Atom('var' type=static), raw: Atom('var' type=static) } - ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] - 22 | --variable: var(--unit); - : ^^^^ + : ^^^^^^^^^^^ `---- - x ComponentValue + x Function ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] 22 | --variable: var(--unit); - : ^^^^^^ + : ^^^^^^^^^^^ `---- - x Ident { value: Atom('--unit' type=inline), raw: Atom('--unit' type=inline) } + x Ident ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] 22 | --variable: var(--unit); - : ^^^^^^ + : ^^^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] 22 | --variable: var(--unit); - : ^ + : ^^^^^^ `---- - x RParen + x Ident { value: Atom('--unit' type=inline), raw: Atom('--unit' type=inline) } ,-[$DIR/tests/fixture/value/custom-property/input.css:22:5] 22 | --variable: var(--unit); - : ^ + : ^^^^^^ `---- x ComponentValue @@ -1264,19 +1222,19 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:27:5] 27 | --square-block: [1, 2, 3]; - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:27:5] 27 | --square-block: [1, 2, 3]; - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:27:5] 27 | --square-block: [1, 2, 3]; - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1294,7 +1252,13 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:27:5] 27 | --square-block: [1, 2, 3]; - : ^ + : ^^^^^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/value/custom-property/input.css:27:5] + 27 | --square-block: [1, 2, 3]; + : ^^^^^^^^^ `---- x LBracket @@ -1387,34 +1351,22 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:27:5] - 27 | --square-block: [1, 2, 3]; - : ^ - `---- - - x RBracket - ,-[$DIR/tests/fixture/value/custom-property/input.css:27:5] - 27 | --square-block: [1, 2, 3]; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:28:5] 28 | --square-block1: []; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:28:5] 28 | --square-block1: []; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:28:5] 28 | --square-block1: []; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1432,43 +1384,37 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:28:5] 28 | --square-block1: []; - : ^ - `---- - - x LBracket - ,-[$DIR/tests/fixture/value/custom-property/input.css:28:5] - 28 | --square-block1: []; - : ^ + : ^^ `---- - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:28:5] 28 | --square-block1: []; - : ^ + : ^^ `---- - x RBracket + x LBracket ,-[$DIR/tests/fixture/value/custom-property/input.css:28:5] 28 | --square-block1: []; - : ^ + : ^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:29:5] 29 | --square-block2:[]; - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:29:5] 29 | --square-block2:[]; - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:29:5] 29 | --square-block2:[]; - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1486,43 +1432,37 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:29:5] 29 | --square-block2:[]; - : ^ - `---- - - x LBracket - ,-[$DIR/tests/fixture/value/custom-property/input.css:29:5] - 29 | --square-block2:[]; - : ^ + : ^^ `---- - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:29:5] 29 | --square-block2:[]; - : ^ + : ^^ `---- - x RBracket + x LBracket ,-[$DIR/tests/fixture/value/custom-property/input.css:29:5] 29 | --square-block2:[]; - : ^ + : ^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:30:5] 30 | --round-block: (1, 2, 3); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:30:5] 30 | --round-block: (1, 2, 3); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:30:5] 30 | --round-block: (1, 2, 3); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1540,7 +1480,13 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:30:5] 30 | --round-block: (1, 2, 3); - : ^ + : ^^^^^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/value/custom-property/input.css:30:5] + 30 | --round-block: (1, 2, 3); + : ^^^^^^^^^ `---- x LParen @@ -1633,34 +1579,22 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:30:5] - 30 | --round-block: (1, 2, 3); - : ^ - `---- - - x RParen - ,-[$DIR/tests/fixture/value/custom-property/input.css:30:5] - 30 | --round-block: (1, 2, 3); - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:31:5] 31 | --round-block1: (); - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:31:5] 31 | --round-block1: (); - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:31:5] 31 | --round-block1: (); - : ^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1678,43 +1612,37 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:31:5] 31 | --round-block1: (); - : ^ - `---- - - x LParen - ,-[$DIR/tests/fixture/value/custom-property/input.css:31:5] - 31 | --round-block1: (); - : ^ + : ^^ `---- - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:31:5] 31 | --round-block1: (); - : ^ + : ^^ `---- - x RParen + x LParen ,-[$DIR/tests/fixture/value/custom-property/input.css:31:5] 31 | --round-block1: (); - : ^ + : ^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:32:5] 32 | --round-block2:(); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:32:5] 32 | --round-block2:(); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:32:5] 32 | --round-block2:(); - : ^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1732,43 +1660,37 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:32:5] 32 | --round-block2:(); - : ^ - `---- - - x LParen - ,-[$DIR/tests/fixture/value/custom-property/input.css:32:5] - 32 | --round-block2:(); - : ^ + : ^^ `---- - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:32:5] 32 | --round-block2:(); - : ^ + : ^^ `---- - x RParen + x LParen ,-[$DIR/tests/fixture/value/custom-property/input.css:32:5] 32 | --round-block2:(); - : ^ + : ^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:33:5] 33 | --bracket-block: {1, 2, 3}; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:33:5] 33 | --bracket-block: {1, 2, 3}; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:33:5] 33 | --bracket-block: {1, 2, 3}; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1786,7 +1708,13 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:33:5] 33 | --bracket-block: {1, 2, 3}; - : ^ + : ^^^^^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/value/custom-property/input.css:33:5] + 33 | --bracket-block: {1, 2, 3}; + : ^^^^^^^^^ `---- x LBrace @@ -1879,34 +1807,22 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:33:5] - 33 | --bracket-block: {1, 2, 3}; - : ^ - `---- - - x RBrace - ,-[$DIR/tests/fixture/value/custom-property/input.css:33:5] - 33 | --bracket-block: {1, 2, 3}; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:34:5] 34 | --bracket-block1: {}; - : ^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:34:5] 34 | --bracket-block1: {}; - : ^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:34:5] 34 | --bracket-block1: {}; - : ^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1924,43 +1840,37 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:34:5] 34 | --bracket-block1: {}; - : ^ - `---- - - x LBrace - ,-[$DIR/tests/fixture/value/custom-property/input.css:34:5] - 34 | --bracket-block1: {}; - : ^ + : ^^ `---- - x ComponentValue + x SimpleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:34:5] 34 | --bracket-block1: {}; - : ^ + : ^^ `---- - x RBrace + x LBrace ,-[$DIR/tests/fixture/value/custom-property/input.css:34:5] 34 | --bracket-block1: {}; - : ^ + : ^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:35:5] 35 | --bracket-block2:{}; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:35:5] 35 | --bracket-block2:{}; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:35:5] 35 | --bracket-block2:{}; - : ^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -1978,43 +1888,37 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:35:5] 35 | --bracket-block2:{}; - : ^ + : ^^ `---- - x LBrace + x SimpleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:35:5] 35 | --bracket-block2:{}; - : ^ + : ^^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:35:5] - 35 | --bracket-block2:{}; - : ^ - `---- - - x RBrace + x LBrace ,-[$DIR/tests/fixture/value/custom-property/input.css:35:5] 35 | --bracket-block2:{}; - : ^ + : ^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -2032,7 +1936,13 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] + 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x LBracket @@ -2116,7 +2026,13 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ + : ^^^^^^^^^^^^^^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] + 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; + : ^^^^^^^^^^^^^^^^^^ `---- x LBrace @@ -2164,7 +2080,13 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ + : ^^^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] + 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; + : ^^^^^^^ `---- x LBrace @@ -2209,30 +2131,6 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] - 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ - `---- - - x RBrace - ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] - 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ - `---- - - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] - 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ - `---- - - x RBrace - ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] - 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; @@ -2260,7 +2158,13 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ + : ^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] + 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; + : ^^^ `---- x LBracket @@ -2281,46 +2185,22 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] - 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ - `---- - - x RBracket - ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] - 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ - `---- - - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] - 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ - `---- - - x RBracket - ,-[$DIR/tests/fixture/value/custom-property/input.css:38:5] - 38 | --JSON: [1, "2", {"three": {"a":1}}, [4]]; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x StyleBlock ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x Declaration ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^^^^^^^^^^^^^^^^^^^^ + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- x DeclarationName @@ -2338,37 +2218,31 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^^^^^^ - `---- - - x Function { value: Atom('function' type=static), raw: Atom('function' type=static) } - ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] - 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^^^^^^ + : ^^^^^^^^^^^^^^ `---- - x ComponentValue + x Function ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^ + : ^^^^^^^^^^^^^^ `---- - x Ident { value: Atom('rule' type=inline), raw: Atom('rule' type=inline) } + x Ident ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^ + : ^^^^^^^^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^ + : ^^^^ `---- - x RParen + x Ident { value: Atom('rule' type=inline), raw: Atom('rule' type=inline) } ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^ + : ^^^^ `---- x ComponentValue @@ -2386,7 +2260,13 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^ + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] + 39 | --javascript: function(rule) { console.log(rule) }; + : ^^^^^^^^^^^^^^^^^^^^^ `---- x LBrace @@ -2434,37 +2314,31 @@ x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^ + : ^^^^^^^^^ `---- - x Function { value: Atom('log' type=inline), raw: Atom('log' type=inline) } + x Function ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^ + : ^^^^^^^^^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] - 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^ - `---- - - x Ident { value: Atom('rule' type=inline), raw: Atom('rule' type=inline) } + x Ident ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^^^^ + : ^^^ `---- x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^ + : ^^^^ `---- - x RParen + x Ident { value: Atom('rule' type=inline), raw: Atom('rule' type=inline) } ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] 39 | --javascript: function(rule) { console.log(rule) }; - : ^ + : ^^^^ `---- x ComponentValue @@ -2479,18 +2353,6 @@ : ^ `---- - x ComponentValue - ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] - 39 | --javascript: function(rule) { console.log(rule) }; - : ^ - `---- - - x RBrace - ,-[$DIR/tests/fixture/value/custom-property/input.css:39:5] - 39 | --javascript: function(rule) { console.log(rule) }; - : ^ - `---- - x ComponentValue ,-[$DIR/tests/fixture/value/custom-property/input.css:41:5] 41 | --CDO: