Add only operator query operator

This commit is contained in:
Max Brunsfeld 2018-10-29 15:46:58 -07:00
parent 5318a21441
commit b0d6e676cb
4 changed files with 1417 additions and 1244 deletions

View File

@ -69,6 +69,7 @@ Media statements
@media screen and (min-width: 30em) and (orientation: landscape) {} @media screen and (min-width: 30em) and (orientation: landscape) {}
@media (min-height: 680px), screen and (orientation: portrait) {} @media (min-height: 680px), screen and (orientation: portrait) {}
@media not all and (monochrome) {} @media not all and (monochrome) {}
@media only screen {}
--- ---
@ -85,8 +86,9 @@ Media statements
(binary_query (keyword_query) (feature_query (feature_name) (plain_value))) (binary_query (keyword_query) (feature_query (feature_name) (plain_value)))
(block)) (block))
(media_statement (media_statement
(binary_query (negated_query (keyword_query)) (parenthesized_query (keyword_query))) (binary_query (unary_query (keyword_query)) (parenthesized_query (keyword_query)))
(block))) (block))
(media_statement (unary_query (keyword_query)) (block)))
============================== ==============================
Supports statements Supports statements
@ -113,12 +115,12 @@ Supports statements
(feature_query (feature_name) (plain_value))) (feature_query (feature_name) (plain_value)))
(block)) (block))
(supports_statement (supports_statement
(negated_query (parenthesized_query (binary_query (unary_query (parenthesized_query (binary_query
(feature_query (feature_name) (plain_value)) (feature_query (feature_name) (plain_value))
(feature_query (feature_name) (plain_value))))) (feature_query (feature_name) (plain_value)))))
(block)) (block))
(supports_statement (supports_statement
(negated_query (selector_query (pseudo_class_selector (unary_query (selector_query (pseudo_class_selector
(class_name) (class_name)
(arguments (tag_name) (tag_name))))) (arguments (tag_name) (tag_name)))))
(block))) (block)))

View File

@ -214,7 +214,7 @@ module.exports = grammar({
alias($.identifier, $.keyword_query), alias($.identifier, $.keyword_query),
$.feature_query, $.feature_query,
$.binary_query, $.binary_query,
$.negated_query, $.unary_query,
$.selector_query, $.selector_query,
$.parenthesized_query $.parenthesized_query
), ),
@ -239,8 +239,8 @@ module.exports = grammar({
$._query $._query
)), )),
negated_query: $ => prec(1, seq( unary_query: $ => prec(1, seq(
'not', choice('not', 'only'),
$._query $._query
)), )),

17
src/grammar.json vendored
View File

@ -1031,7 +1031,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "negated_query" "name": "unary_query"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -1120,15 +1120,24 @@
] ]
} }
}, },
"negated_query": { "unary_query": {
"type": "PREC", "type": "PREC",
"value": 1, "value": 1,
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "STRING", "type": "CHOICE",
"value": "not" "members": [
{
"type": "STRING",
"value": "not"
},
{
"type": "STRING",
"value": "only"
}
]
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",

2628
src/parser.c vendored

File diff suppressed because it is too large Load Diff