Add @supports statements

This commit is contained in:
Max Brunsfeld 2018-10-26 14:01:52 -07:00
parent e4fefc4022
commit 751c870b80
4 changed files with 3984 additions and 3261 deletions

View File

@ -88,6 +88,41 @@ Media statements
(binary_query (negated_query (keyword_query)) (parenthesized_query (keyword_query))) (binary_query (negated_query (keyword_query)) (parenthesized_query (keyword_query)))
(block))) (block)))
==============================
Supports statements
==============================
@supports (animation-name: test) {
div { animation-name: test; }
}
@supports (transform-style: preserve) or (-moz-transform-style: preserve) {}
@supports not ((text-align-last: justify) or (-moz-text-align-last: justify)) {}
@supports not selector(:matches(a, b)) {}
---
(stylesheet
(supports_statement
(feature_query (feature_name) (plain_value))
(block
(rule_set (selectors (tag_name)) (block
(declaration (property_name) (plain_value))))))
(supports_statement
(binary_query
(feature_query (feature_name) (plain_value))
(feature_query (feature_name) (plain_value)))
(block))
(supports_statement
(negated_query (parenthesized_query (binary_query
(feature_query (feature_name) (plain_value))
(feature_query (feature_name) (plain_value)))))
(block))
(supports_statement
(negated_query (selector_query (pseudo_class_selector
(class_name)
(arguments (plain_value) (plain_value)))))
(block)))
============================== ==============================
Charset statements Charset statements
============================== ==============================

View File

@ -25,6 +25,7 @@ module.exports = grammar({
$.charset_statement, $.charset_statement,
$.namespace_statement, $.namespace_statement,
$.keyframes_statement, $.keyframes_statement,
$.supports_statement,
$.at_rule $.at_rule
), ),
@ -76,6 +77,12 @@ module.exports = grammar({
from: $ => 'from', from: $ => 'from',
to: $ => 'to', to: $ => 'to',
supports_statement: $ => seq(
'@supports',
$._query,
$.block
),
at_rule: $ => seq( at_rule: $ => seq(
$.at_keyword, $.at_keyword,
commaSep($._query), commaSep($._query),
@ -181,6 +188,7 @@ module.exports = grammar({
$.feature_query, $.feature_query,
$.binary_query, $.binary_query,
$.negated_query, $.negated_query,
$.selector_query,
$.parenthesized_query $.parenthesized_query
), ),
@ -209,6 +217,13 @@ module.exports = grammar({
$._query $._query
)), )),
selector_query: $ => seq(
'selector',
'(',
$._selector,
')'
),
// Property Values // Property Values
_value: $ => choice( _value: $ => choice(

46
src/grammar.json vendored
View File

@ -35,6 +35,10 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "keyframes_statement" "name": "keyframes_statement"
}, },
{
"type": "SYMBOL",
"name": "supports_statement"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "at_rule" "name": "at_rule"
@ -265,6 +269,23 @@
"type": "STRING", "type": "STRING",
"value": "to" "value": "to"
}, },
"supports_statement": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@supports"
},
{
"type": "SYMBOL",
"name": "_query"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"at_rule": { "at_rule": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -801,6 +822,10 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "negated_query" "name": "negated_query"
}, },
{
"type": "SYMBOL",
"name": "selector_query"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "parenthesized_query" "name": "parenthesized_query"
@ -901,6 +926,27 @@
] ]
} }
}, },
"selector_query": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "selector"
},
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "STRING",
"value": ")"
}
]
},
"_value": { "_value": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [

7149
src/parser.c vendored

File diff suppressed because it is too large Load Diff