rapydscript-ng 0.7.23 → 0.8.0

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 (114) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +72 -26
  3. package/bin/package.json +1 -0
  4. package/bin/rapydscript +65 -62
  5. package/editor-plugins/nvim/rapydscript/README.md +184 -0
  6. package/editor-plugins/nvim/rapydscript/bin/rapydscript.so +0 -0
  7. package/editor-plugins/nvim/rapydscript/ftdetect/rapydscript.lua +10 -0
  8. package/editor-plugins/nvim/rapydscript/lua/rapydscript/health.lua +88 -0
  9. package/editor-plugins/nvim/rapydscript/lua/rapydscript/init.lua +279 -0
  10. package/local-agent.md +28 -0
  11. package/package.json +4 -5
  12. package/release/baselib-plain-pretty.js +448 -326
  13. package/release/baselib-plain-ugly.js +3 -3
  14. package/release/compiler.js +2528 -1672
  15. package/release/signatures.json +17 -17
  16. package/src/ast.pyj +73 -25
  17. package/src/baselib-builtins.pyj +2 -2
  18. package/src/baselib-containers.pyj +153 -151
  19. package/src/baselib-internal.pyj +3 -3
  20. package/src/baselib-str.pyj +5 -5
  21. package/src/lib/aes.pyj +1 -1
  22. package/src/lib/encodings.pyj +1 -1
  23. package/src/lib/pythonize.pyj +1 -1
  24. package/src/lib/re.pyj +2 -2
  25. package/src/lib/traceback.pyj +165 -28
  26. package/src/lib/uuid.pyj +1 -1
  27. package/src/output/codegen.pyj +10 -3
  28. package/src/output/functions.pyj +31 -40
  29. package/src/output/literals.pyj +11 -14
  30. package/src/output/loops.pyj +25 -87
  31. package/src/output/modules.pyj +5 -47
  32. package/src/output/statements.pyj +1 -1
  33. package/src/output/stream.pyj +58 -31
  34. package/src/parse.pyj +777 -427
  35. package/src/tokenizer.pyj +16 -4
  36. package/src/utils.pyj +1 -1
  37. package/test/_treeshake_mod.pyj +30 -0
  38. package/test/_treeshake_side_effect.pyj +9 -0
  39. package/test/ast_serialization.pyj +392 -0
  40. package/test/async.pyj +95 -0
  41. package/test/baselib.pyj +1 -2
  42. package/test/embedded_compiler.pyj +57 -0
  43. package/test/fmt.pyj +201 -0
  44. package/test/generic.pyj +7 -3
  45. package/test/imports.pyj +8 -6
  46. package/test/internationalization.pyj +38 -37
  47. package/test/lint.pyj +120 -115
  48. package/test/lsp.pyj +222 -0
  49. package/test/repl.pyj +70 -65
  50. package/test/sourcemaps.pyj +315 -0
  51. package/test/starargs.pyj +46 -39
  52. package/test/traceback.pyj +263 -0
  53. package/test/treeshaking.pyj +181 -0
  54. package/test/web_repl_export.pyj +88 -0
  55. package/tools/ast_serialize.mjs +557 -0
  56. package/tools/cli.mjs +510 -0
  57. package/tools/compile.mjs +201 -0
  58. package/tools/compiler.mjs +127 -0
  59. package/tools/{completer.js → completer.mjs} +6 -6
  60. package/tools/{embedded_compiler.js → embedded_compiler.mjs} +17 -13
  61. package/tools/export.js +109 -56
  62. package/tools/fmt.mjs +735 -0
  63. package/tools/{gettext.js → gettext.mjs} +46 -53
  64. package/tools/{ini.js → ini.mjs} +9 -10
  65. package/tools/{lint.js → lint.mjs} +107 -56
  66. package/tools/lsp.mjs +914 -0
  67. package/tools/lsp_protocol.mjs +259 -0
  68. package/tools/lsp_symbols.mjs +418 -0
  69. package/tools/{msgfmt.js → msgfmt.mjs} +18 -18
  70. package/tools/{repl.js → repl.mjs} +52 -41
  71. package/tools/{self.js → self.mjs} +56 -46
  72. package/tools/sourcemap.mjs +123 -0
  73. package/tools/test.mjs +152 -0
  74. package/tools/treeshake.mjs +400 -0
  75. package/tools/{utils.js → utils.mjs} +26 -23
  76. package/tools/{web_repl.js → web_repl.mjs} +15 -13
  77. package/tools/web_repl_export.mjs +93 -0
  78. package/tree-sitter/README.md +101 -0
  79. package/tree-sitter/grammar.js +992 -0
  80. package/tree-sitter/package.json +43 -0
  81. package/tree-sitter/queries/rapydscript/highlights.scm +232 -0
  82. package/tree-sitter/queries/rapydscript/indents.scm +64 -0
  83. package/tree-sitter/queries/rapydscript/injections.scm +14 -0
  84. package/tree-sitter/queries/rapydscript/locals.scm +108 -0
  85. package/tree-sitter/src/grammar.json +4976 -0
  86. package/tree-sitter/src/node-types.json +2901 -0
  87. package/tree-sitter/src/parser.c +196465 -0
  88. package/tree-sitter/src/scanner.c +294 -0
  89. package/tree-sitter/src/tree_sitter/alloc.h +54 -0
  90. package/tree-sitter/src/tree_sitter/array.h +330 -0
  91. package/tree-sitter/src/tree_sitter/parser.h +286 -0
  92. package/tree-sitter/test/corpus/chaining.txt +99 -0
  93. package/tree-sitter/test/corpus/classes.txt +147 -0
  94. package/tree-sitter/test/corpus/comprehensions.txt +155 -0
  95. package/tree-sitter/test/corpus/containers.txt +242 -0
  96. package/tree-sitter/test/corpus/control_flow.txt +361 -0
  97. package/tree-sitter/test/corpus/decorators.txt +64 -0
  98. package/tree-sitter/test/corpus/existential.txt +102 -0
  99. package/tree-sitter/test/corpus/functions.txt +293 -0
  100. package/tree-sitter/test/corpus/imports.txt +117 -0
  101. package/tree-sitter/test/corpus/literals.txt +135 -0
  102. package/tree-sitter/test/corpus/operators.txt +296 -0
  103. package/tree-sitter/test/corpus/statements.txt +189 -0
  104. package/tree-sitter/test/corpus/strings.txt +90 -0
  105. package/tree-sitter/test/corpus/subscripts.txt +227 -0
  106. package/tree-sitter/tree-sitter.json +36 -0
  107. package/web-repl/env.js +35 -23
  108. package/web-repl/main.js +8 -8
  109. package/bin/export +0 -75
  110. package/bin/web-repl-export +0 -102
  111. package/tools/cli.js +0 -523
  112. package/tools/compile.js +0 -184
  113. package/tools/compiler.js +0 -84
  114. package/tools/test.js +0 -110
