Allow top-level declarations
This commit is contained in:
parent
c63a7cd74a
commit
53d1095d4a
|
@ -229,3 +229,16 @@ a {
|
||||||
(integer_value (unit))
|
(integer_value (unit))
|
||||||
(integer_value (unit))
|
(integer_value (unit))
|
||||||
(integer_value (unit))))))))
|
(integer_value (unit))))))))
|
||||||
|
|
||||||
|
=================================
|
||||||
|
Declarations at the top level
|
||||||
|
=================================
|
||||||
|
|
||||||
|
--a-variable: -5px;
|
||||||
|
a-property: calc(5px + var(--a-variable));
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(stylesheet
|
||||||
|
(declaration (property_name) (plain_value))
|
||||||
|
(declaration (property_name) (call_expression (function_name) (arguments (binary_expression (integer_value (unit)) (call_expression (function_name) (arguments (plain_value))))))))
|
||||||
|
|
18
grammar.js
18
grammar.js
|
@ -10,6 +10,10 @@ module.exports = grammar({
|
||||||
$._descendant_operator,
|
$._descendant_operator,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
conflicts: $ => [
|
||||||
|
[$._selector, $.declaration],
|
||||||
|
],
|
||||||
|
|
||||||
inline: $ => [
|
inline: $ => [
|
||||||
$._top_level_item,
|
$._top_level_item,
|
||||||
$._block_item,
|
$._block_item,
|
||||||
|
@ -19,6 +23,7 @@ module.exports = grammar({
|
||||||
stylesheet: $ => repeat($._top_level_item),
|
stylesheet: $ => repeat($._top_level_item),
|
||||||
|
|
||||||
_top_level_item: $ => choice(
|
_top_level_item: $ => choice(
|
||||||
|
$.declaration,
|
||||||
$.rule_set,
|
$.rule_set,
|
||||||
$.import_statement,
|
$.import_statement,
|
||||||
$.media_statement,
|
$.media_statement,
|
||||||
|
@ -109,7 +114,14 @@ module.exports = grammar({
|
||||||
|
|
||||||
_block_item: $ => choice(
|
_block_item: $ => choice(
|
||||||
$.declaration,
|
$.declaration,
|
||||||
$._top_level_item
|
$.rule_set,
|
||||||
|
$.import_statement,
|
||||||
|
$.media_statement,
|
||||||
|
$.charset_statement,
|
||||||
|
$.namespace_statement,
|
||||||
|
$.keyframes_statement,
|
||||||
|
$.supports_statement,
|
||||||
|
$.at_rule
|
||||||
),
|
),
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
@ -186,7 +198,7 @@ module.exports = grammar({
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
declaration: $ => prec(1, seq(
|
declaration: $ => seq(
|
||||||
alias($.identifier, $.property_name),
|
alias($.identifier, $.property_name),
|
||||||
':',
|
':',
|
||||||
$._value,
|
$._value,
|
||||||
|
@ -196,7 +208,7 @@ module.exports = grammar({
|
||||||
)),
|
)),
|
||||||
optional($.important),
|
optional($.important),
|
||||||
';'
|
';'
|
||||||
)),
|
),
|
||||||
|
|
||||||
last_declaration: $ => prec(1, seq(
|
last_declaration: $ => prec(1, seq(
|
||||||
alias($.identifier, $.property_name),
|
alias($.identifier, $.property_name),
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
"_top_level_item": {
|
"_top_level_item": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "declaration"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "rule_set"
|
"name": "rule_set"
|
||||||
|
@ -439,7 +443,35 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_top_level_item"
|
"name": "rule_set"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "import_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "media_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "charset_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "namespace_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "keyframes_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "supports_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "at_rule"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -892,9 +924,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"declaration": {
|
"declaration": {
|
||||||
"type": "PREC",
|
|
||||||
"value": 1,
|
|
||||||
"content": {
|
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
|
@ -955,7 +984,6 @@
|
||||||
"value": ";"
|
"value": ";"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"last_declaration": {
|
"last_declaration": {
|
||||||
"type": "PREC",
|
"type": "PREC",
|
||||||
|
@ -1695,7 +1723,12 @@
|
||||||
"name": "comment"
|
"name": "comment"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"conflicts": [],
|
"conflicts": [
|
||||||
|
[
|
||||||
|
"_selector",
|
||||||
|
"declaration"
|
||||||
|
]
|
||||||
|
],
|
||||||
"externals": [
|
"externals": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue