Skip to content

Commit

Permalink
feat: add Copy / Paste / Environment
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Apr 24, 2024
1 parent 9534865 commit 5d878f8
Show file tree
Hide file tree
Showing 5 changed files with 2,406 additions and 1,050 deletions.
8 changes: 7 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module.exports = grammar({
$.left,
$.right,
$.set,
$.env,
$.copy,
$.paste,
$.space,
$.tab,
$.up,
Expand All @@ -30,8 +33,11 @@ module.exports = grammar({
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),
sleep: $ => seq('Sleep', $.time),
type: $ => seq('Type', optional($.speed), repeat1($.string)),
backspace: $ => seq('Backspace', optional($.speed), optional($.integer)),
Expand Down Expand Up @@ -68,7 +74,7 @@ module.exports = grammar({
seq('CursorBlink', $.boolean),
),

string: $ => choice(/"[^"]*"/, /'[^']*'/, /`[^`]*`/),
string: $ => choice(/"[^"]*"/, /'[^']*'/, /`[^`]*`/, /[A-Za-z][A-Za-z0-9_]*/),
comment: $ => /#.*/,
float: $ => /\d*\.?\d+/,
integer: $ => /\d+/,
Expand Down
51 changes: 51 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@
"type": "SYMBOL",
"name": "set"
},
{
"type": "SYMBOL",
"name": "env"
},
{
"type": "SYMBOL",
"name": "copy"
},
{
"type": "SYMBOL",
"name": "paste"
},
{
"type": "SYMBOL",
"name": "space"
Expand Down Expand Up @@ -132,6 +144,24 @@
}
]
},
"copy": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Copy"
}
]
},
"paste": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Paste"
}
]
},
"output": {
"type": "SEQ",
"members": [
Expand All @@ -158,6 +188,23 @@
}
]
},
"env": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "Env"
},
{
"type": "SYMBOL",
"name": "string"
},
{
"type": "SYMBOL",
"name": "string"
}
]
},
"sleep": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -854,6 +901,10 @@
{
"type": "PATTERN",
"value": "`[^`]*`"
},
{
"type": "PATTERN",
"value": "[A-Za-z][A-Za-z0-9_]*"
}
]
},
Expand Down
49 changes: 49 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
"type": "control",
"named": true
},
{
"type": "copy",
"named": true
},
{
"type": "down",
"named": true
Expand All @@ -46,6 +50,10 @@
"type": "enter",
"named": true
},
{
"type": "env",
"named": true
},
{
"type": "escape",
"named": true
Expand All @@ -70,6 +78,10 @@
"type": "pageup",
"named": true
},
{
"type": "paste",
"named": true
},
{
"type": "right",
"named": true
Expand Down Expand Up @@ -109,6 +121,11 @@
]
}
},
{
"type": "copy",
"named": true,
"fields": {}
},
{
"type": "down",
"named": true,
Expand Down Expand Up @@ -147,6 +164,21 @@
]
}
},
{
"type": "env",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "string",
"named": true
}
]
}
},
{
"type": "escape",
"named": true,
Expand Down Expand Up @@ -243,6 +275,11 @@
]
}
},
{
"type": "paste",
"named": true,
"fields": {}
},
{
"type": "program",
"named": true,
Expand Down Expand Up @@ -463,6 +500,10 @@
"type": "BorderRadius",
"named": false
},
{
"type": "Copy",
"named": false
},
{
"type": "CursorBlink",
"named": false
Expand All @@ -475,6 +516,10 @@
"type": "Enter",
"named": false
},
{
"type": "Env",
"named": false
},
{
"type": "Escape",
"named": false
Expand Down Expand Up @@ -539,6 +584,10 @@
"type": "PageUp",
"named": false
},
{
"type": "Paste",
"named": false
},
{
"type": "PlaybackSpeed",
"named": false
Expand Down
Loading

0 comments on commit 5d878f8

Please sign in to comment.