@@ -0,0 +1,242 @@
1
+ ==================
2
+ list literal
3
+ ==================
4
+
5
+ a = [1, 2, 3]
6
+
7
+ ---
8
+
9
+ (module
10
+ (assignment
11
+ left: (pattern
12
+ (identifier))
13
+ right: (list
14
+ (number)
15
+ (number)
16
+ (number))))
17
+
18
+ ==================
19
+ empty list
20
+ ==================
21
+
22
+ a = []
23
+
24
+ ---
25
+
26
+ (module
27
+ (assignment
28
+ left: (pattern
29
+ (identifier))
30
+ right: (list)))
31
+
32
+ ==================
33
+ nested lists
34
+ ==================
35
+
36
+ a = [[1, 2], [3, 4]]
37
+
38
+ ---
39
+
40
+ (module
41
+ (assignment
42
+ left: (pattern
43
+ (identifier))
44
+ right: (list
45
+ (list
46
+ (number)
47
+ (number))
48
+ (list
49
+ (number)
50
+ (number)))))
51
+
52
+ ==================
53
+ dictionary literal
54
+ ==================
55
+
56
+ styles = {"color": "red", "width": 50}
57
+
58
+ ---
59
+
60
+ (module
61
+ (assignment
62
+ left: (pattern
63
+ (identifier))
64
+ right: (dictionary
65
+ (pair
66
+ key: (string)
67
+ value: (string))
68
+ (pair
69
+ key: (string)
70
+ value: (number)))))
71
+
72
+ ==================
73
+ empty dict
74
+ ==================
75
+
76
+ a = {}
77
+
78
+ ---
79
+
80
+ (module
81
+ (assignment
82
+ left: (pattern
83
+ (identifier))
84
+ right: (dictionary)))
85
+
86
+ ==================
87
+ set literal
88
+ ==================
89
+
90
+ a = {1, 2, 3}
91
+
92
+ ---
93
+
94
+ (module
95
+ (assignment
96
+ left: (pattern
97
+ (identifier))
98
+ right: (set
99
+ (number)
100
+ (number)
101
+ (number))))
102
+
103
+ ==================
104
+ tuple literal
105
+ ==================
106
+
107
+ a = (1, 2, 3)
108
+
109
+ ---
110
+
111
+ (module
112
+ (assignment
113
+ left: (pattern
114
+ (identifier))
115
+ right: (tuple
116
+ (number)
117
+ (number)
118
+ (number))))
119
+
120
+ ==================
121
+ empty tuple
122
+ ==================
123
+
124
+ a = ()
125
+
126
+ ---
127
+
128
+ (module
129
+ (assignment
130
+ left: (pattern
131
+ (identifier))
132
+ right: (tuple)))
133
+
134
+ ==================
135
+ single element tuple
136
+ ==================
137
+
138
+ a = (1,)
139
+
140
+ ---
141
+
142
+ (module
143
+ (assignment
144
+ left: (pattern
145
+ (identifier))
146
+ right: (tuple
147
+ (number))))
148
+
149
+ ==================
150
+ parenthesized grouping
151
+ ==================
152
+
153
+ a = (1 + 2)
154
+
155
+ ---
156
+
157
+ (module
158
+ (assignment
159
+ left: (pattern
160
+ (identifier))
161
+ right: (parenthesized_expression
162
+ (binary_operator
163
+ left: (number)
164
+ right: (number)))))
165
+
166
+ ==================
167
+ dict with inline function value
168
+ ==================
169
+
170
+ params = {"onclick": def(event): alert("hi")}
171
+
172
+ ---
173
+
174
+ (module
175
+ (assignment
176
+ left: (pattern
177
+ (identifier))
178
+ right: (dictionary
179
+ (pair
180
+ key: (string)
181
+ value: (anonymous_function
182
+ parameters: (parameters
183
+ (identifier))
184
+ body: (block
185
+ (call
186
+ function: (identifier)
187
+ arguments: (argument_list
188
+ (string)))))))))
189
+
190
+ ==================
191
+ leading comma dict with block values
192
+ ==================
193
+
194
+ d = {
195
+ "a": def(e):
196
+ return 1
197
+ ,"b": def(e):
198
+ return 2
199
+ }
200
+
201
+ ---
202
+
203
+ (module
204
+ (assignment
205
+ left: (pattern
206
+ (identifier))
207
+ right: (dictionary
208
+ (pair
209
+ key: (string)
210
+ value: (anonymous_function
211
+ parameters: (parameters
212
+ (identifier))
213
+ body: (block
214
+ (return_statement
215
+ (number)))))
216
+ (pair
217
+ key: (string)
218
+ value: (anonymous_function
219
+ parameters: (parameters
220
+ (identifier))
221
+ body: (block
222
+ (return_statement
223
+ (number))))))))
224
+
225
+ ==================
226
+ list with splat
227
+ ==================
228
+
229
+ a = [1, *rest, 2]
230
+
231
+ ---
232
+
233
+ (module
234
+ (assignment
235
+ left: (pattern
236
+ (identifier))
237
+ right: (list
238
+ (number)
239
+ (list_splat_argument
240
+ (identifier))
241
+ (number))))
242
+
@@ -0,0 +1,361 @@
1
+ ==================
2
+ if elif else
3
+ ==================
4
+
5
+ if a:
6
+ x()
7
+ elif b:
8
+ y()
9
+ else:
10
+ z()
11
+
12
+ ---
13
+
14
+ (module
15
+ (if_statement
16
+ condition: (identifier)
17
+ consequence: (block
18
+ (call
19
+ function: (identifier)
20
+ arguments: (argument_list)))
21
+ alternative: (elif_clause
22
+ condition: (identifier)
23
+ consequence: (block
24
+ (call
25
+ function: (identifier)
26
+ arguments: (argument_list))))
27
+ alternative: (else_clause
28
+ body: (block
29
+ (call
30
+ function: (identifier)
31
+ arguments: (argument_list))))))
32
+
33
+ ==================
34
+ if with assignment condition
35
+ ==================
36
+
37
+ if m = re.exec(x):
38
+ use(m)
39
+
40
+ ---
41
+
42
+ (module
43
+ (if_statement
44
+ condition: (assignment
45
+ left: (pattern
46
+ (identifier))
47
+ right: (call
48
+ function: (attribute
49
+ object: (identifier)
50
+ attribute: (identifier))
51
+ arguments: (argument_list
52
+ (identifier))))
53
+ consequence: (block
54
+ (call
55
+ function: (identifier)
56
+ arguments: (argument_list
57
+ (identifier))))))
58
+
59
+ ==================
60
+ for in loop
61
+ ==================
62
+
63
+ for animal in animals:
64
+ print(animal)
65
+
66
+ ---
67
+
68
+ (module
69
+ (for_statement
70
+ left: (pattern
71
+ (identifier))
72
+ right: (identifier)
73
+ body: (block
74
+ (call
75
+ function: (identifier)
76
+ arguments: (argument_list
77
+ (identifier))))))
78
+
79
+ ==================
80
+ for with tuple unpacking
81
+ ==================
82
+
83
+ for index, value in enumerate(items):
84
+ print(index)
85
+
86
+ ---
87
+
88
+ (module
89
+ (for_statement
90
+ left: (pattern_list
91
+ (pattern
92
+ (identifier))
93
+ (pattern
94
+ (identifier)))
95
+ right: (call
96
+ function: (identifier)
97
+ arguments: (argument_list
98
+ (identifier)))
99
+ body: (block
100
+ (call
101
+ function: (identifier)
102
+ arguments: (argument_list
103
+ (identifier))))))
104
+
105
+ ==================
106
+ for with nested destructuring
107
+ ==================
108
+
109
+ for x, (y, z) in items:
110
+ print(x)
111
+
112
+ ---
113
+
114
+ (module
115
+ (for_statement
116
+ left: (pattern_list
117
+ (pattern
118
+ (identifier))
119
+ (pattern
120
+ (tuple_pattern
121
+ (pattern
122
+ (identifier))
123
+ (pattern
124
+ (identifier)))))
125
+ right: (identifier)
126
+ body: (block
127
+ (call
128
+ function: (identifier)
129
+ arguments: (argument_list
130
+ (identifier))))))
131
+
132
+ ==================
133
+ for else
134
+ ==================
135
+
136
+ for x in y:
137
+ pass
138
+ else:
139
+ done()
140
+
141
+ ---
142
+
143
+ (module
144
+ (for_statement
145
+ left: (pattern
146
+ (identifier))
147
+ right: (identifier)
148
+ body: (block
149
+ (pass_statement))
150
+ alternative: (else_clause
151
+ body: (block
152
+ (call
153
+ function: (identifier)
154
+ arguments: (argument_list))))))
155
+
156
+ ==================
157
+ while loop
158
+ ==================
159
+
160
+ while a < 10:
161
+ a += 1
162
+
163
+ ---
164
+
165
+ (module
166
+ (while_statement
167
+ condition: (comparison_operator
168
+ (identifier)
169
+ (number))
170
+ body: (block
171
+ (augmented_assignment
172
+ left: (pattern
173
+ (identifier))
174
+ right: (number)))))
175
+
176
+ ==================
177
+ do while loop
178
+ ==================
179
+
180
+ do:
181
+ print(a)
182
+ a += 1
183
+ .while a < 1
184
+
185
+ ---
186
+
187
+ (module
188
+ (do_statement
189
+ body: (block
190
+ (call
191
+ function: (identifier)
192
+ arguments: (argument_list
193
+ (identifier)))
194
+ (augmented_assignment
195
+ left: (pattern
196
+ (identifier))
197
+ right: (number)))
198
+ condition: (comparison_operator
199
+ (identifier)
200
+ (number))))
201
+
202
+ ==================
203
+ native javascript for loop
204
+ ==================
205
+
206
+ for v'i = 0; i < 5; i++':
207
+ print(i)
208
+
209
+
210
+ ---
211
+
212
+ (module
213
+ (for_js_statement
214
+ condition: (verbatim)
215
+ body: (block
216
+ (call
217
+ function: (identifier)
218
+ arguments: (argument_list
219
+ (identifier))))))
220
+
221
+ ==================
222
+ try except else finally
223
+ ==================
224
+
225
+ try:
226
+ somefunc()
227
+ except Exception as e:
228
+ handle(e)
229
+ else:
230
+ ok()
231
+ finally:
232
+ cleanup()
233
+
234
+ ---
235
+
236
+ (module
237
+ (try_statement
238
+ body: (block
239
+ (call
240
+ function: (identifier)
241
+ arguments: (argument_list)))
242
+ (except_clause
243
+ (identifier)
244
+ alias: (identifier)
245
+ body: (block
246
+ (call
247
+ function: (identifier)
248
+ arguments: (argument_list
249
+ (identifier)))))
250
+ (else_clause
251
+ body: (block
252
+ (call
253
+ function: (identifier)
254
+ arguments: (argument_list))))
255
+ (finally_clause
256
+ body: (block
257
+ (call
258
+ function: (identifier)
259
+ arguments: (argument_list))))))
260
+
261
+ ==================
262
+ try multiple exceptions
263
+ ==================
264
+
265
+ try:
266
+ foo()
267
+ except ReferenceError, TypeError as e:
268
+ print(e)
269
+
270
+ ---
271
+
272
+ (module
273
+ (try_statement
274
+ body: (block
275
+ (call
276
+ function: (identifier)
277
+ arguments: (argument_list)))
278
+ (except_clause
279
+ (identifier)
280
+ (identifier)
281
+ alias: (identifier)
282
+ body: (block
283
+ (call
284
+ function: (identifier)
285
+ arguments: (argument_list
286
+ (identifier)))))))
287
+
288
+ ==================
289
+ except as without type
290
+ ==================
291
+
292
+ try:
293
+ foo()
294
+ except as ex:
295
+ log(ex)
296
+
297
+ ---
298
+
299
+ (module
300
+ (try_statement
301
+ body: (block
302
+ (call
303
+ function: (identifier)
304
+ arguments: (argument_list)))
305
+ (except_clause
306
+ alias: (identifier)
307
+ body: (block
308
+ (call
309
+ function: (identifier)
310
+ arguments: (argument_list
311
+ (identifier)))))))
312
+
313
+ ==================
314
+ with multiple clauses
315
+ ==================
316
+
317
+ with a() as x, b() as y:
318
+ run()
319
+
320
+ ---
321
+
322
+ (module
323
+ (with_statement
324
+ (with_clause
325
+ value: (call
326
+ function: (identifier)
327
+ arguments: (argument_list))
328
+ alias: (identifier))
329
+ (with_clause
330
+ value: (call
331
+ function: (identifier)
332
+ arguments: (argument_list))
333
+ alias: (identifier))
334
+ body: (block
335
+ (call
336
+ function: (identifier)
337
+ arguments: (argument_list)))))
338
+
339
+ ==================
340
+ break and continue
341
+ ==================
342
+
343
+ for x in y:
344
+ if x:
345
+ break
346
+ continue
347
+
348
+ ---
349
+
350
+ (module
351
+ (for_statement
352
+ left: (pattern
353
+ (identifier))
354
+ right: (identifier)
355
+ body: (block
356
+ (if_statement
357
+ condition: (identifier)
358
+ consequence: (block
359
+ (break_statement)))
360
+ (continue_statement))))
361
+
@@ -0,0 +1,64 @@
1
+ ==================
2
+ single decorator
3
+ ==================
4
+
5
+ @makebold
6
+ def hello():
7
+ return "hi"
8
+
9
+ ---
10
+
11
+ (module
12
+ (decorated_definition
13
+ (decorator
14
+ (identifier))
15
+ definition: (function_definition
16
+ name: (identifier)
17
+ parameters: (parameters)
18
+ body: (block
19
+ (return_statement
20
+ (string))))))
21
+
22
+ ==================
23
+ stacked decorators
24
+ ==================
25
+
26
+ @makebold
27
+ @makeitalic
28
+ def hello():
29
+ return "hi"
30
+
31
+ ---
32
+
33
+ (module
34
+ (decorated_definition
35
+ (decorator
36
+ (identifier))
37
+ (decorator
38
+ (identifier))
39
+ definition: (function_definition
40
+ name: (identifier)
41
+ parameters: (parameters)
42
+ body: (block
43
+ (return_statement
44
+ (string))))))
45
+
46
+ ==================
47
+ decorated class
48
+ ==================
49
+
50
+ @add_x
51
+ class A:
52
+ pass
53
+
54
+ ---
55
+
56
+ (module
57
+ (decorated_definition
58
+ (decorator
59
+ (identifier))
60
+ definition: (class_definition
61
+ name: (identifier)
62
+ body: (block
63
+ (pass_statement)))))
64
+