tabry 0.1.1 → 0.1.2

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tabry/shells/bash.rb +12 -5
  3. data/sh/bash/README.md +2 -1
  4. data/tabry.gemspec +19 -2
  5. data/treesitter/Cargo.toml +26 -0
  6. data/treesitter/README.md +4 -0
  7. data/treesitter/binding.gyp +19 -0
  8. data/treesitter/bindings/node/binding.cc +28 -0
  9. data/treesitter/bindings/node/index.js +19 -0
  10. data/treesitter/bindings/rust/build.rs +40 -0
  11. data/treesitter/bindings/rust/lib.rs +52 -0
  12. data/treesitter/corpus/arg.txt +96 -0
  13. data/treesitter/corpus/at.txt +79 -0
  14. data/treesitter/corpus/comment.txt +13 -0
  15. data/treesitter/corpus/desc.txt +25 -0
  16. data/treesitter/corpus/examples_from_language_reference.txt +410 -0
  17. data/treesitter/corpus/flag.txt +48 -0
  18. data/treesitter/corpus/flag_desc_inline.txt +37 -0
  19. data/treesitter/corpus/opts.txt +21 -0
  20. data/treesitter/corpus/rapture.txt +61 -0
  21. data/treesitter/grammar.js +171 -0
  22. data/treesitter/jest_fixtures/examples_from_language_reference/argument_titles.yml +8 -0
  23. data/treesitter/jest_fixtures/examples_from_language_reference/arguments_and_possible_options__arg_.yml +23 -0
  24. data/treesitter/jest_fixtures/examples_from_language_reference/flags__flag__flagarg__reqd_flagarg_.yml +37 -0
  25. data/treesitter/jest_fixtures/examples_from_language_reference/getting_started.yml +13 -0
  26. data/treesitter/jest_fixtures/examples_from_language_reference/includes.yml +57 -0
  27. data/treesitter/jest_fixtures/examples_from_language_reference/multi_line_descriptions.yml +7 -0
  28. data/treesitter/jest_fixtures/examples_from_language_reference/optional_args_and_varargs__opt_arg__varargs__opt_varargs_.yml +16 -0
  29. data/treesitter/jest_fixtures/examples_from_language_reference/options.yml +24 -0
  30. data/treesitter/jest_fixtures/examples_from_language_reference/subcommands__sub__1.yml +23 -0
  31. data/treesitter/jest_fixtures/examples_from_language_reference/subcommands__sub__2.yml +15 -0
  32. data/treesitter/package.json +21 -0
  33. data/treesitter/parser_compile.sh +1 -0
  34. data/treesitter/src/grammar.json +615 -0
  35. data/treesitter/src/node-types.json +563 -0
  36. data/treesitter/src/parser.c +4706 -0
  37. data/treesitter/src/tree_sitter/parser.h +223 -0
  38. data/treesitter/tabry-compile.js +394 -0
  39. data/treesitter/tabry-compile.test.js +51 -0
  40. metadata +36 -1
