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.
- package/CHANGELOG.md +24 -0
- package/README.md +72 -26
- package/bin/package.json +1 -0
- package/bin/rapydscript +65 -62
- package/editor-plugins/nvim/rapydscript/README.md +184 -0
- package/editor-plugins/nvim/rapydscript/bin/rapydscript.so +0 -0
- package/editor-plugins/nvim/rapydscript/ftdetect/rapydscript.lua +10 -0
- package/editor-plugins/nvim/rapydscript/lua/rapydscript/health.lua +88 -0
- package/editor-plugins/nvim/rapydscript/lua/rapydscript/init.lua +279 -0
- package/local-agent.md +28 -0
- package/package.json +4 -5
- package/release/baselib-plain-pretty.js +448 -326
- package/release/baselib-plain-ugly.js +3 -3
- package/release/compiler.js +2528 -1672
- package/release/signatures.json +17 -17
- package/src/ast.pyj +73 -25
- package/src/baselib-builtins.pyj +2 -2
- package/src/baselib-containers.pyj +153 -151
- package/src/baselib-internal.pyj +3 -3
- package/src/baselib-str.pyj +5 -5
- package/src/lib/aes.pyj +1 -1
- package/src/lib/encodings.pyj +1 -1
- package/src/lib/pythonize.pyj +1 -1
- package/src/lib/re.pyj +2 -2
- package/src/lib/traceback.pyj +165 -28
- package/src/lib/uuid.pyj +1 -1
- package/src/output/codegen.pyj +10 -3
- package/src/output/functions.pyj +31 -40
- package/src/output/literals.pyj +11 -14
- package/src/output/loops.pyj +25 -87
- package/src/output/modules.pyj +5 -47
- package/src/output/statements.pyj +1 -1
- package/src/output/stream.pyj +58 -31
- package/src/parse.pyj +777 -427
- package/src/tokenizer.pyj +16 -4
- package/src/utils.pyj +1 -1
- package/test/_treeshake_mod.pyj +30 -0
- package/test/_treeshake_side_effect.pyj +9 -0
- package/test/ast_serialization.pyj +392 -0
- package/test/async.pyj +95 -0
- package/test/baselib.pyj +1 -2
- package/test/embedded_compiler.pyj +57 -0
- package/test/fmt.pyj +201 -0
- package/test/generic.pyj +7 -3
- package/test/imports.pyj +8 -6
- package/test/internationalization.pyj +38 -37
- package/test/lint.pyj +120 -115
- package/test/lsp.pyj +222 -0
- package/test/repl.pyj +70 -65
- package/test/sourcemaps.pyj +315 -0
- package/test/starargs.pyj +46 -39
- package/test/traceback.pyj +263 -0
- package/test/treeshaking.pyj +181 -0
- package/test/web_repl_export.pyj +88 -0
- package/tools/ast_serialize.mjs +557 -0
- package/tools/cli.mjs +510 -0
- package/tools/compile.mjs +201 -0
- package/tools/compiler.mjs +127 -0
- package/tools/{completer.js → completer.mjs} +6 -6
- package/tools/{embedded_compiler.js → embedded_compiler.mjs} +17 -13
- package/tools/export.js +109 -56
- package/tools/fmt.mjs +735 -0
- package/tools/{gettext.js → gettext.mjs} +46 -53
- package/tools/{ini.js → ini.mjs} +9 -10
- package/tools/{lint.js → lint.mjs} +107 -56
- package/tools/lsp.mjs +914 -0
- package/tools/lsp_protocol.mjs +259 -0
- package/tools/lsp_symbols.mjs +418 -0
- package/tools/{msgfmt.js → msgfmt.mjs} +18 -18
- package/tools/{repl.js → repl.mjs} +52 -41
- package/tools/{self.js → self.mjs} +56 -46
- package/tools/sourcemap.mjs +123 -0
- package/tools/test.mjs +152 -0
- package/tools/treeshake.mjs +400 -0
- package/tools/{utils.js → utils.mjs} +26 -23
- package/tools/{web_repl.js → web_repl.mjs} +15 -13
- package/tools/web_repl_export.mjs +93 -0
- package/tree-sitter/README.md +101 -0
- package/tree-sitter/grammar.js +992 -0
- package/tree-sitter/package.json +43 -0
- package/tree-sitter/queries/rapydscript/highlights.scm +232 -0
- package/tree-sitter/queries/rapydscript/indents.scm +64 -0
- package/tree-sitter/queries/rapydscript/injections.scm +14 -0
- package/tree-sitter/queries/rapydscript/locals.scm +108 -0
- package/tree-sitter/src/grammar.json +4976 -0
- package/tree-sitter/src/node-types.json +2901 -0
- package/tree-sitter/src/parser.c +196465 -0
- package/tree-sitter/src/scanner.c +294 -0
- package/tree-sitter/src/tree_sitter/alloc.h +54 -0
- package/tree-sitter/src/tree_sitter/array.h +330 -0
- package/tree-sitter/src/tree_sitter/parser.h +286 -0
- package/tree-sitter/test/corpus/chaining.txt +99 -0
- package/tree-sitter/test/corpus/classes.txt +147 -0
- package/tree-sitter/test/corpus/comprehensions.txt +155 -0
- package/tree-sitter/test/corpus/containers.txt +242 -0
- package/tree-sitter/test/corpus/control_flow.txt +361 -0
- package/tree-sitter/test/corpus/decorators.txt +64 -0
- package/tree-sitter/test/corpus/existential.txt +102 -0
- package/tree-sitter/test/corpus/functions.txt +293 -0
- package/tree-sitter/test/corpus/imports.txt +117 -0
- package/tree-sitter/test/corpus/literals.txt +135 -0
- package/tree-sitter/test/corpus/operators.txt +296 -0
- package/tree-sitter/test/corpus/statements.txt +189 -0
- package/tree-sitter/test/corpus/strings.txt +90 -0
- package/tree-sitter/test/corpus/subscripts.txt +227 -0
- package/tree-sitter/tree-sitter.json +36 -0
- package/web-repl/env.js +35 -23
- package/web-repl/main.js +8 -8
- package/bin/export +0 -75
- package/bin/web-repl-export +0 -102
- package/tools/cli.js +0 -523
- package/tools/compile.js +0 -184
- package/tools/compiler.js +0 -84
- package/tools/test.js +0 -110
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tree-sitter-rapydscript",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "RapydScript grammar for tree-sitter",
|
|
5
|
+
"main": "bindings/node",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"parser",
|
|
8
|
+
"lexer",
|
|
9
|
+
"rapydscript",
|
|
10
|
+
"tree-sitter"
|
|
11
|
+
],
|
|
12
|
+
"license": "BSD-2-Clause",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"node-addon-api": "^8.0.0",
|
|
15
|
+
"node-gyp-build": "^4.8.0"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"tree-sitter": "^0.21.0"
|
|
19
|
+
},
|
|
20
|
+
"peerDependenciesMeta": {
|
|
21
|
+
"tree-sitter": {
|
|
22
|
+
"optional": true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"tree-sitter-cli": "^0.26.0"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"generate": "tree-sitter generate",
|
|
30
|
+
"test": "tree-sitter test"
|
|
31
|
+
},
|
|
32
|
+
"tree-sitter": [
|
|
33
|
+
{
|
|
34
|
+
"scope": "source.rapydscript",
|
|
35
|
+
"file-types": [
|
|
36
|
+
"pyj"
|
|
37
|
+
],
|
|
38
|
+
"highlights": [
|
|
39
|
+
"queries/rapydscript/highlights.scm"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
; Syntax highlighting for RapydScript
|
|
2
|
+
; Capture names follow the nvim-treesitter conventions so this file works
|
|
3
|
+
; out-of-the-box in Neovim. More specific patterns come later so that they
|
|
4
|
+
; override the more general ones.
|
|
5
|
+
|
|
6
|
+
; ----------------------------------------------------------------------------
|
|
7
|
+
; Identifiers
|
|
8
|
+
; ----------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
(identifier) @variable
|
|
11
|
+
|
|
12
|
+
; ----------------------------------------------------------------------------
|
|
13
|
+
; Literals
|
|
14
|
+
; ----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
(comment) @comment @spell
|
|
17
|
+
|
|
18
|
+
(string) @string
|
|
19
|
+
(verbatim) @string.special
|
|
20
|
+
(concatenated_string) @string
|
|
21
|
+
(regex) @string.regexp
|
|
22
|
+
(number) @number
|
|
23
|
+
|
|
24
|
+
(true) @boolean
|
|
25
|
+
(false) @boolean
|
|
26
|
+
(none) @constant.builtin
|
|
27
|
+
(this) @variable.builtin
|
|
28
|
+
|
|
29
|
+
; ----------------------------------------------------------------------------
|
|
30
|
+
; Function & class definitions
|
|
31
|
+
; ----------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
(function_definition
|
|
34
|
+
name: (identifier) @function)
|
|
35
|
+
|
|
36
|
+
(async_function_definition
|
|
37
|
+
name: (identifier) @function)
|
|
38
|
+
|
|
39
|
+
(class_definition
|
|
40
|
+
name: (identifier) @type)
|
|
41
|
+
|
|
42
|
+
(anonymous_function) @function
|
|
43
|
+
|
|
44
|
+
; parameters
|
|
45
|
+
(parameters (identifier) @variable.parameter)
|
|
46
|
+
(typed_parameter name: (identifier) @variable.parameter)
|
|
47
|
+
(default_parameter name: (identifier) @variable.parameter)
|
|
48
|
+
(typed_default_parameter name: (identifier) @variable.parameter)
|
|
49
|
+
(list_splat_parameter name: (identifier) @variable.parameter)
|
|
50
|
+
(dictionary_splat_parameter name: (identifier) @variable.parameter)
|
|
51
|
+
|
|
52
|
+
(typed_parameter type: (identifier) @type)
|
|
53
|
+
(typed_default_parameter type: (identifier) @type)
|
|
54
|
+
|
|
55
|
+
; ----------------------------------------------------------------------------
|
|
56
|
+
; Calls
|
|
57
|
+
; ----------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
(call
|
|
60
|
+
function: (identifier) @function.call)
|
|
61
|
+
|
|
62
|
+
(call
|
|
63
|
+
function: (attribute
|
|
64
|
+
attribute: (identifier) @function.method.call))
|
|
65
|
+
|
|
66
|
+
(new_expression
|
|
67
|
+
constructor: (identifier) @type)
|
|
68
|
+
|
|
69
|
+
(decorator) @attribute
|
|
70
|
+
(decorator "@" @attribute)
|
|
71
|
+
|
|
72
|
+
; keyword arguments
|
|
73
|
+
(keyword_argument
|
|
74
|
+
name: (identifier) @variable.parameter)
|
|
75
|
+
|
|
76
|
+
; attribute access
|
|
77
|
+
(attribute
|
|
78
|
+
attribute: (identifier) @property)
|
|
79
|
+
|
|
80
|
+
; ----------------------------------------------------------------------------
|
|
81
|
+
; Keywords
|
|
82
|
+
; ----------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
[
|
|
85
|
+
"def"
|
|
86
|
+
"class"
|
|
87
|
+
"async"
|
|
88
|
+
] @keyword.function
|
|
89
|
+
|
|
90
|
+
[
|
|
91
|
+
"return"
|
|
92
|
+
"yield"
|
|
93
|
+
"raise"
|
|
94
|
+
"del"
|
|
95
|
+
"assert"
|
|
96
|
+
"global"
|
|
97
|
+
"nonlocal"
|
|
98
|
+
] @keyword
|
|
99
|
+
|
|
100
|
+
; single-token statements (their keyword is not separately queryable)
|
|
101
|
+
[
|
|
102
|
+
(pass_statement)
|
|
103
|
+
(break_statement)
|
|
104
|
+
(continue_statement)
|
|
105
|
+
(debugger_statement)
|
|
106
|
+
] @keyword
|
|
107
|
+
|
|
108
|
+
[
|
|
109
|
+
"if"
|
|
110
|
+
"elif"
|
|
111
|
+
"else"
|
|
112
|
+
] @keyword.conditional
|
|
113
|
+
|
|
114
|
+
(conditional_expression ["if" "else"] @keyword.conditional.ternary)
|
|
115
|
+
|
|
116
|
+
[
|
|
117
|
+
"for"
|
|
118
|
+
"while"
|
|
119
|
+
"do"
|
|
120
|
+
] @keyword.repeat
|
|
121
|
+
|
|
122
|
+
[
|
|
123
|
+
"try"
|
|
124
|
+
"except"
|
|
125
|
+
"finally"
|
|
126
|
+
] @keyword.exception
|
|
127
|
+
|
|
128
|
+
[
|
|
129
|
+
"import"
|
|
130
|
+
"from"
|
|
131
|
+
"as"
|
|
132
|
+
"with"
|
|
133
|
+
] @keyword.import
|
|
134
|
+
|
|
135
|
+
"await" @keyword.coroutine
|
|
136
|
+
(yield "from" @keyword)
|
|
137
|
+
|
|
138
|
+
[
|
|
139
|
+
"and"
|
|
140
|
+
"or"
|
|
141
|
+
"not"
|
|
142
|
+
"in"
|
|
143
|
+
"is"
|
|
144
|
+
"new"
|
|
145
|
+
"typeof"
|
|
146
|
+
"void"
|
|
147
|
+
"instanceof"
|
|
148
|
+
] @keyword.operator
|
|
149
|
+
|
|
150
|
+
; ----------------------------------------------------------------------------
|
|
151
|
+
; Operators & punctuation
|
|
152
|
+
; ----------------------------------------------------------------------------
|
|
153
|
+
|
|
154
|
+
[
|
|
155
|
+
"+"
|
|
156
|
+
"-"
|
|
157
|
+
"*"
|
|
158
|
+
"/"
|
|
159
|
+
"//"
|
|
160
|
+
"%"
|
|
161
|
+
"**"
|
|
162
|
+
"="
|
|
163
|
+
"+="
|
|
164
|
+
"-="
|
|
165
|
+
"*="
|
|
166
|
+
"/="
|
|
167
|
+
"//="
|
|
168
|
+
"%="
|
|
169
|
+
"**="
|
|
170
|
+
"&="
|
|
171
|
+
"^="
|
|
172
|
+
"|="
|
|
173
|
+
">>="
|
|
174
|
+
"<<="
|
|
175
|
+
">>>="
|
|
176
|
+
"=="
|
|
177
|
+
"==="
|
|
178
|
+
"!="
|
|
179
|
+
"!=="
|
|
180
|
+
"<"
|
|
181
|
+
">"
|
|
182
|
+
"<="
|
|
183
|
+
">="
|
|
184
|
+
"&"
|
|
185
|
+
"|"
|
|
186
|
+
"^"
|
|
187
|
+
"~"
|
|
188
|
+
"<<"
|
|
189
|
+
">>"
|
|
190
|
+
">>>"
|
|
191
|
+
"->"
|
|
192
|
+
"?"
|
|
193
|
+
"@"
|
|
194
|
+
] @operator
|
|
195
|
+
|
|
196
|
+
[
|
|
197
|
+
"("
|
|
198
|
+
")"
|
|
199
|
+
"["
|
|
200
|
+
"]"
|
|
201
|
+
"{"
|
|
202
|
+
"}"
|
|
203
|
+
] @punctuation.bracket
|
|
204
|
+
|
|
205
|
+
[
|
|
206
|
+
","
|
|
207
|
+
":"
|
|
208
|
+
"."
|
|
209
|
+
";"
|
|
210
|
+
] @punctuation.delimiter
|
|
211
|
+
|
|
212
|
+
; ----------------------------------------------------------------------------
|
|
213
|
+
; Builtins (common RapydScript / JavaScript globals)
|
|
214
|
+
; ----------------------------------------------------------------------------
|
|
215
|
+
|
|
216
|
+
((identifier) @constant.builtin
|
|
217
|
+
(#any-of? @constant.builtin "undefined" "NaN" "Infinity"))
|
|
218
|
+
|
|
219
|
+
((identifier) @variable.builtin
|
|
220
|
+
(#any-of? @variable.builtin "self" "arguments" "window" "document" "console"))
|
|
221
|
+
|
|
222
|
+
((identifier) @function.builtin
|
|
223
|
+
(#any-of? @function.builtin
|
|
224
|
+
"print" "len" "range" "enumerate" "list" "dict" "set" "str" "int" "float"
|
|
225
|
+
"bool" "isinstance" "getattr" "setattr" "hasattr" "iter" "type" "abs"
|
|
226
|
+
"min" "max" "sum" "sorted" "map" "filter" "zip" "repr" "jstype"))
|
|
227
|
+
|
|
228
|
+
((identifier) @type.builtin
|
|
229
|
+
(#any-of? @type.builtin
|
|
230
|
+
"Object" "Array" "String" "Number" "Boolean" "RegExp" "Date" "Error"
|
|
231
|
+
"Exception" "TypeError" "ValueError" "KeyError" "IndexError" "Promise"
|
|
232
|
+
"Map" "Set" "WeakMap" "WeakSet" "Image" "Symbol"))
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
; Smart indentation for RapydScript (nvim-treesitter indent queries).
|
|
2
|
+
;
|
|
3
|
+
; @indent.begin — node whose body should be indented one level
|
|
4
|
+
; @indent.end — node that closes an indent region (closing brackets)
|
|
5
|
+
; @indent.branch — keyword that sits at the same level as its opener
|
|
6
|
+
; (elif/else/except/finally)
|
|
7
|
+
; @indent.align — opening bracket for alignment-based indent
|
|
8
|
+
|
|
9
|
+
; ---------------------------------------------------------------------------
|
|
10
|
+
; Compound statements that introduce an indented block
|
|
11
|
+
; ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
[
|
|
14
|
+
(function_definition)
|
|
15
|
+
(async_function_definition)
|
|
16
|
+
(class_definition)
|
|
17
|
+
(if_statement)
|
|
18
|
+
(while_statement)
|
|
19
|
+
(for_statement)
|
|
20
|
+
(for_js_statement)
|
|
21
|
+
(do_statement)
|
|
22
|
+
(try_statement)
|
|
23
|
+
(with_statement)
|
|
24
|
+
(decorated_definition)
|
|
25
|
+
(anonymous_function)
|
|
26
|
+
(block_tailed_statement)
|
|
27
|
+
(block)
|
|
28
|
+
] @indent.begin
|
|
29
|
+
|
|
30
|
+
; ---------------------------------------------------------------------------
|
|
31
|
+
; Continuation clauses — dedent back to the level of the opening keyword
|
|
32
|
+
; ---------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
(elif_clause) @indent.branch
|
|
35
|
+
(else_clause) @indent.branch
|
|
36
|
+
(except_clause) @indent.branch
|
|
37
|
+
(finally_clause) @indent.branch
|
|
38
|
+
|
|
39
|
+
; do { ... } .while — the trailing ".while" is at statement level
|
|
40
|
+
(do_statement "." @indent.branch)
|
|
41
|
+
|
|
42
|
+
; ---------------------------------------------------------------------------
|
|
43
|
+
; Bracket-delimited containers — alignment / one-level indent inside
|
|
44
|
+
; ---------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
[
|
|
47
|
+
(argument_list)
|
|
48
|
+
(parameters)
|
|
49
|
+
(list)
|
|
50
|
+
(tuple)
|
|
51
|
+
(set)
|
|
52
|
+
(dictionary)
|
|
53
|
+
(list_comprehension)
|
|
54
|
+
(set_comprehension)
|
|
55
|
+
(dictionary_comprehension)
|
|
56
|
+
(generator_expression)
|
|
57
|
+
(parenthesized_expression)
|
|
58
|
+
] @indent.begin
|
|
59
|
+
|
|
60
|
+
[
|
|
61
|
+
")"
|
|
62
|
+
"]"
|
|
63
|
+
"}"
|
|
64
|
+
] @indent.end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
; Language injections for RapydScript
|
|
2
|
+
; These let Neovim highlight embedded languages inside RapydScript source.
|
|
3
|
+
|
|
4
|
+
; Verbatim JavaScript literals ( v'...' ) contain raw JavaScript.
|
|
5
|
+
((verbatim) @injection.content
|
|
6
|
+
(#set! injection.language "javascript"))
|
|
7
|
+
|
|
8
|
+
; Regular expression literals.
|
|
9
|
+
((regex) @injection.content
|
|
10
|
+
(#set! injection.language "regex"))
|
|
11
|
+
|
|
12
|
+
; Comments (for TODO/FIXME highlighting via the `comment` parser, if installed).
|
|
13
|
+
((comment) @injection.content
|
|
14
|
+
(#set! injection.language "comment"))
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
; Scope and definition tracking for RapydScript (nvim-treesitter locals queries).
|
|
2
|
+
;
|
|
3
|
+
; @local.scope — node that introduces a new name scope
|
|
4
|
+
; @local.definition — an identifier being declared/bound in the current scope
|
|
5
|
+
; @local.reference — an identifier being looked up (read)
|
|
6
|
+
|
|
7
|
+
; ---------------------------------------------------------------------------
|
|
8
|
+
; Scopes
|
|
9
|
+
; ---------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
(module) @local.scope
|
|
12
|
+
|
|
13
|
+
(function_definition) @local.scope
|
|
14
|
+
(async_function_definition) @local.scope
|
|
15
|
+
|
|
16
|
+
; Anonymous functions create their own closure scope (the key RapydScript feature)
|
|
17
|
+
(anonymous_function) @local.scope
|
|
18
|
+
(block_tailed_statement) @local.scope
|
|
19
|
+
|
|
20
|
+
(class_definition) @local.scope
|
|
21
|
+
|
|
22
|
+
; ---------------------------------------------------------------------------
|
|
23
|
+
; Definitions
|
|
24
|
+
; ---------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
; Named function and class declarations
|
|
27
|
+
(function_definition
|
|
28
|
+
name: (identifier) @local.definition)
|
|
29
|
+
|
|
30
|
+
(async_function_definition
|
|
31
|
+
name: (identifier) @local.definition)
|
|
32
|
+
|
|
33
|
+
(class_definition
|
|
34
|
+
name: (identifier) @local.definition)
|
|
35
|
+
|
|
36
|
+
; Named anonymous function expression: factorial = def named(n): ...
|
|
37
|
+
(anonymous_function
|
|
38
|
+
name: (identifier) @local.definition)
|
|
39
|
+
|
|
40
|
+
; Function parameters
|
|
41
|
+
(parameters (identifier) @local.definition)
|
|
42
|
+
(typed_parameter
|
|
43
|
+
name: (identifier) @local.definition)
|
|
44
|
+
(default_parameter
|
|
45
|
+
name: (identifier) @local.definition)
|
|
46
|
+
(typed_default_parameter
|
|
47
|
+
name: (identifier) @local.definition)
|
|
48
|
+
(list_splat_parameter
|
|
49
|
+
name: (identifier) @local.definition)
|
|
50
|
+
(dictionary_splat_parameter
|
|
51
|
+
name: (identifier) @local.definition)
|
|
52
|
+
|
|
53
|
+
; Assignment targets
|
|
54
|
+
(assignment
|
|
55
|
+
left: (identifier) @local.definition)
|
|
56
|
+
(assignment
|
|
57
|
+
left: (pattern_list (pattern (identifier) @local.definition)))
|
|
58
|
+
(assignment
|
|
59
|
+
left: (pattern (tuple_pattern (pattern (identifier) @local.definition))))
|
|
60
|
+
(assignment
|
|
61
|
+
left: (pattern (list_pattern (pattern (identifier) @local.definition))))
|
|
62
|
+
|
|
63
|
+
; Augmented assignment also binds the target
|
|
64
|
+
(augmented_assignment
|
|
65
|
+
left: (identifier) @local.definition)
|
|
66
|
+
|
|
67
|
+
; For-loop variables
|
|
68
|
+
(for_statement
|
|
69
|
+
left: (identifier) @local.definition)
|
|
70
|
+
(for_statement
|
|
71
|
+
left: (pattern_list (pattern (identifier) @local.definition)))
|
|
72
|
+
(for_in_clause
|
|
73
|
+
left: (identifier) @local.definition)
|
|
74
|
+
(for_in_clause
|
|
75
|
+
left: (pattern_list (pattern (identifier) @local.definition)))
|
|
76
|
+
|
|
77
|
+
; Import statements
|
|
78
|
+
(import_statement
|
|
79
|
+
name: (dotted_name (identifier) @local.definition))
|
|
80
|
+
|
|
81
|
+
(import_from_statement
|
|
82
|
+
name: (identifier) @local.definition)
|
|
83
|
+
|
|
84
|
+
; `import foo as bar` — bar is the local name
|
|
85
|
+
(aliased_import
|
|
86
|
+
alias: (identifier) @local.definition)
|
|
87
|
+
|
|
88
|
+
; `from foo import baz as qux` — qux is the local name
|
|
89
|
+
(aliased_import_name
|
|
90
|
+
alias: (identifier) @local.definition)
|
|
91
|
+
|
|
92
|
+
; `with expr as alias:`
|
|
93
|
+
(with_clause
|
|
94
|
+
alias: (identifier) @local.definition)
|
|
95
|
+
|
|
96
|
+
; `except ExcType as e:`
|
|
97
|
+
(except_clause
|
|
98
|
+
alias: (identifier) @local.definition)
|
|
99
|
+
|
|
100
|
+
; global / nonlocal declarations — the identifier becomes visible in the scope
|
|
101
|
+
(global_statement (identifier) @local.definition)
|
|
102
|
+
(nonlocal_statement (identifier) @local.definition)
|
|
103
|
+
|
|
104
|
+
; ---------------------------------------------------------------------------
|
|
105
|
+
; References
|
|
106
|
+
; ---------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
(identifier) @local.reference
|