Skip to content

Commit

Permalink
fix: inline anonymous nodes (#13)
Browse files Browse the repository at this point in the history
Problem: The "trick" of wrapping an anonymous node into a single `choice` or `seq` no longer works as of tree-sitter/tree-sitter#2577

Solution: Inline anonymous nodes.
  • Loading branch information
clason authored Aug 17, 2024
1 parent 90028bb commit 780a8a2
Show file tree
Hide file tree
Showing 7 changed files with 1,249 additions and 1,114 deletions.
12 changes: 4 additions & 8 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module.exports = grammar({
$.control,
$.shift,
$.alt,
$.hide,
$.show,
'Hide',
'Show',
$.output,
$.sleep,
$.type,
Expand All @@ -19,8 +19,8 @@ module.exports = grammar({
$.right,
$.set,
$.env,
$.copy,
$.paste,
'Copy',
'Paste',
$.space,
$.tab,
$.up,
Expand All @@ -31,10 +31,6 @@ module.exports = grammar({
control: $ => /Ctrl\+(Alt\+)?(Shift\+)?([A-Z]|Enter)/,
alt: $ => /Alt\+(Shift\+)?([A-Z]|Enter|Tab)/,
shift: $ => /Shift\+([A-Z]|Enter|Tab)/,
hide: $ => seq('Hide'),
show: $ => seq('Show'),
copy: $ => seq('Copy'),
paste: $ => seq('Paste'),
output: $ => seq('Output', $.path),
set: $ => seq('Set', $.setting),
env: $ => seq('Env', $.string, $.string),
Expand Down
53 changes: 8 additions & 45 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"name": "alt"
},
{
"type": "SYMBOL",
"name": "hide"
"type": "STRING",
"value": "Hide"
},
{
"type": "SYMBOL",
"name": "show"
"type": "STRING",
"value": "Show"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -85,12 +85,12 @@
"name": "env"
},
{
"type": "SYMBOL",
"name": "copy"
"type": "STRING",
"value": "Copy"
},
{
"type": "SYMBOL",
"name": "paste"
"type": "STRING",
"value": "Paste"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -126,42 +126,6 @@
"type": "PATTERN",
"value": "Shift\\+([A-Z]|Enter|Tab)"
},
"hide": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Hide"
}
]
},
"show": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Show"
}
]
},
"copy": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Copy"
}
]
},
"paste": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Paste"
}
]
},
"output": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -962,4 +926,3 @@
"inline": [],
"supertypes": []
}

38 changes: 1 addition & 37 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"fields": {},
"children": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "alt",
Expand All @@ -38,10 +38,6 @@
"type": "control",
"named": true
},
{
"type": "copy",
"named": true
},
{
"type": "down",
"named": true
Expand All @@ -58,10 +54,6 @@
"type": "escape",
"named": true
},
{
"type": "hide",
"named": true
},
{
"type": "left",
"named": true
Expand All @@ -78,10 +70,6 @@
"type": "pageup",
"named": true
},
{
"type": "paste",
"named": true
},
{
"type": "right",
"named": true
Expand All @@ -94,10 +82,6 @@
"type": "shift",
"named": true
},
{
"type": "show",
"named": true
},
{
"type": "sleep",
"named": true
Expand All @@ -121,11 +105,6 @@
]
}
},
{
"type": "copy",
"named": true,
"fields": {}
},
{
"type": "down",
"named": true,
Expand Down Expand Up @@ -198,11 +177,6 @@
]
}
},
{
"type": "hide",
"named": true,
"fields": {}
},
{
"type": "left",
"named": true,
Expand Down Expand Up @@ -275,11 +249,6 @@
]
}
},
{
"type": "paste",
"named": true,
"fields": {}
},
{
"type": "program",
"named": true,
Expand Down Expand Up @@ -368,11 +337,6 @@
]
}
},
{
"type": "show",
"named": true,
"fields": {}
},
{
"type": "sleep",
"named": true,
Expand Down
Loading

0 comments on commit 780a8a2

Please sign in to comment.