@@ -0,0 +1,171 @@
1
+ module.exports = grammar({
2
+ name: 'tabry',
3
+
4
+ rules: {
5
+ source_file: $ => repeat($._toplevel_statement),
6
+
7
+ _toplevel_statement: $ => choice(
8
+ $._common_statement,
9
+ $.cmd_statement,
10
+ $.defopts_statement,
11
+ $.defargs_statement,
12
+ ),
13
+
14
+ // TODO fix restrictions here, e.g. can't have flagarg inside flagarg
15
+ // make an _opts_block_statement with only opts_*_statement. and make an opts_block
16
+ _common_statement: $ => choice(
17
+ $.arg_statement,
18
+ $.flagarg_statement,
19
+ $.flag_statement,
20
+ $.sub_statement,
21
+ $._comment,
22
+ $.desc_statement,
23
+ $.include_statement,
24
+ ),
25
+
26
+ _block_statement: $ => choice(
27
+ $._common_statement,
28
+ $.opts_const_statement,
29
+ $.opts_shell_statement,
30
+ $.opts_file_statement,
31
+ $.opts_dir_statement,
32
+ $.title_statement,
33
+ ),
34
+
35
+ include_statement: $ => seq(
36
+ 'include',
37
+ $.at_identifier,
38
+ ),
39
+
40
+ // TODO limit types of statements inside defopts and defargs etc.
41
+ defopts_statement: $ => seq(
42
+ 'defopts',
43
+ $.at_identifier,
44
+ $.block,
45
+ ),
46
+ defargs_statement: $ => seq(
47
+ 'defargs',
48
+ $.at_identifier,
49
+ $.block,
50
+ ),
51
+
52
+ at_identifier: $ => /@[a-zA-Z_][a-zA-Z0-9_-]*/,
53
+
54
+ _comment: $ => /#.*/,
55
+
56
+ sub_statement: $ => seq(
57
+ 'sub',
58
+ field('names', $.sub_name_list),
59
+ optional(field('desc', $.string)),
60
+ repeat($.at_identifier),
61
+ optional($.block),
62
+ ),
63
+
64
+ cmd_statement: $ => seq(
65
+ 'cmd',
66
+ $.string,
67
+ ),
68
+
69
+ desc_statement: $ => seq(
70
+ 'desc',
71
+ $.string,
72
+ ),
73
+
74
+ title_statement: $ => seq(
75
+ 'title',
76
+ $.string,
77
+ ),
78
+
79
+ arg_type: $ => choice(
80
+ 'arg',
81
+ 'varargs',
82
+ ),
83
+
84
+ arg_statement: $ => seq(
85
+ optional($.arg_modifier),
86
+ // restrictions:
87
+ // * 'arg' or 'varargs' cannot after 'args'.
88
+ // * non-optional arg(s) cannot come after optional arg
89
+ $.arg_type,
90
+ optional(
91
+ choice(
92
+ seq($.arg_name_list, $.string),
93
+ seq($.arg_name_list)
94
+ )
95
+ ),
96
+ repeat(
97
+ field("at", $.at_identifier),
98
+ ),
99
+ optional($.block),
100
+ ),
101
+
102
+ opts_const_statement: $ => seq(
103
+ 'opts',
104
+ 'const', // TODO this is weird: doesn't require a space between them
105
+ $._strings,
106
+ ),
107
+
108
+ opts_shell_statement: $ => seq(
109
+ 'opts',
110
+ 'shell',
111
+ $.string,
112
+ ),
113
+
114
+ opts_file_statement: $ => seq(
115
+ 'opts',
116
+ 'file',
117
+ ),
118
+
119
+ opts_dir_statement: $ => seq(
120
+ 'opts',
121
+ 'dir',
122
+ ),
123
+
124
+ flagarg_statement: $ => seq(
125
+ optional($.flag_modifier),
126
+ 'flagarg',
127
+ field('names', $.flag_name_list),
128
+ optional(field('desc', $.string)),
129
+ repeat($.at_identifier),
130
+ optional($.block),
131
+ ),
132
+
133
+ flag_statement: $ => seq(
134
+ optional($.flag_modifier),
135
+ 'flag',
136
+ field('names', $.flag_name_list),
137
+ optional(field('desc', $.string)),
138
+ repeat($.at_identifier),
139
+ optional($.block),
140
+ ),
141
+
142
+ flag_modifier: $ => choice(
143
+ 'reqd',
144
+ ),
145
+
146
+ arg_modifier: $ => 'opt',
147
+
148
+ block: $ => seq(
149
+ '{',
150
+ repeat1($._block_statement),
151
+ '}',
152
+ ),
153
+
154
+ flag_name_list: $ => $._strings,
155
+ arg_name_list: $ => $._strings,
156
+ sub_name_list: $ => $._strings,
157
+
158
+ _strings: $ => choice(
159
+ $.string,
160
+ $._strings_list,
161
+ ),
162
+
163
+ string: $ => /[A-Za-z_][a-zA-Z0-9_,-]*|"([^"\\]|\\"|\\\\)*"/,
164
+
165
+ _strings_list: $ => seq(
166
+ '(',
167
+ repeat1($.string),
168
+ ')',
169
+ ),
170
+ }
171
+ });
@@ -0,0 +1,8 @@
1
+ cmd: null
2
+ main:
3
+ args:
4
+ - name: thing_to_search_for
5
+ title: thing to search for
6
+ - name: files_to_load
7
+ title: "file to load"
8
+ varargs: true
@@ -0,0 +1,23 @@
1
+ cmd: null
2
+ main:
3
+ args:
4
+ - name: vehicle_type1
5
+ - name: vehicle_type3
6
+ description: The type of vehicle
7
+ - name: vehicle_type4
8
+ description: The type of vehicle
9
+ - options:
10
+ - type: const
11
+ value: a
12
+ - name: bool1
13
+ options:
14
+ - type: const
15
+ value: T
16
+ - type: const
17
+ value: F
18
+ - name: bool2
19
+ options:
20
+ - type: const
21
+ value: T
22
+ - type: const
23
+ value: F
@@ -0,0 +1,37 @@
1
+ cmd: null
2
+ main:
3
+ flags:
4
+ - name: dry-run
5
+ aliases:
6
+ - d
7
+ - name: dry-run2
8
+ aliases:
9
+ - r
10
+ description: Don't act, only show what would be done
11
+ - name: f
12
+ aliases:
13
+ - format
14
+ arg: true
15
+ options:
16
+ - type: const
17
+ value: json
18
+ - type: const
19
+ value: yml
20
+ - name: env
21
+ aliases:
22
+ - e
23
+ description: The environment (this must be given)
24
+ arg: true
25
+ options:
26
+ - type: const
27
+ value: prod
28
+ - type: const
29
+ value: beta
30
+ - type: const
31
+ value: dev
32
+ - name: interactive
33
+ aliases:
34
+ - i
35
+ - name: force
36
+ aliases:
37
+ - f
@@ -0,0 +1,13 @@
1
+ cmd: control-vehicle
2
+ main:
3
+ args:
4
+ - options:
5
+ - type: const
6
+ value: car
7
+ - type: const
8
+ value: bike
9
+ - options:
10
+ - type: const
11
+ value: go
12
+ - type: const
13
+ value: stop
@@ -0,0 +1,57 @@
1
+ cmd: mydeploy
2
+ main:
3
+ args:
4
+ - include: project-and-environment
5
+ flags:
6
+ - include: project-and-environment
7
+ subs:
8
+ - include: project-and-environment
9
+ - name: status
10
+ args:
11
+ - include: project-and-environment
12
+ - include: verbose
13
+ flags:
14
+ - include: project-and-environment
15
+ - include: verbose
16
+ subs:
17
+ - include: project-and-environment
18
+ - include: verbose
19
+ - name: list
20
+ args:
21
+ - include: verbose
22
+ flags:
23
+ - include: verbose
24
+ - name: env
25
+ options:
26
+ - type: include
27
+ value: environment
28
+ arg: true
29
+ subs:
30
+ - include: verbose
31
+ option_includes:
32
+ environment:
33
+ - type: const
34
+ value: prod
35
+ - type: const
36
+ value: beta
37
+ - type: const
38
+ value: dev
39
+ arg_includes:
40
+ verbose:
41
+ flags:
42
+ - name: verbose
43
+ description: Show more info
44
+ project-and-environment:
45
+ args:
46
+ - name: project
47
+ description: The project
48
+ options:
49
+ - type: const
50
+ value: project1
51
+ - type: const
52
+ value: project2
53
+ - name: environment
54
+ options:
55
+ - type: include
56
+ value: environment
57
+ description: The environment
@@ -0,0 +1,7 @@
1
+ cmd: null
2
+ main:
3
+ subs:
4
+ - name: mycmd
5
+ description: |-
6
+ My command:
7
+ * It does stuff
@@ -0,0 +1,16 @@
1
+ cmd: null
2
+ main:
3
+ args:
4
+ - name: first-arg-mandatory
5
+ - name: second-arg-optional
6
+ optional: true
7
+ - name: rest-args-optional
8
+ optional: true
9
+ varargs: true
10
+ options:
11
+ - type: const
12
+ value: foo
13
+ - type: const
14
+ value: bar
15
+ - type: const
16
+ value: waz
@@ -0,0 +1,24 @@
1
+ cmd: null
2
+ main:
3
+ args:
4
+ - options:
5
+ - type: const
6
+ value: hello
7
+ - type: const
8
+ value: hello "world"
9
+ - type: const
10
+ value: T
11
+ - type: const
12
+ value: F
13
+ - type: const
14
+ value: "true"
15
+ - type: const
16
+ value: "false"
17
+ - type: const
18
+ value: "yes"
19
+ - type: const
20
+ value: "no"
21
+ - type: shell
22
+ value: mycmd list-things
23
+ - type: file
24
+ - type: dir
@@ -0,0 +1,23 @@
1
+ cmd: null
2
+ main:
3
+ subs:
4
+ - name: list
5
+ description: List the things
6
+ - name: new
7
+ aliases:
8
+ - "n"
9
+ description: Create a thing
10
+ - name: delete
11
+ aliases:
12
+ - d
13
+ description: Delete a thing
14
+ args:
15
+ - name: thing
16
+ description: The thing to delete
17
+ options:
18
+ - type: shell
19
+ value: mycmd list
20
+ - name: do-something
21
+ - name: do-something-else
22
+ aliases:
23
+ - dse
@@ -0,0 +1,15 @@
1
+ cmd: foo
2
+ main:
3
+ args:
4
+ - name: toplevel-arg
5
+ flags:
6
+ - name: dryrun
7
+ subs:
8
+ - name: mysub1
9
+ subs:
10
+ - name: mysub2
11
+ flags:
12
+ - name: someopt
13
+ args:
14
+ - name: mysub2-arg
15
+ optional: true
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "tree-sitter-tabry",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "bindings/node",
6
+ "scripts": {
7
+ "test": "tree-sitter test",
8
+ "gen": "tree-sitter generate"
9
+ },
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "nan": "^2.15.0",
14
+ "tree-sitter": "^0.20.0",
15
+ "yaml": "^2.0.0-8"
16
+ },
17
+ "devDependencies": {
18
+ "jest": "^27.5.1",
19
+ "tree-sitter-cli": "^0.20.0"
20
+ }
21
+ }
@@ -0,0 +1 @@
1
+ npx tree-sitter generate && npx tree-sitter test && npx node-gyp rebuild