feat(css/ast): Add delim token (#2398)

This commit is contained in:
Alexander Akait 2021-10-12 14:47:17 +03:00 committed by GitHub
parent 62f7f655a9
commit fb4869f413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 1387 additions and 136 deletions

14
Cargo.lock generated
View File

@ -2500,7 +2500,7 @@ dependencies = [
[[package]]
name = "swc_css"
version = "0.13.0"
version = "0.14.0"
dependencies = [
"swc_css_ast",
"swc_css_codegen",
@ -2511,7 +2511,7 @@ dependencies = [
[[package]]
name = "swc_css_ast"
version = "0.12.0"
version = "0.13.0"
dependencies = [
"is-macro",
"serde",
@ -2522,7 +2522,7 @@ dependencies = [
[[package]]
name = "swc_css_codegen"
version = "0.11.0"
version = "0.12.0"
dependencies = [
"auto_impl",
"bitflags",
@ -2548,7 +2548,7 @@ dependencies = [
[[package]]
name = "swc_css_parser"
version = "0.13.0"
version = "0.14.0"
dependencies = [
"bitflags",
"lexical",
@ -2564,7 +2564,7 @@ dependencies = [
[[package]]
name = "swc_css_utils"
version = "0.9.0"
version = "0.10.0"
dependencies = [
"swc_atoms 0.2.8",
"swc_common",
@ -2574,7 +2574,7 @@ dependencies = [
[[package]]
name = "swc_css_visit"
version = "0.11.0"
version = "0.12.0"
dependencies = [
"swc_atoms 0.2.8",
"swc_common",
@ -3139,7 +3139,7 @@ dependencies = [
[[package]]
name = "swc_stylis"
version = "0.10.0"
version = "0.11.0"
dependencies = [
"swc_atoms 0.2.8",
"swc_common",

View File

@ -6,11 +6,11 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css"
repository = "https://github.com/swc-project/swc.git"
version = "0.13.0"
version = "0.14.0"
[dependencies]
swc_css_ast = {version = "0.12.0", path = "./ast"}
swc_css_codegen = {version = "0.11.0", path = "./codegen"}
swc_css_parser = {version = "0.13.0", path = "./parser"}
swc_css_utils = {version = "0.9.0", path = "./utils/"}
swc_css_visit = {version = "0.11.0", path = "./visit"}
swc_css_ast = {version = "0.13.0", path = "./ast"}
swc_css_codegen = {version = "0.12.0", path = "./codegen"}
swc_css_parser = {version = "0.14.0", path = "./parser"}
swc_css_utils = {version = "0.10.0", path = "./utils/"}
swc_css_visit = {version = "0.12.0", path = "./visit"}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_ast"
repository = "https://github.com/swc-project/swc.git"
version = "0.12.0"
version = "0.13.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -23,6 +23,10 @@ pub enum Token {
raw: JsWord,
},
Delim {
value: char,
},
/// `(`
LParen,

View File

@ -6,17 +6,17 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_codegen"
repository = "https://github.com/swc-project/swc.git"
version = "0.11.0"
version = "0.12.0"
[dependencies]
auto_impl = "0.4.1"
bitflags = "1.3.2"
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.13.0", path = "../../common"}
swc_css_ast = {version = "0.12.0", path = "../ast/"}
swc_css_ast = {version = "0.13.0", path = "../ast/"}
swc_css_codegen_macros = {version = "0.2.0", path = "macros/"}
[dev-dependencies]
swc_css_parser = {version = "0.13.0", path = "../parser"}
swc_css_visit = {version = "0.11.0", path = "../visit"}
swc_css_parser = {version = "0.14.0", path = "../parser"}
swc_css_visit = {version = "0.12.0", path = "../visit"}
testing = {version = "0.14.0", path = "../../testing"}

View File

@ -479,6 +479,9 @@ where
punct!(self, span, "@");
self.wr.write_raw(Some(n.span), &raw)?;
}
Token::Delim { value } => {
self.wr.write_raw_char(Some(n.span), *value)?;
}
Token::LParen => {
punct!(self, span, "(");
}

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_parser"
repository = "https://github.com/swc-project/swc.git"
version = "0.13.0"
version = "0.14.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
@ -17,11 +17,11 @@ bitflags = "1.2.1"
lexical = "5.2.2"
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.13.0", path = "../../common"}
swc_css_ast = {version = "0.12.0", path = "../ast"}
swc_css_ast = {version = "0.13.0", path = "../ast"}
unicode-xid = "0.2.2"
[dev-dependencies]
serde = "1.0.127"
serde_json = "1.0.66"
swc_css_visit = {version = "0.11.0", path = "../visit"}
swc_css_visit = {version = "0.12.0", path = "../visit"}
testing = {version = "0.14.0", path = "../../testing"}

View File

@ -92,14 +92,6 @@ where
return Err(ErrorKind::Eof);
}
macro_rules! try_delim {
($b:tt,$tok:tt) => {{
if self.input.eat_byte($b) {
return Ok(tok!($tok));
}
}};
}
if self.input.is_byte(b'/') {
if self.input.peek() == Some('/') {
self.skip_line_comment(2)?;
@ -114,21 +106,18 @@ where
}
}
try_delim!(b'(', "(");
try_delim!(b')', ")");
macro_rules! try_delim {
($b:tt,$tok:tt) => {{
if self.input.eat_byte($b) {
return Ok(tok!($tok));
}
}};
}
try_delim!(b'[', "[");
try_delim!(b']', "]");
try_delim!(b'{', "{");
try_delim!(b'}', "}");
try_delim!(b',', ",");
// TODO: it is delim tokens
try_delim!(b'=', "=");
try_delim!(b'*', "*");
try_delim!(b'$', "$");
try_delim!(b':', ":");
try_delim!(b';', ";");
try_delim!(b'^', "^");
try_delim!(b'%', "%");
try_delim!(b'!', "!");
@ -140,14 +129,51 @@ where
// TODO: Plus can start a number
try_delim!(b'/', "/");
if self.input.eat_byte(b'@') {
return self.read_at_keyword();
if let Some(c) = self.input.cur() {
if is_whitespace(c) {
self.skip_ws()?;
return Ok(tok!(" "));
}
}
if self.input.is_byte(b'<') {
return self.read_less_than();
if self.input.is_byte(b'"') {
return self.read_str(None);
}
if self.input.is_byte(b'#') {
let c = self.input.cur().unwrap();
self.input.bump();
if is_name_continue(self.input.cur().unwrap()) || self.is_valid_escape()? {
let is_id = self.would_start_ident()?;
let name = self.read_name()?;
return Ok(Token::Hash {
is_id,
value: name.0,
raw: name.1,
});
}
return Ok(Token::Delim { value: c });
}
if self.input.is_byte(b'\'') {
return self.read_str(None);
}
try_delim!(b'(', "(");
try_delim!(b')', ")");
if self.input.is_byte(b'+') {
return self.read_plus();
}
try_delim!(b',', ",");
if self.input.is_byte(b'-') {
return self.read_minus();
}
@ -156,78 +182,89 @@ where
return self.read_dot();
}
if self.input.is_byte(b'+') {
return self.read_plus();
try_delim!(b':', ":");
try_delim!(b';', ";");
if self.input.is_byte(b'<') {
let c = self.input.cur().unwrap();
self.input.bump();
// <!--
if self.input.is_byte(b'!')
&& self.input.peek() == Some('-')
&& self.input.peek_ahead() == Some('-')
{
self.input.bump(); // !
self.input.bump(); // -
self.input.bump(); // -
return Ok(tok!("<!--"));
}
return Ok(Token::Delim { value: c });
}
if self.input.is_byte(b'@') {
let c = self.input.cur().unwrap();
self.input.bump();
if self.would_start_ident()? {
return self.read_at_keyword();
}
return Ok(Token::Delim { value: c });
}
try_delim!(b'[', "[");
if self.input.is_byte(b'\\') {
let c = self.input.cur().unwrap();
if self.is_valid_escape()? {
return self.read_ident_like();
} else {
return Err(ErrorKind::InvalidEscape);
}
self.input.bump();
return Ok(Token::Delim { value: c });
}
try_delim!(b']', "]");
try_delim!(b'{', "{");
try_delim!(b'}', "}");
if let Some('0'..='9') = self.input.cur() {
return self.read_number();
}
if let Some(c) = self.input.cur() {
if is_name_start(c) {
return self.read_ident_like();
}
}
match self.input.cur() {
Some(c) => match c {
'0'..='9' => return self.read_number(),
c if is_whitespace(c) => {
self.skip_ws()?;
return Ok(tok!(" "));
}
'\'' | '"' => return self.read_str(None),
'#' => {
self.input.bump();
if let Some(c) = self.input.cur() {
Ok(if is_name_continue(c) || self.is_valid_escape()? {
let is_id = self.would_start_ident()?;
let name = self.read_name()?;
Token::Hash {
is_id,
value: name.0,
raw: name.1,
}
} else {
// TODO: Verify if this is ok.
Token::Hash {
is_id: false,
value: js_word!(""),
raw: js_word!(""),
}
})
} else {
Err(ErrorKind::Eof)
}
}
_ => {
if is_name_start(c) {
return self.read_ident_like();
}
todo!("read_token (cur = {:?})", c)
}
},
None => {
unreachable!()
}
// TODO: Return an <EOF-token>.
if self.input.cur().is_none() {
unreachable!()
}
let c = self.input.cur().unwrap();
self.input.bump();
return Ok(Token::Delim { value: c });
}
/// Ported from `isValidEscape` of `esbuild`
fn is_valid_escape(&mut self) -> LexResult<bool> {
if self.input.cur().is_none() {
return Ok(false);
}
if self.input.cur().unwrap() != '\\' {
if self.input.cur() != Some('\\') {
return Ok(false);
}
let c = self.input.peek();
match c {
@ -236,6 +273,8 @@ where
}
}
/// Ported from `consumeIdentLike` of `esbuild`
// TODO: rewrite https://www.w3.org/TR/css-syntax-3/#consume-an-ident-like-token
fn read_ident_like(&mut self) -> LexResult<Token> {
let name = self.read_name()?;
@ -522,25 +561,6 @@ where
})
}
fn read_less_than(&mut self) -> LexResult<Token> {
assert_eq!(self.input.cur(), Some('<'));
self.input.bump(); // <
// <!--
if self.input.is_byte(b'!')
&& self.input.peek() == Some('-')
&& self.input.peek_ahead() == Some('-')
{
self.input.bump(); // !
self.input.bump(); // -
self.input.bump(); // -
return Ok(tok!("<!--"));
}
Err(ErrorKind::UnexpectedChar(self.input.cur()))
}
fn read_minus(&mut self) -> LexResult<Token> {
assert_eq!(self.input.cur(), Some('-'));
@ -725,18 +745,52 @@ where
}
}
#[inline(always)]
fn is_digit(c: char) -> bool {
match c {
'0'..='9' => true,
_ => false,
}
}
#[inline(always)]
fn is_uppercase_letter(c: char) -> bool {
match c {
'A'..='Z' => true,
_ => false,
}
}
#[inline(always)]
fn is_lowercase_letter(c: char) -> bool {
match c {
'a'..='z' => true,
_ => false,
}
}
#[inline(always)]
fn is_letter(c: char) -> bool {
is_uppercase_letter(c) || is_lowercase_letter(c)
}
#[inline(always)]
fn is_non_ascii(c: char) -> bool {
c as u32 >= 0x80
}
pub(crate) fn is_name_start(c: char) -> bool {
match c {
'a'..='z' | 'A'..='Z' | '_' | '\x00' => true,
_ => c as u32 >= 0x80,
// TODO: `\x00` is not valid
c if is_letter(c) || is_non_ascii(c) || c == '_' || c == '\x00' => true,
_ => false,
}
}
pub(crate) fn is_name_continue(c: char) -> bool {
is_name_start(c)
|| match c {
'0'..='9' | '-' => true,
c if is_digit(c) || c == '-' => true,
_ => false,
}
}

View File

@ -0,0 +1,3 @@
a {
color: \\ red \\ blue;
}

View File

@ -0,0 +1,131 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 33,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 32,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "DeclBlock",
"span": {
"start": 2,
"end": 32,
"ctxt": 0
},
"items": [
{
"type": "Property",
"span": {
"start": 8,
"end": 29,
"ctxt": 0
},
"name": {
"type": "Text",
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"value": "color",
"raw": "color"
},
"values": [
{
"type": "Text",
"span": {
"start": 15,
"end": 17,
"ctxt": 0
},
"value": "\\",
"raw": "\\\\"
},
{
"type": "Text",
"span": {
"start": 18,
"end": 21,
"ctxt": 0
},
"value": "red",
"raw": "red"
},
{
"type": "Text",
"span": {
"start": 22,
"end": 24,
"ctxt": 0
},
"value": "\\",
"raw": "\\\\"
},
{
"type": "Text",
"span": {
"start": 25,
"end": 29,
"ctxt": 0
},
"value": "blue",
"raw": "blue"
}
],
"important": null
}
]
}
}
]
}

View File

@ -0,0 +1,117 @@
error: Stylesheet
--> $DIR/tests/fixture/delim/backslash/input.css:1:1
|
1 | / a {
2 | | color: \\ red \\ blue;
3 | | }
| |__^
error: Rule
--> $DIR/tests/fixture/delim/backslash/input.css:1:1
|
1 | / a {
2 | | color: \\ red \\ blue;
3 | | }
| |_^
error: StyleRule
--> $DIR/tests/fixture/delim/backslash/input.css:1:1
|
1 | / a {
2 | | color: \\ red \\ blue;
3 | | }
| |_^
error: ComplexSelector
--> $DIR/tests/fixture/delim/backslash/input.css:1:1
|
1 | a {
| ^
error: CompoundSelector
--> $DIR/tests/fixture/delim/backslash/input.css:1:1
|
1 | a {
| ^
error: NamespacedName
--> $DIR/tests/fixture/delim/backslash/input.css:1:1
|
1 | a {
| ^
error: Text
--> $DIR/tests/fixture/delim/backslash/input.css:1:1
|
1 | a {
| ^
error: DeclBlock
--> $DIR/tests/fixture/delim/backslash/input.css:1:3
|
1 | a {
| ___^
2 | | color: \\ red \\ blue;
3 | | }
| |_^
error: Property
--> $DIR/tests/fixture/delim/backslash/input.css:2:5
|
2 | color: \\ red \\ blue;
| ^^^^^^^^^^^^^^^^^^^^^
error: Text
--> $DIR/tests/fixture/delim/backslash/input.css:2:5
|
2 | color: \\ red \\ blue;
| ^^^^^
error: Value
--> $DIR/tests/fixture/delim/backslash/input.css:2:12
|
2 | color: \\ red \\ blue;
| ^^
error: Text
--> $DIR/tests/fixture/delim/backslash/input.css:2:12
|
2 | color: \\ red \\ blue;
| ^^
error: Value
--> $DIR/tests/fixture/delim/backslash/input.css:2:15
|
2 | color: \\ red \\ blue;
| ^^^
error: Text
--> $DIR/tests/fixture/delim/backslash/input.css:2:15
|
2 | color: \\ red \\ blue;
| ^^^
error: Value
--> $DIR/tests/fixture/delim/backslash/input.css:2:19
|
2 | color: \\ red \\ blue;
| ^^
error: Text
--> $DIR/tests/fixture/delim/backslash/input.css:2:19
|
2 | color: \\ red \\ blue;
| ^^
error: Value
--> $DIR/tests/fixture/delim/backslash/input.css:2:22
|
2 | color: \\ red \\ blue;
| ^^^^
error: Text
--> $DIR/tests/fixture/delim/backslash/input.css:2:22
|
2 | color: \\ red \\ blue;
| ^^^^

View File

@ -0,0 +1,3 @@
a {
color: @ red;
}

View File

@ -0,0 +1,142 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 24,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 23,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "DeclBlock",
"span": {
"start": 2,
"end": 23,
"ctxt": 0
},
"items": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 20,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"token": {
"Ident": {
"value": "color",
"raw": "color"
}
}
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 14,
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
},
{
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"token": {
"Delim": {
"value": "@"
}
}
},
{
"span": {
"start": 16,
"end": 17,
"ctxt": 0
},
"token": "WhiteSpace"
},
{
"span": {
"start": 17,
"end": 20,
"ctxt": 0
},
"token": {
"Ident": {
"value": "red",
"raw": "red"
}
}
}
]
}
]
}
}
]
}

View File

@ -0,0 +1,6 @@
error: Expected Property value
--> $DIR/tests/recovery/delim-token/at-sign/input.css:2:12
|
2 | color: @ red;
| ^

View File

@ -0,0 +1,3 @@
a {
color: !!;
}

View File

@ -0,0 +1,125 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 21,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 20,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "DeclBlock",
"span": {
"start": 2,
"end": 20,
"ctxt": 0
},
"items": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 17,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"token": {
"Ident": {
"value": "color",
"raw": "color"
}
}
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 14,
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
},
{
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"token": "Bang"
},
{
"span": {
"start": 16,
"end": 17,
"ctxt": 0
},
"token": "Bang"
}
]
}
]
}
}
]
}

