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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7a68e716ef2ec6d5115371bc0e836e25cbe4e19b20e2c3d7d514b4909dafa6a
|
|
4
|
+
data.tar.gz: 989fb3ed0c2ad24c30dbedcf706d6d4b51475e58796bfd1dfd8bef6ca6710a7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58bc92cd8ce53899ddcd6a56e24113697987b1ae6b9ea71edf5c05e3a1f1560c412c66c4306a67cc3f13769169fdd1fa2c591fbbdca4d09ccd27a54c5deb69b3
|
|
7
|
+
data.tar.gz: 18f8f3cd2420a788b527677da604aa0b68bdd9aa99755981a01e378a3fdb7592c4582916969b9814714daec45b40832afb481e06ce1b7d0b01a7d22c9e6d0889
|
data/.gitignore
CHANGED
|
@@ -13,3 +13,11 @@
|
|
|
13
13
|
examples/themes/*.mp4
|
|
14
14
|
/themes.json
|
|
15
15
|
*.sw*
|
|
16
|
+
*.vsix
|
|
17
|
+
|
|
18
|
+
# Tree-sitter
|
|
19
|
+
editors/zed/tree-sitter/node_modules/
|
|
20
|
+
editors/zed/tree-sitter/build/
|
|
21
|
+
editors/zed/tree-sitter/*.node
|
|
22
|
+
editors/zed/grammars/demotape
|
|
23
|
+
editors/zed/tree-sitter/examples
|
data/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,12 @@ Prefix your message with one of the following:
|
|
|
11
11
|
- [Security] in case of vulnerabilities.
|
|
12
12
|
-->
|
|
13
13
|
|
|
14
|
+
## v0.0.4
|
|
15
|
+
|
|
16
|
+
- [Fixed] Fix how Thor handle defaults for arrays.
|
|
17
|
+
- [Fixed] Fix reading tapes from stdin.
|
|
18
|
+
- [Fixed] Fix `demotape help run` to expand to `_run`.
|
|
19
|
+
|
|
14
20
|
## v0.0.3
|
|
15
21
|
|
|
16
22
|
- [Changed] Re-implemented parser.
|
data/CONTRIBUTING.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Contributing to
|
|
1
|
+
# Contributing to Demo Tape
|
|
2
2
|
|
|
3
3
|
👍🎉 First off, thanks for taking the time to contribute! 🎉👍
|
|
4
4
|
|
|
@@ -32,7 +32,7 @@ by [opening an issue on Github](https://github.com/fnando/demotape/issues).
|
|
|
32
32
|
When you're ready to make your pull request, follow checklist below to make sure
|
|
33
33
|
your contribution is according to how this project works.
|
|
34
34
|
|
|
35
|
-
1. [Fork](https://help.github.com/forking/)
|
|
35
|
+
1. [Fork](https://help.github.com/forking/) Demo Tape
|
|
36
36
|
2. Create a topic branch - `git checkout -b my_branch`
|
|
37
37
|
3. Make your changes using [descriptive commit messages](#commit-messages)
|
|
38
38
|
4. Update CHANGELOG.md describing your changes by adding an entry to the
|
data/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Demo Tape
|
|
2
2
|
|
|
3
3
|
[](https://github.com/fnando/demotape)
|
|
4
4
|
[](https://rubygems.org/gems/demotape)
|
|
5
5
|
[](https://rubygems.org/gems/demotape)
|
|
6
6
|
[](https://tldrlegal.com/license/mit-license)
|
|
7
7
|
|
|
8
|
-

|
|
9
9
|
|
|
10
10
|
Record terminal sessions from your CLI tools
|
|
11
11
|
|
|
@@ -26,9 +26,18 @@ Or add the following line to your project's Gemfile:
|
|
|
26
26
|
gem "demotape"
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
### Editor Integration
|
|
30
|
+
|
|
31
|
+
Demo Tape has extensions for several editors to provide syntax highlighting and
|
|
32
|
+
snippets.
|
|
33
|
+
|
|
34
|
+
- Sublime Text: https://github.com/fnando/sublime-demotape/
|
|
35
|
+
- VSCode: https://marketplace.visualstudio.com/items?itemName=fnando.demotape
|
|
36
|
+
- vim: https://github.com/fnando/demotape/blob/main/editors/vim/README.md
|
|
37
|
+
|
|
29
38
|
### Shell Completion
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
Demo Tape supports shell completion for Bash, Zsh, Fish, and PowerShell. To set
|
|
32
41
|
up completion for your shell:
|
|
33
42
|
|
|
34
43
|
**Bash:**
|
|
@@ -73,7 +82,7 @@ demotape completion --shell=powershell | Out-String | Invoke-Expression
|
|
|
73
82
|
|
|
74
83
|
## Usage
|
|
75
84
|
|
|
76
|
-
Run a
|
|
85
|
+
Run a Demo Tape script:
|
|
77
86
|
|
|
78
87
|
```console
|
|
79
88
|
$ demotape run path/to/script.tape
|
|
@@ -109,12 +118,12 @@ $ echo "Type 'echo \"it works with stdin too\"'\nEnter\nSleep 5" | \
|
|
|
109
118
|
### Examples
|
|
110
119
|
|
|
111
120
|
The [`examples/`](https://github.com/fnando/demotape/tree/main/examples) folder
|
|
112
|
-
contains several
|
|
121
|
+
contains several Demo Tape scripts showcasing different features. There you'll
|
|
113
122
|
also find the generated output files (videos, GIFs, and screenshots).
|
|
114
123
|
|
|
115
|
-
##
|
|
124
|
+
## Demo Tape Syntax
|
|
116
125
|
|
|
117
|
-
|
|
126
|
+
Demo Tape scripts (`.tape` files) consist of a series of commands, one per line.
|
|
118
127
|
Each command performs an action in the terminal recording, such as typing text,
|
|
119
128
|
pressing keys, waiting, or configuring the recording session.
|
|
120
129
|
|
|
@@ -579,7 +588,7 @@ Set padding 20
|
|
|
579
588
|
# Start recording
|
|
580
589
|
Sleep 1
|
|
581
590
|
|
|
582
|
-
Type "echo 'Hello,
|
|
591
|
+
Type "echo 'Hello, Demo Tape!'"
|
|
583
592
|
Enter
|
|
584
593
|
Sleep 500ms
|
|
585
594
|
|
|
@@ -639,7 +648,7 @@ quirks and adding some extra features.
|
|
|
639
648
|
> [!WARNING]
|
|
640
649
|
>
|
|
641
650
|
> The syntax is not fully compatible with vhs. Although some commands are
|
|
642
|
-
> similar, there are many differences. Please refer to the
|
|
651
|
+
> similar, there are many differences. Please refer to the Demo Tape syntax
|
|
643
652
|
> documentation above.
|
|
644
653
|
|
|
645
654
|
## Maintainer
|
|
@@ -663,6 +672,6 @@ found at https://github.com/fnando/demotape/blob/main/LICENSE.md.
|
|
|
663
672
|
|
|
664
673
|
## Code of Conduct
|
|
665
674
|
|
|
666
|
-
Everyone interacting in the
|
|
675
|
+
Everyone interacting in the Demo Tape project's codebases, issue trackers, chat
|
|
667
676
|
rooms and mailing lists is expected to follow the
|
|
668
677
|
[code of conduct](https://github.com/fnando/demotape/blob/main/CODE_OF_CONDUCT.md).
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
" Detect
|
|
1
|
+
" Detect Demo Tape files
|
|
2
2
|
au BufRead,BufNewFile *.tape set filetype=demotape
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nando Vieira
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/editors/vscode/README.md
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Demo Tape VSCode Extension
|
|
2
2
|
|
|
3
|
-
Syntax highlighting for
|
|
3
|
+
Syntax highlighting for [Demo Tape](https://github.com/fnando/demotape)
|
|
4
|
+
(`.tape`) files in Visual Studio Code.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
8
|
+
### Marketplace
|
|
9
|
+
|
|
10
|
+
1. Open Visual Studio Code
|
|
11
|
+
2. Go to the Extensions view (`Ctrl+Shift+X` or `Cmd+Shift+X` on macOS)
|
|
12
|
+
3. Search for
|
|
13
|
+
[DemoTape](https://marketplace.visualstudio.com/items?itemName=fnando.demotape)
|
|
14
|
+
|
|
15
|
+
### Manual Installation
|
|
16
|
+
|
|
7
17
|
Copy this directory to your VSCode extensions folder:
|
|
8
18
|
|
|
9
19
|
- **Windows**: `%USERPROFILE%\.vscode\extensions\demotape`
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Release Process
|
|
2
|
+
|
|
3
|
+
1. Bump up the version on `package.json`
|
|
4
|
+
2. [Publish the extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension).
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install -g @vscode/vsce
|
|
8
|
+
vsce package
|
|
9
|
+
vsce publish --pat $MICROSOFT_VSCODE_API_KEY
|
|
10
|
+
```
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
3
|
-
"name": "
|
|
3
|
+
"name": "Demo Tape",
|
|
4
4
|
"scopeName": "source.demotape",
|
|
5
5
|
"fileTypes": ["tape"],
|
|
6
|
-
"patterns": [
|
|
6
|
+
"patterns": [
|
|
7
|
+
{ "include": "#comments" },
|
|
8
|
+
{ "include": "#blocks" },
|
|
9
|
+
{ "include": "#commands" }
|
|
10
|
+
],
|
|
7
11
|
"repository": {
|
|
8
12
|
"blocks": {
|
|
9
13
|
"patterns": [
|
|
@@ -19,10 +23,7 @@
|
|
|
19
23
|
"endCaptures": {
|
|
20
24
|
"1": { "name": "keyword.control.demotape" }
|
|
21
25
|
},
|
|
22
|
-
"patterns": [
|
|
23
|
-
{ "include": "#comments" },
|
|
24
|
-
{ "include": "#commands" }
|
|
25
|
-
]
|
|
26
|
+
"patterns": [{ "include": "#comments" }, { "include": "#commands" }]
|
|
26
27
|
}
|
|
27
28
|
]
|
|
28
29
|
},
|
|
Binary file
|
data/editors/vscode/package.json
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "demotape",
|
|
3
|
-
"displayName": "
|
|
3
|
+
"displayName": "Demo Tape",
|
|
4
4
|
"description": "Syntax highlighting for DemoTape (.tape) files",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.0.2",
|
|
6
6
|
"publisher": "fnando",
|
|
7
|
+
"icon": "icon.png",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"publisher": "fnando",
|
|
10
|
+
"repository": {
|
|
11
|
+
"url": "https://github.com/fnando/demotape"
|
|
12
|
+
},
|
|
7
13
|
"engines": {
|
|
8
14
|
"vscode": "^1.50.0"
|
|
9
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"*.json",
|
|
18
|
+
"*.png",
|
|
19
|
+
"*.md"
|
|
20
|
+
],
|
|
10
21
|
"categories": [
|
|
11
22
|
"Programming Languages"
|
|
12
23
|
],
|
|
@@ -14,8 +25,13 @@
|
|
|
14
25
|
"languages": [
|
|
15
26
|
{
|
|
16
27
|
"id": "demotape",
|
|
17
|
-
"aliases": [
|
|
18
|
-
|
|
28
|
+
"aliases": [
|
|
29
|
+
"DemoTape",
|
|
30
|
+
"demotape"
|
|
31
|
+
],
|
|
32
|
+
"extensions": [
|
|
33
|
+
".tape"
|
|
34
|
+
],
|
|
19
35
|
"configuration": "./language-configuration.json"
|
|
20
36
|
}
|
|
21
37
|
],
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
id = "demotape"
|
|
2
|
+
name = "Demo Tape"
|
|
3
|
+
description = "Syntax highlighting for Demo Tape terminal recording scripts"
|
|
4
|
+
version = "0.0.1"
|
|
5
|
+
schema_version = 1
|
|
6
|
+
authors = ["Nando Vieira <me@fnando.com>"]
|
|
7
|
+
repository = "https://github.com/fnando/demotape"
|
|
8
|
+
|
|
9
|
+
[grammars.demotape]
|
|
10
|
+
repository = "https://github.com/fnando/demotape"
|
|
11
|
+
rev = "main"
|
|
12
|
+
path = "editors/zed/tree-sitter"
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name = "Demo Tape"
|
|
2
|
+
grammar = "demotape"
|
|
3
|
+
path_suffixes = ["tape"]
|
|
4
|
+
line_comments = ["# "]
|
|
5
|
+
brackets = [
|
|
6
|
+
{ start = "\"", end = "\"", close = true, newline = false },
|
|
7
|
+
{ start = "'", end = "'", close = true, newline = false },
|
|
8
|
+
{ start = "(", end = ")", close = true, newline = true },
|
|
9
|
+
{ start = "[", end = "]", close = true, newline = true },
|
|
10
|
+
{ start = "{", end = "}", close = true, newline = true },
|
|
11
|
+
]
|
|
@@ -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))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "tree-sitter-demotape"
|
|
3
|
+
description = "demotape grammar for the tree-sitter parsing library"
|
|
4
|
+
version = "0.0.1"
|
|
5
|
+
keywords = ["incremental", "parsing", "demotape"]
|
|
6
|
+
categories = ["parsing", "text-editors"]
|
|
7
|
+
repository = "https://github.com/tree-sitter/tree-sitter-demotape"
|
|
8
|
+
edition = "2018"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
|
|
11
|
+
build = "bindings/rust/build.rs"
|
|
12
|
+
include = [
|
|
13
|
+
"bindings/rust/*",
|
|
14
|
+
"grammar.js",
|
|
15
|
+
"queries/*",
|
|
16
|
+
"src/*",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[lib]
|
|
20
|
+
path = "bindings/rust/lib.rs"
|
|
21
|
+
|
|
22
|
+
[dependencies]
|
|
23
|
+
tree-sitter = "~0.20.10"
|
|
24
|
+
|
|
25
|
+
[build-dependencies]
|
|
26
|
+
cc = "1.0"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "tree_sitter_demotape_binding",
|
|
5
|
+
"include_dirs": [
|
|
6
|
+
"<!(node -e \"require('nan')\")",
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"sources": [
|
|
10
|
+
"bindings/node/binding.cc",
|
|
11
|
+
"src/parser.c",
|
|
12
|
+
# If your language uses an external scanner, add it here.
|
|
13
|
+
],
|
|
14
|
+
"cflags_c": [
|
|
15
|
+
"-std=c99",
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#include "tree_sitter/parser.h"
|
|
2
|
+
#include <node.h>
|
|
3
|
+
#include "nan.h"
|
|
4
|
+
|
|
5
|
+
using namespace v8;
|
|
6
|
+
|
|
7
|
+
extern "C" TSLanguage * tree_sitter_demotape();
|
|
8
|
+
|
|
9
|
+
namespace {
|
|
10
|
+
|
|
11
|
+
NAN_METHOD(New) {}
|
|
12
|
+
|
|
13
|
+
void Init(Local<Object> exports, Local<Object> module) {
|
|
14
|
+
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
15
|
+
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
|
16
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
17
|
+
|
|
18
|
+
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
|
19
|
+
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
|
20
|
+
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_demotape());
|
|
21
|
+
|
|
22
|
+
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("demotape").ToLocalChecked());
|
|
23
|
+
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
NODE_MODULE(tree_sitter_demotape_binding, Init)
|
|
27
|
+
|
|
28
|
+
} // namespace
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
try {
|
|
2
|
+
module.exports = require("../../build/Release/tree_sitter_demotape_binding");
|
|
3
|
+
} catch (error1) {
|
|
4
|
+
if (error1.code !== 'MODULE_NOT_FOUND') {
|
|
5
|
+
throw error1;
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
module.exports = require("../../build/Debug/tree_sitter_demotape_binding");
|
|
9
|
+
} catch (error2) {
|
|
10
|
+
if (error2.code !== 'MODULE_NOT_FOUND') {
|
|
11
|
+
throw error2;
|
|
12
|
+
}
|
|
13
|
+
throw error1
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
|
19
|
+
} catch (_) {}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
fn main() {
|
|
2
|
+
let src_dir = std::path::Path::new("src");
|
|
3
|
+
|
|
4
|
+
let mut c_config = cc::Build::new();
|
|
5
|
+
c_config.include(&src_dir);
|
|
6
|
+
c_config
|
|
7
|
+
.flag_if_supported("-Wno-unused-parameter")
|
|
8
|
+
.flag_if_supported("-Wno-unused-but-set-variable")
|
|
9
|
+
.flag_if_supported("-Wno-trigraphs");
|
|
10
|
+
let parser_path = src_dir.join("parser.c");
|
|
11
|
+
c_config.file(&parser_path);
|
|
12
|
+
|
|
13
|
+
// If your language uses an external scanner written in C,
|
|
14
|
+
// then include this block of code:
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
let scanner_path = src_dir.join("scanner.c");
|
|
18
|
+
c_config.file(&scanner_path);
|
|
19
|
+
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
c_config.compile("parser");
|
|
23
|
+
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
|
24
|
+
|
|
25
|
+
// If your language uses an external scanner written in C++,
|
|
26
|
+
// then include this block of code:
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
let mut cpp_config = cc::Build::new();
|
|
30
|
+
cpp_config.cpp(true);
|
|
31
|
+
cpp_config.include(&src_dir);
|
|
32
|
+
cpp_config
|
|
33
|
+
.flag_if_supported("-Wno-unused-parameter")
|
|
34
|
+
.flag_if_supported("-Wno-unused-but-set-variable");
|
|
35
|
+
let scanner_path = src_dir.join("scanner.cc");
|
|
36
|
+
cpp_config.file(&scanner_path);
|
|
37
|
+
cpp_config.compile("scanner");
|
|
38
|
+
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
|
39
|
+
*/
|
|
40
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//! This crate provides demotape language support for the [tree-sitter][] parsing library.
|
|
2
|
+
//!
|
|
3
|
+
//! Typically, you will use the [language][language func] function to add this language to a
|
|
4
|
+
//! tree-sitter [Parser][], and then use the parser to parse some code:
|
|
5
|
+
//!
|
|
6
|
+
//! ```
|
|
7
|
+
//! let code = "";
|
|
8
|
+
//! let mut parser = tree_sitter::Parser::new();
|
|
9
|
+
//! parser.set_language(tree_sitter_demotape::language()).expect("Error loading demotape grammar");
|
|
10
|
+
//! let tree = parser.parse(code, None).unwrap();
|
|
11
|
+
//! ```
|
|
12
|
+
//!
|
|
13
|
+
//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
|
14
|
+
//! [language func]: fn.language.html
|
|
15
|
+
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
|
16
|
+
//! [tree-sitter]: https://tree-sitter.github.io/
|
|
17
|
+
|
|
18
|
+
use tree_sitter::Language;
|
|
19
|
+
|
|
20
|
+
extern "C" {
|
|
21
|
+
fn tree_sitter_demotape() -> Language;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// Get the tree-sitter [Language][] for this grammar.
|
|
25
|
+
///
|
|
26
|
+
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
|
27
|
+
pub fn language() -> Language {
|
|
28
|
+
unsafe { tree_sitter_demotape() }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// The content of the [`node-types.json`][] file for this grammar.
|
|
32
|
+
///
|
|
33
|
+
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
|
34
|
+
pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
|
|
35
|
+
|
|
36
|
+
// Uncomment these to include any queries that this grammar contains
|
|
37
|
+
|
|
38
|
+
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
|
39
|
+
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
|
40
|
+
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
|
41
|
+
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
|
42
|
+
|
|
43
|
+
#[cfg(test)]
|
|
44
|
+
mod tests {
|
|
45
|
+
#[test]
|
|
46
|
+
fn test_can_load_grammar() {
|
|
47
|
+
let mut parser = tree_sitter::Parser::new();
|
|
48
|
+
parser
|
|
49
|
+
.set_language(super::language())
|
|
50
|
+
.expect("Error loading demotape language");
|
|
51
|
+
}
|
|
52
|
+
}
|