Skip to content

Commit

Permalink
add support for @apply statements
Browse files Browse the repository at this point in the history
fixes #5.
  • Loading branch information
tmacwill committed Feb 3, 2022
1 parent 4bf1ed8 commit c478c68
Show file tree
Hide file tree
Showing 5 changed files with 7,901 additions and 7,519 deletions.
11 changes: 11 additions & 0 deletions corpus/statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ Extend statements
(block (extend_statement (plain_value))
(extend_statement (class_selector (class_name))))))))

==============================
Apply statements
==============================

@apply fill-red-50 border-black col-span-1;

---

(stylesheet
(apply_statement (plain_value) (plain_value) (plain_value)))

=================================
Operators
=================================
Expand Down
3 changes: 3 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = grammar({
$.supports_statement,
$.use_statement,
$.forward_statement,
$.apply_statement,
$.mixin_statement,
$.include_statement,
$.if_statement,
Expand Down Expand Up @@ -76,6 +77,8 @@ module.exports = grammar({

forward_statement: ($) => seq("@forward", $._value, ";"),

apply_statement: ($) => seq("@apply", repeat($._value), ";"),

parameters: ($) => seq("(", sep1(",", $.parameter), ")"),

parameter: ($) =>
Expand Down
24 changes: 24 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
"type": "SYMBOL",
"name": "forward_statement"
},
{
"type": "SYMBOL",
"name": "apply_statement"
},
{
"type": "SYMBOL",
"name": "mixin_statement"
Expand Down Expand Up @@ -445,6 +449,26 @@
}
]
},
"apply_statement": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@apply"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_value"
}
},
{
"type": "STRING",
"value": ";"
}
]
},
"parameters": {
"type": "SEQ",
"members": [
Expand Down
55 changes: 55 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,53 @@
]
}
},
{
"type": "apply_statement",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "call_expression",
"named": true
},
{
"type": "color_value",
"named": true
},
{
"type": "float_value",
"named": true
},
{
"type": "integer_value",
"named": true
},
{
"type": "parenthesized_value",
"named": true
},
{
"type": "plain_value",
"named": true
},
{
"type": "string_value",
"named": true
},
{
"type": "variable_value",
"named": true
}
]
}
},
{
"type": "argument",
"named": true,
Expand Down Expand Up @@ -2366,6 +2413,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": "apply_statement",
"named": true
},
{
"type": "at_rule",
"named": true
Expand Down Expand Up @@ -2816,6 +2867,10 @@
"type": ">=",
"named": false
},
{
"type": "@apply",
"named": false
},
{
"type": "@at-root",
"named": false
Expand Down
Loading

0 comments on commit c478c68

Please sign in to comment.