View File

@ -0,0 +1,6 @@
error: Expected Property value
--> $DIR/tests/recovery/delim-token/bang/input.css:2:12
|
2 | color: !!;
| ^

View File

@ -0,0 +1,3 @@
a {
color: ##;
}

View File

@ -0,0 +1,133 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 21,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 20,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "DeclBlock",
"span": {
"start": 2,
"end": 20,
"ctxt": 0
},
"items": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 17,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"token": {
"Ident": {
"value": "color",
"raw": "color"
}
}
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 14,
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
},
{
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"token": {
"Delim": {
"value": "#"
}
}
},
{
"span": {
"start": 16,
"end": 17,
"ctxt": 0
},
"token": {
"Delim": {
"value": "#"
}
}
}
]
}
]
}
}
]
}

View File

@ -0,0 +1,6 @@
error: Expected Property value
--> $DIR/tests/recovery/delim-token/hash/input.css:2:12
|
2 | color: ##;
| ^

View File

@ -0,0 +1,3 @@
a {
color: <;
}

View File

@ -0,0 +1,121 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 20,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 19,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "DeclBlock",
"span": {
"start": 2,
"end": 19,
"ctxt": 0
},
"items": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 16,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"token": {
"Ident": {
"value": "color",
"raw": "color"
}
}
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 14,
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
},
{
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"token": {
"Delim": {
"value": "<"
}
}
}
]
}
]
}
}
]
}

