Don't require a ; on the last declaration in a block
This commit is contained in:
parent
90369e3d66
commit
7add08036c
|
@ -166,3 +166,21 @@ a {
|
|||
(selectors (tag_name))
|
||||
(block
|
||||
(declaration (property_name) (plain_value) (important)))))
|
||||
|
||||
============================
|
||||
Declarations without trailing semicolons
|
||||
============================
|
||||
|
||||
a {
|
||||
b: c;
|
||||
d: e
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(stylesheet
|
||||
(rule_set
|
||||
(selectors (tag_name))
|
||||
(block
|
||||
(declaration (property_name) (plain_value))
|
||||
(declaration (property_name) (plain_value)))))
|
||||
|
|
17
grammar.js
17
grammar.js
|
@ -98,7 +98,11 @@ module.exports = grammar({
|
|||
|
||||
selectors: $ => commaSep1($._selector),
|
||||
|
||||
block: $ => seq('{', repeat($._block_item), '}'),
|
||||
block: $ => seq('{',
|
||||
repeat($._block_item),
|
||||
optional(alias($.last_declaration, $.declaration)),
|
||||
'}'
|
||||
),
|
||||
|
||||
_block_item: $ => choice(
|
||||
$.declaration,
|
||||
|
@ -191,6 +195,17 @@ module.exports = grammar({
|
|||
';'
|
||||
)),
|
||||
|
||||
last_declaration: $ => prec(1, seq(
|
||||
alias($.identifier, $.property_name),
|
||||
':',
|
||||
$._value,
|
||||
repeat(seq(
|
||||
optional(','),
|
||||
$._value
|
||||
)),
|
||||
optional($.important)
|
||||
)),
|
||||
|
||||
important: $ => '!important',
|
||||
|
||||
// Media queries
|
||||
|
|
|
@ -393,6 +393,23 @@
|
|||
"name": "_block_item"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "last_declaration"
|
||||
},
|
||||
"named": true,
|
||||
"value": "declaration"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
|
@ -926,6 +943,68 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"last_declaration": {
|
||||
"type": "PREC",
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
"named": true,
|
||||
"value": "property_name"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_value"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_value"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "important"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"important": {
|
||||
"type": "STRING",
|
||||
"value": "!important"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue