Skip to content

Commit

Permalink
port recent fixes from tree-sitter-css
Browse files Browse the repository at this point in the history
fixes Wilfred#6. fixes Wilfred#8.
  • Loading branch information
tmacwill committed Feb 3, 2022
1 parent f3174d3 commit 4bf1ed8
Show file tree
Hide file tree
Showing 7 changed files with 2,320 additions and 2,389 deletions.
27 changes: 26 additions & 1 deletion corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ a {
c: 5em;
margin: 10E3px;
margin: -456.8px;
margin: -5px;
margin: -0.0px;
}

Expand All @@ -97,6 +98,7 @@ a {
(declaration (property_name) (integer_value (unit)))
(declaration (property_name) (float_value (unit)))
(declaration (property_name) (float_value (unit)))
(declaration (property_name) (integer_value (unit)))
(declaration (property_name) (float_value (unit))))))

============================
Expand Down Expand Up @@ -240,7 +242,7 @@ a-property: calc(5px + var(--a-variable));
---

(stylesheet
(declaration (property_name) (plain_value))
(declaration (property_name) (integer_value (unit)))
(declaration (property_name) (call_expression (function_name) (arguments (binary_expression (integer_value (unit)) (call_expression (function_name) (arguments (plain_value))))))))

=================================
Expand Down Expand Up @@ -352,3 +354,26 @@ Placeholders
(name)
(block
(declaration (property_name) (integer_value (unit))))))

=============================================
Spaces after colons in property declarations
=============================================

div {
margin : 0;
padding : 0;
}

---

(stylesheet
(rule_set
(selectors
(tag_name))
(block
(declaration
(property_name)
(integer_value))
(declaration
(property_name)
(integer_value)))))
1 change: 1 addition & 0 deletions corpus/statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ Extend statements
(selectors (class_selector (class_name)))
(block (extend_statement (plain_value))
(extend_statement (class_selector (class_name))))))))

=================================
Operators
=================================
Expand Down
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ module.exports = grammar({
arguments: ($) => seq(token.immediate("("), sep(choice(",", ";"), repeat1($._value)), ")"),

identifier: ($) =>
/((#\{[a-zA-Z0-9-_,&\$\.\(\) ]*\})|[a-zA-Z-_])([a-zA-Z0-9-_]|(#\{[a-zA-Z0-9-_,&\$\.\(\) ]*\}))*/,
/((#\{[a-zA-Z0-9-_,&\$\.\(\) ]*\})|(--|-?[a-zA-Z_]))([a-zA-Z0-9-_]|(#\{[a-zA-Z0-9-_,&\$\.\(\) ]*\}))*/,

variable_identifier: ($) => /([a-zA-Z_]+\.)?\$[a-zA-Z-_][a-zA-Z0-9-_]*/,

Expand Down
2 changes: 1 addition & 1 deletion src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2462,7 +2462,7 @@
},
"identifier": {
"type": "PATTERN",
"value": "((#\\{[a-zA-Z0-9-_,&\\$\\.\\(\\) ]*\\})|[a-zA-Z-_])([a-zA-Z0-9-_]|(#\\{[a-zA-Z0-9-_,&\\$\\.\\(\\) ]*\\}))*"
"value": "((#\\{[a-zA-Z0-9-_,&\\$\\.\\(\\) ]*\\})|(--|-?[a-zA-Z_]))([a-zA-Z0-9-_]|(#\\{[a-zA-Z0-9-_,&\\$\\.\\(\\) ]*\\}))*"
},
"variable_identifier": {
"type": "PATTERN",
Expand Down
Loading

0 comments on commit 4bf1ed8

Please sign in to comment.