View File

@ -0,0 +1,6 @@
error: Expected Property value
--> $DIR/tests/recovery/delim-token/less-than/input.css:2:12
|
2 | color: <;
| ^

View File

@ -0,0 +1,3 @@
a {
color: ?;
}

View File

@ -0,0 +1,121 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 20,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 19,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "DeclBlock",
"span": {
"start": 2,
"end": 19,
"ctxt": 0
},
"items": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 16,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"token": {
"Ident": {
"value": "color",
"raw": "color"
}
}
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 14,
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
},
{
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"token": {
"Delim": {
"value": "?"
}
}
}
]
}
]
}
}
]
}

View File

@ -0,0 +1,6 @@
error: Expected Property value
--> $DIR/tests/recovery/delim-token/question-mark/input.css:2:12
|
2 | color: ?;
| ^

View File

@ -0,0 +1,3 @@
a {
color: *;
}

View File

@ -0,0 +1,117 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 20,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 19,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "DeclBlock",
"span": {
"start": 2,
"end": 19,
"ctxt": 0
},
"items": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 16,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"token": {
"Ident": {
"value": "color",
"raw": "color"
}
}
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 14,
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
},
{
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"token": "Asterisk"
}
]
}
]
}
}
]
}

View File

@ -0,0 +1,6 @@
error: Expected Property value
--> $DIR/tests/recovery/delim-token/star/input.css:2:12
|
2 | color: *;
| ^

