demotape 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tests.yml +1 -1
- data/.gitignore +8 -0
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +2 -2
- data/README.md +19 -10
- data/editors/sublime-text/DemoTape.sublime-syntax +1 -1
- data/editors/vim/ftdetect/demotape.vim +1 -1
- data/editors/vim/syntax/demotape.vim +1 -1
- data/editors/vscode/LICENSE.md +20 -0
- data/editors/vscode/README.md +12 -2
- data/editors/vscode/RELEASE_PROCESS.md +10 -0
- data/editors/vscode/demotape.tmLanguage.json +7 -6
- data/editors/vscode/icon.png +0 -0
- data/editors/vscode/package.json +20 -4
- data/editors/zed/extension.toml +12 -0
- data/editors/zed/grammars/demotape.wasm +0 -0
- data/editors/zed/languages/demotape/config.toml +11 -0
- data/editors/zed/languages/demotape/highlights.scm +70 -0
- data/editors/zed/package-lock.json +6 -0
- data/editors/zed/tree-sitter/Cargo.toml +26 -0
- data/editors/zed/tree-sitter/binding.gyp +19 -0
- data/editors/zed/tree-sitter/bindings/node/binding.cc +28 -0
- data/editors/zed/tree-sitter/bindings/node/index.js +19 -0
- data/editors/zed/tree-sitter/bindings/rust/build.rs +40 -0
- data/editors/zed/tree-sitter/bindings/rust/lib.rs +52 -0
- data/editors/zed/tree-sitter/grammar.js +227 -0
- data/editors/zed/tree-sitter/package-lock.json +36 -0
- data/editors/zed/tree-sitter/package.json +27 -0
- data/editors/zed/tree-sitter/queries/highlights.scm +70 -0
- data/editors/zed/tree-sitter/src/grammar.json +1123 -0
- data/editors/zed/tree-sitter/src/node-types.json +862 -0
- data/editors/zed/tree-sitter/src/parser.c +9337 -0
- data/editors/zed/tree-sitter/src/tree_sitter/parser.h +224 -0
- data/exe/demotape +1 -0
- data/lib/demo_tape/cli.rb +10 -2
- data/lib/demo_tape/command.rb +1 -1
- data/lib/demo_tape/ext/thor.rb +17 -0
- data/lib/demo_tape/version.rb +1 -1
- metadata +28 -7
- data/demotape_new.y.backup +0 -160
- data/demotape_simple_test.y +0 -32
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
module.exports = grammar({
|
|
2
|
+
name: 'demotape',
|
|
3
|
+
|
|
4
|
+
extras: $ => [
|
|
5
|
+
/\s/,
|
|
6
|
+
],
|
|
7
|
+
|
|
8
|
+
rules: {
|
|
9
|
+
source_file: $ => repeat(choice(
|
|
10
|
+
$.comment,
|
|
11
|
+
$.group_block,
|
|
12
|
+
$.command,
|
|
13
|
+
$.newline,
|
|
14
|
+
)),
|
|
15
|
+
|
|
16
|
+
newline: $ => /\r?\n/,
|
|
17
|
+
|
|
18
|
+
comment: $ => /#.*/,
|
|
19
|
+
|
|
20
|
+
// Group blocks
|
|
21
|
+
group_block: $ => seq(
|
|
22
|
+
'Group',
|
|
23
|
+
field('name', $.identifier),
|
|
24
|
+
'do',
|
|
25
|
+
repeat(choice(
|
|
26
|
+
$.comment,
|
|
27
|
+
$.command,
|
|
28
|
+
$.newline,
|
|
29
|
+
)),
|
|
30
|
+
'end'
|
|
31
|
+
),
|
|
32
|
+
|
|
33
|
+
identifier: $ => /[a-z_][a-z0-9_]*/,
|
|
34
|
+
|
|
35
|
+
// Commands
|
|
36
|
+
command: $ => choice(
|
|
37
|
+
$.type_command,
|
|
38
|
+
$.run_command,
|
|
39
|
+
$.wait_until_command,
|
|
40
|
+
$.type_file_command,
|
|
41
|
+
$.set_command,
|
|
42
|
+
$.output_command,
|
|
43
|
+
$.copy_command,
|
|
44
|
+
$.paste_command,
|
|
45
|
+
$.send_command,
|
|
46
|
+
$.include_command,
|
|
47
|
+
$.screenshot_command,
|
|
48
|
+
$.wait_command,
|
|
49
|
+
$.sleep_command,
|
|
50
|
+
$.require_command,
|
|
51
|
+
$.pause_command,
|
|
52
|
+
$.resume_command,
|
|
53
|
+
$.clear_command,
|
|
54
|
+
$.key_command,
|
|
55
|
+
$.group_invocation,
|
|
56
|
+
),
|
|
57
|
+
|
|
58
|
+
// Group invocation
|
|
59
|
+
group_invocation: $ => seq(
|
|
60
|
+
field('group', $.identifier),
|
|
61
|
+
),
|
|
62
|
+
|
|
63
|
+
// Type command
|
|
64
|
+
type_command: $ => seq(
|
|
65
|
+
'Type',
|
|
66
|
+
optional($.duration_modifier),
|
|
67
|
+
field('text', $.string),
|
|
68
|
+
),
|
|
69
|
+
|
|
70
|
+
// TypeFile command
|
|
71
|
+
type_file_command: $ => seq(
|
|
72
|
+
'TypeFile',
|
|
73
|
+
optional($.duration_modifier),
|
|
74
|
+
field('path', $.string),
|
|
75
|
+
),
|
|
76
|
+
|
|
77
|
+
// Run command
|
|
78
|
+
run_command: $ => seq(
|
|
79
|
+
'Run',
|
|
80
|
+
optional($.duration_modifier),
|
|
81
|
+
field('command', $.string),
|
|
82
|
+
),
|
|
83
|
+
|
|
84
|
+
// WaitUntil command
|
|
85
|
+
wait_until_command: $ => seq(
|
|
86
|
+
'WaitUntil',
|
|
87
|
+
optional($.duration_modifier),
|
|
88
|
+
field('pattern', $.regex),
|
|
89
|
+
),
|
|
90
|
+
|
|
91
|
+
// Set command
|
|
92
|
+
set_command: $ => seq(
|
|
93
|
+
'Set',
|
|
94
|
+
field('option', $.set_option),
|
|
95
|
+
field('value', choice(
|
|
96
|
+
$.string,
|
|
97
|
+
$.number,
|
|
98
|
+
$.duration,
|
|
99
|
+
$.boolean,
|
|
100
|
+
$.unquoted_string,
|
|
101
|
+
)),
|
|
102
|
+
optional(seq(',', field('value', choice($.number, $.duration)))),
|
|
103
|
+
optional(seq(',', field('value', choice($.number, $.duration)))),
|
|
104
|
+
optional(seq(',', field('value', choice($.number, $.duration)))),
|
|
105
|
+
),
|
|
106
|
+
|
|
107
|
+
set_option: $ => /[a-z_]+(\.[a-z_]+)?/,
|
|
108
|
+
|
|
109
|
+
// Output command
|
|
110
|
+
output_command: $ => seq(
|
|
111
|
+
'Output',
|
|
112
|
+
field('path', $.string),
|
|
113
|
+
),
|
|
114
|
+
|
|
115
|
+
// Copy command
|
|
116
|
+
copy_command: $ => seq(
|
|
117
|
+
'Copy',
|
|
118
|
+
field('text', $.string),
|
|
119
|
+
),
|
|
120
|
+
|
|
121
|
+
// Paste command
|
|
122
|
+
paste_command: $ => 'Paste',
|
|
123
|
+
|
|
124
|
+
// Send command
|
|
125
|
+
send_command: $ => seq(
|
|
126
|
+
'Send',
|
|
127
|
+
field('text', $.string),
|
|
128
|
+
),
|
|
129
|
+
|
|
130
|
+
// Include command
|
|
131
|
+
include_command: $ => seq(
|
|
132
|
+
'Include',
|
|
133
|
+
field('path', $.string),
|
|
134
|
+
),
|
|
135
|
+
|
|
136
|
+
// Screenshot command
|
|
137
|
+
screenshot_command: $ => seq(
|
|
138
|
+
'Screenshot',
|
|
139
|
+
optional(field('path', $.string)),
|
|
140
|
+
),
|
|
141
|
+
|
|
142
|
+
// Wait/Sleep commands
|
|
143
|
+
wait_command: $ => seq(
|
|
144
|
+
'Wait',
|
|
145
|
+
field('duration', choice($.number, $.duration)),
|
|
146
|
+
),
|
|
147
|
+
|
|
148
|
+
sleep_command: $ => seq(
|
|
149
|
+
'Sleep',
|
|
150
|
+
field('duration', choice($.number, $.duration)),
|
|
151
|
+
),
|
|
152
|
+
|
|
153
|
+
// Require command
|
|
154
|
+
require_command: $ => seq(
|
|
155
|
+
'Require',
|
|
156
|
+
field('command', choice($.string, $.identifier)),
|
|
157
|
+
),
|
|
158
|
+
|
|
159
|
+
// Control commands
|
|
160
|
+
pause_command: $ => 'Pause',
|
|
161
|
+
resume_command: $ => 'Resume',
|
|
162
|
+
clear_command: $ => 'Clear',
|
|
163
|
+
|
|
164
|
+
// Key commands
|
|
165
|
+
key_command: $ => seq(
|
|
166
|
+
field('key', $.key_combination),
|
|
167
|
+
optional($.duration_modifier),
|
|
168
|
+
optional(field('count', $.number)),
|
|
169
|
+
),
|
|
170
|
+
|
|
171
|
+
key_combination: $ => choice(
|
|
172
|
+
$.special_key,
|
|
173
|
+
$.modifier_key,
|
|
174
|
+
seq(
|
|
175
|
+
choice($.modifier_key, $.letter_key),
|
|
176
|
+
repeat1(seq('+', choice($.modifier_key, $.special_key, $.letter_key))),
|
|
177
|
+
),
|
|
178
|
+
),
|
|
179
|
+
|
|
180
|
+
special_key: $ => choice(
|
|
181
|
+
'Enter', 'Return', 'Tab', 'Backspace', 'Delete', 'Escape', 'Esc',
|
|
182
|
+
'Space', 'Up', 'Down', 'Left', 'Right', 'Home', 'End',
|
|
183
|
+
'PageUp', 'PageDown', 'Insert', 'Cancel', 'Help',
|
|
184
|
+
'Semicolon', 'Colon', 'Equals', 'Slash', 'BackSlash',
|
|
185
|
+
/Numpad[0-9]/, 'Multiply', 'Add', 'Separator', 'Subtract', 'Decimal', 'Divide',
|
|
186
|
+
/F([1-9]|1[0-2])/,
|
|
187
|
+
),
|
|
188
|
+
|
|
189
|
+
modifier_key: $ => choice(
|
|
190
|
+
'Ctrl', 'Control', 'Alt', 'Option', 'Shift', 'Meta', 'Command'
|
|
191
|
+
),
|
|
192
|
+
|
|
193
|
+
letter_key: $ => /[A-Za-z0-9]/,
|
|
194
|
+
|
|
195
|
+
// Modifiers
|
|
196
|
+
duration_modifier: $ => seq('@', field('duration', choice($.duration, $.number))),
|
|
197
|
+
|
|
198
|
+
// Literals
|
|
199
|
+
string: $ => choice(
|
|
200
|
+
seq('"""', field('content', /([^"]|"[^"]|""[^"])*?/), '"""'),
|
|
201
|
+
seq('"', field('content', repeat(choice(/[^"\\]+/, $.escape_sequence))), '"'),
|
|
202
|
+
seq("'", field('content', repeat(choice(/[^'\\]+/, $.escape_sequence))), "'"),
|
|
203
|
+
),
|
|
204
|
+
|
|
205
|
+
escape_sequence: $ => token(seq(
|
|
206
|
+
'\\',
|
|
207
|
+
choice(
|
|
208
|
+
/[ntr\\"']/,
|
|
209
|
+
/u[0-9a-fA-F]{4}/,
|
|
210
|
+
/U[0-9a-fA-F]{8}/,
|
|
211
|
+
)
|
|
212
|
+
)),
|
|
213
|
+
|
|
214
|
+
unquoted_string: $ => /[a-zA-Z_]\w*/,
|
|
215
|
+
|
|
216
|
+
regex: $ => /\/([^\/\\]|\\.)*\//,
|
|
217
|
+
|
|
218
|
+
duration: $ => token(seq(
|
|
219
|
+
/\d+(\.\d+)?/,
|
|
220
|
+
choice('ms', 's', 'm', 'h'),
|
|
221
|
+
)),
|
|
222
|
+
|
|
223
|
+
number: $ => /\d+(\.\d+)?/,
|
|
224
|
+
|
|
225
|
+
boolean: $ => choice('true', 'false'),
|
|
226
|
+
}
|
|
227
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tree-sitter-demotape",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "tree-sitter-demotape",
|
|
9
|
+
"version": "0.0.1",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"nan": "^2.14.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"tree-sitter-cli": "^0.20.0"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"node_modules/nan": {
|
|
19
|
+
"version": "2.23.1",
|
|
20
|
+
"resolved": "https://registry.npmjs.org/nan/-/nan-2.23.1.tgz",
|
|
21
|
+
"integrity": "sha512-r7bBUGKzlqk8oPBDYxt6Z0aEdF1G1rwlMcLk8LCOMbOzf0mG+JUfUzG4fIMWwHWP0iyaLWEQZJmtB7nOHEm/qw==",
|
|
22
|
+
"license": "MIT"
|
|
23
|
+
},
|
|
24
|
+
"node_modules/tree-sitter-cli": {
|
|
25
|
+
"version": "0.20.8",
|
|
26
|
+
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.8.tgz",
|
|
27
|
+
"integrity": "sha512-XjTcS3wdTy/2cc/ptMLc/WRyOLECRYcMTrSWyhZnj1oGSOWbHLTklgsgRICU3cPfb0vy+oZCC33M43u6R1HSCA==",
|
|
28
|
+
"dev": true,
|
|
29
|
+
"hasInstallScript": true,
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"bin": {
|
|
32
|
+
"tree-sitter": "cli.js"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "demotape",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Tree-sitter grammar for DemoTape",
|
|
5
|
+
"main": "bindings/node",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"tree-sitter",
|
|
8
|
+
"demotape",
|
|
9
|
+
"parser"
|
|
10
|
+
],
|
|
11
|
+
"author": "Nando Vieira <me@fnando.com>",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"nan": "^2.14.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"tree-sitter-cli": "^0.20.0"
|
|
18
|
+
},
|
|
19
|
+
"tree-sitter": [
|
|
20
|
+
{
|
|
21
|
+
"scope": "source.demotape",
|
|
22
|
+
"file-types": [
|
|
23
|
+
"tape"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
; Comments
|
|
2
|
+
(comment) @comment
|
|
3
|
+
|
|
4
|
+
; Command keywords - using string literals
|
|
5
|
+
"Type" @keyword
|
|
6
|
+
"TypeFile" @keyword
|
|
7
|
+
"Run" @keyword
|
|
8
|
+
"WaitUntil" @keyword
|
|
9
|
+
"Set" @keyword
|
|
10
|
+
"Output" @keyword
|
|
11
|
+
"Copy" @keyword
|
|
12
|
+
"Send" @keyword
|
|
13
|
+
"Include" @keyword
|
|
14
|
+
"Screenshot" @keyword
|
|
15
|
+
"Wait" @keyword
|
|
16
|
+
"Sleep" @keyword
|
|
17
|
+
"Require" @keyword
|
|
18
|
+
"Group" @keyword
|
|
19
|
+
"do" @keyword
|
|
20
|
+
"end" @keyword
|
|
21
|
+
|
|
22
|
+
; Command keywords - simple commands (just the literal)
|
|
23
|
+
(paste_command) @keyword
|
|
24
|
+
(pause_command) @keyword
|
|
25
|
+
(resume_command) @keyword
|
|
26
|
+
(clear_command) @keyword
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
; Group blocks
|
|
30
|
+
(group_block
|
|
31
|
+
name: (identifier) @function)
|
|
32
|
+
(group_invocation
|
|
33
|
+
group: (identifier) @function)
|
|
34
|
+
|
|
35
|
+
; Keys
|
|
36
|
+
(special_key) @constant
|
|
37
|
+
(modifier_key) @constant
|
|
38
|
+
(letter_key) @constant
|
|
39
|
+
|
|
40
|
+
; Operators
|
|
41
|
+
"@" @operator
|
|
42
|
+
"+" @operator
|
|
43
|
+
"," @punctuation.delimiter
|
|
44
|
+
|
|
45
|
+
; Strings
|
|
46
|
+
(string) @string
|
|
47
|
+
(escape_sequence) @string.escape
|
|
48
|
+
(unquoted_string) @string
|
|
49
|
+
|
|
50
|
+
; Regex
|
|
51
|
+
(regex) @string.regex
|
|
52
|
+
|
|
53
|
+
; Numbers and durations
|
|
54
|
+
(number) @number
|
|
55
|
+
(duration) @number
|
|
56
|
+
|
|
57
|
+
; Booleans
|
|
58
|
+
(boolean) @boolean
|
|
59
|
+
|
|
60
|
+
; Set options
|
|
61
|
+
(set_command
|
|
62
|
+
option: (set_option) @constant)
|
|
63
|
+
|
|
64
|
+
; Identifiers
|
|
65
|
+
(identifier) @variable
|
|
66
|
+
|
|
67
|
+
; Force highlight for problematic words with higher priority
|
|
68
|
+
((set_option) @constant
|
|
69
|
+
(#match? @constant "^(height|margin)$")
|
|
70
|
+
(#set! "priority" 200))
|