Skip to content

Commit

Permalink
Update to the latest parser version
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Nov 28, 2023
1 parent 09391dd commit ba06f10
Show file tree
Hide file tree
Showing 13 changed files with 7,073 additions and 5,292 deletions.
3 changes: 2 additions & 1 deletion .ignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/
src/*
!src/scanner.c
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
corpus
examples
build
examples
target
test
27 changes: 0 additions & 27 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,5 @@ module.exports = grammar(CSS, {
_js_block: $ => seq("{", repeat($._js_statement), "}"),

_js_statement: $ => /[^{}]+/,

// FIXME: Remove once https://github.com/tree-sitter/tree-sitter-css/pull/30 is merged
pseudo_element_selector: $ =>
seq(
optional($._selector),
"::",
alias($.identifier, $.tag_name),
optional(alias($.pseudo_element_arguments, $.arguments))
),

// FIXME: Remove once https://github.com/tree-sitter/tree-sitter-css/pull/30 is merged
pseudo_element_arguments: $ =>
seq(
token.immediate("("),
sep(",", choice($._selector, repeat1($._value))),
")"
),
},
})

// FIXME: Remove once https://github.com/tree-sitter/tree-sitter-css/pull/30 is merged
function sep(separator, rule) {
return optional(sep1(separator, rule))
}

// FIXME: Remove once https://github.com/tree-sitter/tree-sitter-css/pull/30 is merged
function sep1(separator, rule) {
return seq(rule, repeat(seq(separator, rule)))
}
2 changes: 2 additions & 0 deletions scripts/update-parser.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

npm update tree-sitter-css
npm ci

Expand Down
244 changes: 162 additions & 82 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@
{
"type": "SYMBOL",
"name": "adjacent_sibling_selector"
},
{
"type": "SYMBOL",
"name": "namespace_selector"
}
]
},
Expand Down Expand Up @@ -613,7 +617,12 @@
]
},
{
"type": "STRING",
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_pseudo_class_selector_colon"
},
"named": false,
"value": ":"
},
{
Expand Down Expand Up @@ -743,8 +752,17 @@
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "namespace_selector"
}
]
},
"named": true,
"value": "attribute_name"
Expand Down Expand Up @@ -885,6 +903,27 @@
]
}
},
"namespace_selector": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "STRING",
"value": "|"
},
{
"type": "SYMBOL",
"name": "_selector"
}
]
}
},
"pseudo_class_arguments": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -958,6 +997,79 @@
}
]
},
"pseudo_element_arguments": {
"type": "SEQ",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "("
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
}
]
}
]
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ")"
}
]
},
"declaration": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -1282,6 +1394,10 @@
"type": "SYMBOL",
"name": "string_value"
},
{
"type": "SYMBOL",
"name": "grid_value"
},
{
"type": "SYMBOL",
"name": "binary_expression"
Expand Down Expand Up @@ -1564,6 +1680,44 @@
"value": "[a-zA-Z%]+"
}
},
"grid_value": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_value"
}
]
}
}
]
},
{
"type": "STRING",
"value": "]"
}
]
},
"call_expression": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -1852,79 +2006,6 @@
"_js_statement": {
"type": "PATTERN",
"value": "[^{}]+"
},
"pseudo_element_arguments": {
"type": "SEQ",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "("
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
}
]
}
]
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ")"
}
]
}
},
"extras": [
Expand All @@ -1937,17 +2018,16 @@
"name": "comment"
}
],
"conflicts": [
[
"_selector",
"declaration"
]
],
"conflicts": [],
"precedences": [],
"externals": [
{
"type": "SYMBOL",
"name": "_descendant_operator"
},
{
"type": "SYMBOL",
"name": "_pseudo_class_selector_colon"
}
],
"inline": [
Expand Down
Loading

0 comments on commit ba06f10

Please sign in to comment.