View File

@ -0,0 +1,3 @@
a {
color: ~;
}

View File

@ -0,0 +1,117 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 20,
"ctxt": 0
},
"rules": [
{
"type": "StyleRule",
"span": {
"start": 0,
"end": 19,
"ctxt": 0
},
"selectors": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"selectors": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"hasNestPrefix": false,
"combinator": null,
"typeSelector": {
"type": "NamespacedName",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Text",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
],
"block": {
"type": "DeclBlock",
"span": {
"start": 2,
"end": 19,
"ctxt": 0
},
"items": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 16,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"token": {
"Ident": {
"value": "color",
"raw": "color"
}
}
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 14,
"end": 15,
"ctxt": 0
},
"token": "WhiteSpace"
},
{
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"token": "Tilde"
}
]
}
]
}
}
]
}

View File

@ -0,0 +1,6 @@
error: Expected Property value
--> $DIR/tests/recovery/delim-token/tilde/input.css:2:12
|
2 | color: ~;
| ^

View File

@ -6,18 +6,18 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_stylis"
repository = "https://github.com/swc-project/swc.git"
version = "0.10.0"
version = "0.11.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.13.0", path = "../../common"}
swc_css_ast = {version = "0.12.0", path = "../ast"}
swc_css_utils = {version = "0.9.0", path = "../utils/"}
swc_css_visit = {version = "0.11.0", path = "../visit"}
swc_css_ast = {version = "0.13.0", path = "../ast"}
swc_css_utils = {version = "0.10.0", path = "../utils/"}
swc_css_visit = {version = "0.12.0", path = "../visit"}
[dev-dependencies]
swc_css_codegen = {version = "0.11.0", path = "../codegen"}
swc_css_parser = {version = "0.13.0", path = "../parser"}
swc_css_codegen = {version = "0.12.0", path = "../codegen"}
swc_css_parser = {version = "0.14.0", path = "../parser"}
testing = {version = "0.14.0", path = "../../testing"}

View File

@ -6,11 +6,11 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_utils"
repository = "https://github.com/swc-project/swc.git"
version = "0.9.0"
version = "0.10.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.13.0", path = "../../common"}
swc_css_ast = {version = "0.12.0", path = "../ast"}
swc_css_visit = {version = "0.11.0", path = "../visit"}
swc_css_ast = {version = "0.13.0", path = "../ast"}
swc_css_visit = {version = "0.12.0", path = "../visit"}

View File

@ -6,12 +6,12 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_css_visit"
repository = "https://github.com/swc-project/swc.git"
version = "0.11.0"
version = "0.12.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_atoms = {version = "0.2.7", path = "../../atoms"}
swc_common = {version = "0.13.0", path = "../../common"}
swc_css_ast = {version = "0.12.0", path = "../ast/"}
swc_css_ast = {version = "0.13.0", path = "../ast/"}
swc_visit = {version = "0.2.6", path = "../../visit"}