jaclang 0.7.30__py3-none-any.whl → 0.7.32__py3-none-any.whl
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.
Potentially problematic release.
This version of jaclang might be problematic. Click here for more details.
- jaclang/__init__.py +419 -3
- jaclang/compiler/absyntree.py +3 -3
- jaclang/compiler/constant.py +4 -4
- jaclang/compiler/jac.lark +226 -175
- jaclang/compiler/parser.py +1772 -2422
- jaclang/compiler/passes/main/fuse_typeinfo_pass.py +2 -2
- jaclang/compiler/passes/main/import_pass.py +2 -1
- jaclang/compiler/passes/main/inheritance_pass.py +20 -1
- jaclang/compiler/passes/main/pyast_gen_pass.py +565 -723
- jaclang/compiler/passes/main/tests/test_type_check_pass.py +6 -3
- jaclang/compiler/tests/test_parser.py +13 -5
- jaclang/plugin/builtin.py +11 -0
- jaclang/plugin/default.py +64 -10
- jaclang/plugin/feature.py +14 -0
- jaclang/plugin/spec.py +16 -0
- jaclang/plugin/tests/fixtures/graph_purger.jac +2 -0
- jaclang/plugin/tests/fixtures/other_root_access.jac +1 -0
- jaclang/plugin/tests/fixtures/savable_object.jac +2 -0
- jaclang/plugin/tests/fixtures/traversing_save.jac +17 -0
- jaclang/plugin/tests/test_jaseci.py +34 -1
- jaclang/runtimelib/architype.py +9 -19
- jaclang/runtimelib/context.py +25 -9
- jaclang/settings.py +2 -0
- jaclang/tests/fixtures/base_class_complex_expr.jac +38 -0
- jaclang/tests/fixtures/create_dynamic_architype.jac +1 -1
- jaclang/tests/fixtures/nested_impls.jac +55 -0
- jaclang/tests/test_cli.py +21 -0
- jaclang/tests/test_language.py +27 -13
- jaclang/tests/test_reference.py +2 -2
- jaclang/utils/helpers.py +4 -3
- jaclang/utils/profiler.py +62 -0
- {jaclang-0.7.30.dist-info → jaclang-0.7.32.dist-info}/METADATA +1 -1
- {jaclang-0.7.30.dist-info → jaclang-0.7.32.dist-info}/RECORD +35 -31
- {jaclang-0.7.30.dist-info → jaclang-0.7.32.dist-info}/WHEEL +1 -1
- {jaclang-0.7.30.dist-info → jaclang-0.7.32.dist-info}/entry_points.txt +0 -0
jaclang/compiler/jac.lark
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
// Base Module structure
|
|
1
|
+
// [Heading]: Base Module structure.
|
|
2
2
|
start: module
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
// TODO:AST: We should allow the very first top level statement to have
|
|
5
|
+
// docstring but not the module to have one. After allowing that
|
|
6
|
+
// the rule for the module would be:
|
|
7
|
+
//
|
|
8
|
+
// module: STRING? toplevel_stmt*
|
|
9
|
+
//
|
|
10
|
+
module: (toplevel_stmt (tl_stmt_with_doc | toplevel_stmt)*)?
|
|
11
|
+
| STRING (tl_stmt_with_doc | toplevel_stmt)*
|
|
12
|
+
|
|
13
|
+
// AST:TODO: Docstring should be part of the definition of the statement
|
|
14
|
+
// and not all toplevel statement have docstring, example: ImportStmt.
|
|
15
|
+
//
|
|
16
|
+
// Statements that are only valid at the toplevel.
|
|
17
|
+
tl_stmt_with_doc: STRING toplevel_stmt
|
|
18
|
+
toplevel_stmt: import_stmt
|
|
11
19
|
| architype
|
|
12
20
|
| ability
|
|
13
21
|
| global_var
|
|
@@ -15,7 +23,7 @@ element: import_stmt
|
|
|
15
23
|
| py_code_block
|
|
16
24
|
| test
|
|
17
25
|
|
|
18
|
-
// Import/Include Statements
|
|
26
|
+
// [Heading]: Import/Include Statements.
|
|
19
27
|
import_stmt: KW_IMPORT sub_name? KW_FROM from_path LBRACE import_items RBRACE
|
|
20
28
|
| KW_IMPORT sub_name? KW_FROM from_path COMMA import_items SEMI //Deprecated
|
|
21
29
|
| KW_IMPORT sub_name? import_path (COMMA import_path)* SEMI
|
|
@@ -30,7 +38,7 @@ import_item: named_ref (KW_AS NAME)?
|
|
|
30
38
|
sub_name: COLON NAME
|
|
31
39
|
include_stmt: KW_INCLUDE sub_name? import_path SEMI
|
|
32
40
|
|
|
33
|
-
// Architypes
|
|
41
|
+
// [Heading]: Architypes.
|
|
34
42
|
architype: decorators? architype_decl
|
|
35
43
|
| architype_def
|
|
36
44
|
| enum
|
|
@@ -49,15 +57,15 @@ arch_type: KW_WALKER
|
|
|
49
57
|
| KW_NODE
|
|
50
58
|
| KW_CLASS
|
|
51
59
|
|
|
52
|
-
// Architype bodies
|
|
60
|
+
// [Heading]: Architype bodies.
|
|
53
61
|
member_block: LBRACE member_stmt* RBRACE
|
|
54
|
-
member_stmt:
|
|
62
|
+
member_stmt: STRING? (py_code_block | abstract_ability | ability | architype | has_stmt | free_code)
|
|
55
63
|
has_stmt: KW_STATIC? (KW_LET | KW_HAS) access_tag? has_assign_list SEMI
|
|
56
64
|
has_assign_list: (has_assign_list COMMA)? typed_has_clause
|
|
57
65
|
typed_has_clause: named_ref (COLON STRING)? type_tag (EQ expression | KW_BY KW_POST_INIT)?
|
|
58
66
|
type_tag: COLON expression
|
|
59
67
|
|
|
60
|
-
// Enumerations
|
|
68
|
+
// [Heading]: Enumerations.
|
|
61
69
|
enum: decorators? enum_decl
|
|
62
70
|
| enum_def
|
|
63
71
|
|
|
@@ -72,7 +80,7 @@ enum_stmt: NAME (COLON STRING)? EQ expression
|
|
|
72
80
|
| abstract_ability
|
|
73
81
|
| ability
|
|
74
82
|
|
|
75
|
-
// Abilities
|
|
83
|
+
// [Heading]: Abilities.
|
|
76
84
|
ability: decorators? KW_ASYNC? ability_decl
|
|
77
85
|
| decorators? genai_ability
|
|
78
86
|
| ability_def
|
|
@@ -86,20 +94,20 @@ func_decl: (LPAREN func_decl_params? RPAREN)? (RETURN_HINT (STRING COLON)? expre
|
|
|
86
94
|
func_decl_params: (param_var COMMA)* param_var COMMA?
|
|
87
95
|
param_var: (STAR_POW | STAR_MUL)? NAME (COLON STRING)? type_tag (EQ expression)?
|
|
88
96
|
|
|
89
|
-
// Global variables
|
|
97
|
+
// [Heading]: Global variables.
|
|
90
98
|
global_var: (KW_LET | KW_GLOBAL) access_tag? assignment_list SEMI
|
|
91
99
|
assignment_list: (assignment_list COMMA)? assignment
|
|
92
100
|
|
|
93
|
-
// Free code
|
|
101
|
+
// [Heading]: Free code.
|
|
94
102
|
free_code: KW_WITH KW_ENTRY sub_name? code_block
|
|
95
103
|
|
|
96
|
-
// Inline python
|
|
104
|
+
// [Heading]: Inline python.
|
|
97
105
|
py_code_block: PYNLINE
|
|
98
106
|
|
|
99
|
-
// Tests
|
|
107
|
+
// [Heading]: Tests.
|
|
100
108
|
test: KW_TEST NAME? code_block
|
|
101
109
|
|
|
102
|
-
// Implementations
|
|
110
|
+
// [Heading]: Implementations.
|
|
103
111
|
arch_or_ability_chain: arch_or_ability_chain? (ability_ref | arch_ref)
|
|
104
112
|
abil_to_arch_chain: arch_or_ability_chain? arch_ref
|
|
105
113
|
arch_to_abil_chain: arch_or_ability_chain? ability_ref
|
|
@@ -119,7 +127,7 @@ object_ref: OBJECT_OP named_ref
|
|
|
119
127
|
enum_ref: ENUM_OP named_ref
|
|
120
128
|
ability_ref: ABILITY_OP named_ref
|
|
121
129
|
|
|
122
|
-
// Codeblocks and Statements
|
|
130
|
+
// [Heading]: Codeblocks and Statements.
|
|
123
131
|
code_block: LBRACE statement* RBRACE
|
|
124
132
|
|
|
125
133
|
statement: import_stmt
|
|
@@ -149,29 +157,29 @@ statement: import_stmt
|
|
|
149
157
|
| SEMI
|
|
150
158
|
|
|
151
159
|
|
|
152
|
-
// If statements
|
|
160
|
+
// [Heading]: If statements.
|
|
153
161
|
if_stmt: KW_IF expression code_block (elif_stmt | else_stmt)?
|
|
154
162
|
elif_stmt: KW_ELIF expression code_block (elif_stmt | else_stmt)?
|
|
155
163
|
else_stmt: KW_ELSE code_block
|
|
156
164
|
|
|
157
|
-
// While statements
|
|
165
|
+
// [Heading]: While statements.
|
|
158
166
|
while_stmt: KW_WHILE expression code_block
|
|
159
167
|
|
|
160
|
-
// For statements
|
|
168
|
+
// [Heading]: For statements.
|
|
161
169
|
for_stmt: KW_ASYNC? KW_FOR assignment KW_TO expression KW_BY assignment code_block else_stmt?
|
|
162
170
|
| KW_ASYNC? KW_FOR atomic_chain KW_IN expression code_block else_stmt?
|
|
163
171
|
|
|
164
|
-
// Try statements
|
|
172
|
+
// [Heading]: Try statements.
|
|
165
173
|
try_stmt: KW_TRY code_block except_list? else_stmt? finally_stmt?
|
|
166
174
|
except_list: except_def+
|
|
167
175
|
except_def: KW_EXCEPT expression (KW_AS NAME)? code_block
|
|
168
176
|
finally_stmt: KW_FINALLY code_block
|
|
169
177
|
|
|
170
|
-
// Match statements
|
|
178
|
+
// [Heading]: Match statements.
|
|
171
179
|
match_stmt: KW_MATCH expression LBRACE match_case_block+ RBRACE
|
|
172
180
|
match_case_block: KW_CASE pattern_seq (KW_IF expression)? COLON statement+
|
|
173
181
|
|
|
174
|
-
// Match patterns
|
|
182
|
+
// [Heading]: Match patterns.
|
|
175
183
|
pattern_seq: (or_pattern | as_pattern)
|
|
176
184
|
or_pattern: (pattern BW_OR)* pattern
|
|
177
185
|
as_pattern: or_pattern KW_AS NAME
|
|
@@ -184,87 +192,87 @@ pattern: literal_pattern
|
|
|
184
192
|
| class_pattern
|
|
185
193
|
|
|
186
194
|
|
|
187
|
-
// Match litteral patterns
|
|
195
|
+
// [Heading]: Match litteral patterns.
|
|
188
196
|
literal_pattern: (INT | FLOAT | multistring)
|
|
189
197
|
|
|
190
|
-
// Match singleton patterns
|
|
198
|
+
// [Heading]: Match singleton patterns.
|
|
191
199
|
singleton_pattern: (NULL | BOOL)
|
|
192
200
|
|
|
193
|
-
// Match capture patterns
|
|
201
|
+
// [Heading]: Match capture patterns.
|
|
194
202
|
capture_pattern: NAME
|
|
195
203
|
|
|
196
|
-
// Match sequence patterns
|
|
204
|
+
// [Heading]: Match sequence patterns.
|
|
197
205
|
sequence_pattern: LSQUARE list_inner_pattern (COMMA list_inner_pattern)* RSQUARE
|
|
198
206
|
| LPAREN list_inner_pattern (COMMA list_inner_pattern)* RPAREN
|
|
199
207
|
|
|
200
|
-
// Match mapping patterns
|
|
208
|
+
// [Heading]: Match mapping patterns.
|
|
201
209
|
mapping_pattern: LBRACE (dict_inner_pattern (COMMA dict_inner_pattern)*)? RBRACE
|
|
202
210
|
list_inner_pattern: (pattern_seq | STAR_MUL NAME)
|
|
203
211
|
dict_inner_pattern: (literal_pattern COLON pattern_seq | STAR_POW NAME)
|
|
204
212
|
|
|
205
|
-
// Match class patterns
|
|
213
|
+
// [Heading]: Match class patterns.
|
|
206
214
|
class_pattern: NAME (DOT NAME)* LPAREN kw_pattern_list? RPAREN
|
|
207
215
|
| NAME (DOT NAME)* LPAREN pattern_list (COMMA kw_pattern_list)? RPAREN
|
|
208
216
|
|
|
209
217
|
pattern_list: (pattern_list COMMA)? pattern_seq
|
|
210
218
|
kw_pattern_list: (kw_pattern_list COMMA)? named_ref EQ pattern_seq
|
|
211
219
|
|
|
212
|
-
// Context managers
|
|
220
|
+
// [Heading]: Context managers.
|
|
213
221
|
with_stmt: KW_ASYNC? KW_WITH expr_as_list code_block
|
|
214
222
|
expr_as_list: (expr_as COMMA)* expr_as
|
|
215
223
|
expr_as: expression (KW_AS expression)?
|
|
216
224
|
|
|
217
|
-
// Global and nonlocal statements
|
|
225
|
+
// [Heading]: Global and nonlocal statements.
|
|
218
226
|
global_ref: GLOBAL_OP name_list
|
|
219
227
|
nonlocal_ref: NONLOCAL_OP name_list
|
|
220
228
|
name_list: (named_ref COMMA)* named_ref
|
|
221
229
|
|
|
222
|
-
// Data spatial typed context blocks
|
|
230
|
+
// [Heading]: Data spatial typed context blocks.
|
|
223
231
|
typed_ctx_block: RETURN_HINT expression code_block
|
|
224
232
|
|
|
225
|
-
// Return statements
|
|
233
|
+
// [Heading]: Return statements.
|
|
226
234
|
return_stmt: KW_RETURN expression?
|
|
227
235
|
|
|
228
|
-
// Yield statements
|
|
236
|
+
// [Heading]: Yield statements.
|
|
229
237
|
yield_expr: KW_YIELD KW_FROM? expression
|
|
230
238
|
|
|
231
|
-
// Raise statements
|
|
239
|
+
// [Heading]: Raise statements.
|
|
232
240
|
raise_stmt: KW_RAISE (expression (KW_FROM expression)?)?
|
|
233
241
|
|
|
234
|
-
// Assert statements
|
|
242
|
+
// [Heading]: Assert statements.
|
|
235
243
|
assert_stmt: KW_ASSERT expression (COMMA expression)?
|
|
236
244
|
|
|
237
|
-
// Check statements
|
|
245
|
+
// [Heading]: Check statements.
|
|
238
246
|
check_stmt: KW_CHECK expression
|
|
239
247
|
|
|
240
|
-
// Delete statements
|
|
248
|
+
// [Heading]: Delete statements.
|
|
241
249
|
delete_stmt: KW_DELETE expression
|
|
242
250
|
|
|
243
|
-
// Report statements
|
|
251
|
+
// [Heading]: Report statements.
|
|
244
252
|
report_stmt: KW_REPORT expression
|
|
245
253
|
|
|
246
|
-
// Control statements
|
|
254
|
+
// [Heading]: Control statements.
|
|
247
255
|
ctrl_stmt: KW_SKIP | KW_BREAK | KW_CONTINUE
|
|
248
256
|
|
|
249
|
-
// Data spatial Walker statements
|
|
257
|
+
// [Heading]: Data spatial Walker statements.
|
|
250
258
|
walker_stmt: visit_stmt
|
|
251
259
|
| revisit_stmt
|
|
252
260
|
| disengage_stmt
|
|
253
261
|
| ignore_stmt
|
|
254
262
|
|
|
255
|
-
// Visit statements
|
|
263
|
+
// [Heading]: Visit statements.
|
|
256
264
|
visit_stmt: KW_VISIT (inherited_archs)? expression (else_stmt | SEMI)
|
|
257
265
|
|
|
258
|
-
// Revisit statements
|
|
266
|
+
// [Heading]: Revisit statements.
|
|
259
267
|
revisit_stmt: KW_REVISIT expression? (else_stmt | SEMI)
|
|
260
268
|
|
|
261
|
-
// Disengage statements
|
|
269
|
+
// [Heading]: Disengage statements.
|
|
262
270
|
disengage_stmt: KW_DISENGAGE SEMI
|
|
263
271
|
|
|
264
|
-
// Ignore statements
|
|
272
|
+
// [Heading]: Ignore statements.
|
|
265
273
|
ignore_stmt: KW_IGNORE expression SEMI
|
|
266
274
|
|
|
267
|
-
// Assignments
|
|
275
|
+
// [Heading]: Assignments.
|
|
268
276
|
assignment: KW_LET? (atomic_chain EQ)+ (yield_expr | expression)
|
|
269
277
|
| atomic_chain (COLON STRING)? type_tag (EQ (yield_expr | expression))?
|
|
270
278
|
| atomic_chain aug_op (yield_expr | expression)
|
|
@@ -284,29 +292,29 @@ aug_op: RSHIFT_EQ
|
|
|
284
292
|
| MATMUL_EQ
|
|
285
293
|
| STAR_POW_EQ
|
|
286
294
|
|
|
287
|
-
// Expressions
|
|
295
|
+
// [Heading]: Expressions.
|
|
288
296
|
expression: walrus_assign (KW_IF expression KW_ELSE expression)?
|
|
289
297
|
| lambda_expr
|
|
290
298
|
|
|
291
|
-
// Walrus assignments
|
|
299
|
+
// [Heading]: Walrus assignments.
|
|
292
300
|
walrus_assign: (named_ref WALRUS_EQ)? pipe
|
|
293
301
|
|
|
294
|
-
// Lambda expressions
|
|
302
|
+
// [Heading]: Lambda expressions.
|
|
295
303
|
lambda_expr: KW_WITH func_decl_params? (RETURN_HINT expression)? KW_CAN expression
|
|
296
304
|
|
|
297
|
-
// Pipe expressions
|
|
305
|
+
// [Heading]: Pipe expressions.
|
|
298
306
|
pipe: (pipe PIPE_FWD)? pipe_back
|
|
299
307
|
|
|
300
|
-
// Pipe back expressions
|
|
308
|
+
// [Heading]: Pipe back expressions.
|
|
301
309
|
pipe_back: (pipe_back PIPE_BKWD)? bitwise_or
|
|
302
310
|
|
|
303
|
-
// Bitwise expressions
|
|
311
|
+
// [Heading]: Bitwise expressions.
|
|
304
312
|
bitwise_or: (bitwise_or BW_OR)? bitwise_xor
|
|
305
313
|
bitwise_xor: (bitwise_xor BW_XOR)? bitwise_and
|
|
306
314
|
bitwise_and: (bitwise_and BW_AND)? shift
|
|
307
315
|
shift: (shift (RSHIFT | LSHIFT))? logical_or
|
|
308
316
|
|
|
309
|
-
// Logical and compare expressions
|
|
317
|
+
// [Heading]: Logical and compare expressions.
|
|
310
318
|
logical_or: logical_and (KW_OR logical_and)*
|
|
311
319
|
logical_and: logical_not (KW_AND logical_not)*
|
|
312
320
|
logical_not: NOT logical_not | compare
|
|
@@ -323,34 +331,34 @@ cmp_op: KW_ISN
|
|
|
323
331
|
| LT
|
|
324
332
|
| EE
|
|
325
333
|
|
|
326
|
-
// Arithmetic expressions
|
|
334
|
+
// [Heading]: Arithmetic expressions.
|
|
327
335
|
arithmetic: (arithmetic (MINUS | PLUS))? term
|
|
328
336
|
term: (term (MOD | DIV | FLOOR_DIV | STAR_MUL | DECOR_OP))? power
|
|
329
337
|
power: (power STAR_POW)? factor
|
|
330
338
|
factor: (BW_NOT | MINUS | PLUS) factor | connect
|
|
331
339
|
|
|
332
|
-
// Connect expressions
|
|
340
|
+
// [Heading]: Connect expressions.
|
|
333
341
|
connect: (connect (connect_op | disconnect_op))? atomic_pipe
|
|
334
342
|
|
|
335
|
-
// Atomic expressions
|
|
343
|
+
// [Heading]: Atomic expressions.
|
|
336
344
|
atomic_pipe: (atomic_pipe A_PIPE_FWD)? atomic_pipe_back
|
|
337
345
|
|
|
338
|
-
// Atomic pipe back expressions
|
|
346
|
+
// [Heading]: Atomic pipe back expressions.
|
|
339
347
|
atomic_pipe_back: (atomic_pipe_back A_PIPE_BKWD)? ds_spawn
|
|
340
348
|
|
|
341
|
-
// Data spatial spawn expressions
|
|
349
|
+
// [Heading]: Data spatial spawn expressions.
|
|
342
350
|
ds_spawn: (ds_spawn KW_SPAWN)? unpack
|
|
343
351
|
|
|
344
|
-
// Unpack expressions
|
|
352
|
+
// [Heading]: Unpack expressions.
|
|
345
353
|
unpack: STAR_MUL? ref
|
|
346
354
|
|
|
347
|
-
// References (unused)
|
|
355
|
+
// [Heading]: References (unused).
|
|
348
356
|
ref: BW_AND? pipe_call
|
|
349
357
|
|
|
350
|
-
// Data spatial calls
|
|
358
|
+
// [Heading]: Data spatial calls.
|
|
351
359
|
pipe_call: (PIPE_FWD | A_PIPE_FWD | KW_SPAWN | KW_AWAIT)? atomic_chain
|
|
352
360
|
|
|
353
|
-
// Subscripted and dotted expressions
|
|
361
|
+
// [Heading]: Subscripted and dotted expressions.
|
|
354
362
|
atomic_chain: atomic_chain NULL_OK? (filter_compr | assign_compr | index_slice)
|
|
355
363
|
| atomic_chain NULL_OK? (DOT_BKWD | DOT_FWD | DOT) named_ref
|
|
356
364
|
| (atomic_call | atom | edge_ref_chain)
|
|
@@ -361,14 +369,14 @@ index_slice: LSQUARE
|
|
|
361
369
|
RSQUARE
|
|
362
370
|
| list_val
|
|
363
371
|
|
|
364
|
-
// Function calls
|
|
372
|
+
// [Heading]: Function calls.
|
|
365
373
|
atomic_call: atomic_chain LPAREN param_list? (KW_BY atomic_call)? RPAREN
|
|
366
374
|
|
|
367
375
|
param_list: expr_list COMMA kw_expr_list COMMA?
|
|
368
376
|
| kw_expr_list COMMA?
|
|
369
377
|
| expr_list COMMA?
|
|
370
378
|
|
|
371
|
-
// Atom
|
|
379
|
+
// [Heading]: Atom.
|
|
372
380
|
atom: named_ref
|
|
373
381
|
| LPAREN (expression | yield_expr) RPAREN
|
|
374
382
|
| atom_collection
|
|
@@ -388,7 +396,7 @@ atom_literal: builtin_type
|
|
|
388
396
|
|
|
389
397
|
type_ref: TYPE_OP (named_ref | builtin_type)
|
|
390
398
|
|
|
391
|
-
multistring: (fstring | STRING
|
|
399
|
+
multistring: (fstring | STRING)+
|
|
392
400
|
|
|
393
401
|
fstring: FSTR_START fstr_parts FSTR_END
|
|
394
402
|
| FSTR_SQ_START fstr_sq_parts FSTR_SQ_END
|
|
@@ -396,7 +404,7 @@ fstring: FSTR_START fstr_parts FSTR_END
|
|
|
396
404
|
fstr_parts: (FSTR_PIECE | FSTR_BESC | LBRACE expression RBRACE )*
|
|
397
405
|
fstr_sq_parts: (FSTR_SQ_PIECE | FSTR_BESC | LBRACE expression RBRACE )*
|
|
398
406
|
|
|
399
|
-
// Collection values
|
|
407
|
+
// [Heading]: Collection values.
|
|
400
408
|
atom_collection: dict_compr
|
|
401
409
|
| set_compr
|
|
402
410
|
| gen_compr
|
|
@@ -420,7 +428,7 @@ set_val: LBRACE expr_list COMMA? RBRACE
|
|
|
420
428
|
kv_pair: expression COLON expression | STAR_POW expression
|
|
421
429
|
expr_list: (expr_list COMMA)? expression
|
|
422
430
|
|
|
423
|
-
// Tuples and Jac Tuples
|
|
431
|
+
// [Heading]: Tuples and Jac Tuples.
|
|
424
432
|
tuple_list: expression COMMA expr_list COMMA kw_expr_list COMMA?
|
|
425
433
|
| expression COMMA kw_expr_list COMMA?
|
|
426
434
|
| expression COMMA expr_list COMMA?
|
|
@@ -430,7 +438,7 @@ tuple_list: expression COMMA expr_list COMMA kw_expr_list COMMA?
|
|
|
430
438
|
kw_expr_list: (kw_expr_list COMMA)? kw_expr
|
|
431
439
|
kw_expr: named_ref EQ expression | STAR_POW expression
|
|
432
440
|
|
|
433
|
-
// Data Spatial References
|
|
441
|
+
// [Heading]: Data Spatial References.
|
|
434
442
|
edge_ref_chain: (EDGE_OP|NODE_OP)? LSQUARE expression? (edge_op_ref (filter_compr | expression)?)+ RSQUARE
|
|
435
443
|
edge_op_ref: edge_any | edge_from | edge_to
|
|
436
444
|
edge_to: ARROW_R | ARROW_R_P1 typed_filter_compare_list ARROW_R_P2
|
|
@@ -442,7 +450,7 @@ connect_to: CARROW_R | CARROW_R_P1 expression (COLON kw_expr_list)? CARROW_R_P2
|
|
|
442
450
|
connect_from: CARROW_L | CARROW_L_P1 expression (COLON kw_expr_list)? CARROW_L_P2
|
|
443
451
|
connect_any: CARROW_BI | CARROW_L_P1 expression (COLON kw_expr_list)? CARROW_R_P2
|
|
444
452
|
|
|
445
|
-
// Special Comprehensions
|
|
453
|
+
// [Heading]: Special Comprehensions.
|
|
446
454
|
filter_compr: LPAREN NULL_OK filter_compare_list RPAREN
|
|
447
455
|
| LPAREN TYPE_OP NULL_OK typed_filter_compare_list RPAREN
|
|
448
456
|
assign_compr: LPAREN EQ kw_expr_list RPAREN
|
|
@@ -450,7 +458,7 @@ filter_compare_list: (filter_compare_list COMMA)? filter_compare_item
|
|
|
450
458
|
typed_filter_compare_list: expression (COLON filter_compare_list)?
|
|
451
459
|
filter_compare_item: named_ref cmp_op expression
|
|
452
460
|
|
|
453
|
-
// Names and references
|
|
461
|
+
// [Heading]: Names and references.
|
|
454
462
|
named_ref: special_ref
|
|
455
463
|
| KWESC_NAME
|
|
456
464
|
| NAME
|
|
@@ -462,7 +470,7 @@ special_ref: KW_INIT
|
|
|
462
470
|
| KW_SELF
|
|
463
471
|
| KW_HERE
|
|
464
472
|
|
|
465
|
-
// Builtin types
|
|
473
|
+
// [Heading]: Builtin types.
|
|
466
474
|
builtin_type: TYP_TYPE
|
|
467
475
|
| TYP_ANY
|
|
468
476
|
| TYP_BOOL
|
|
@@ -475,7 +483,49 @@ builtin_type: TYP_TYPE
|
|
|
475
483
|
| TYP_BYTES
|
|
476
484
|
| TYP_STRING
|
|
477
485
|
|
|
478
|
-
//
|
|
486
|
+
// ************************************************************************* //
|
|
487
|
+
// Terminals //
|
|
488
|
+
// ************************************************************************* //
|
|
489
|
+
|
|
490
|
+
PYNLINE: /::py::(.|\n|\r)*?::py::/
|
|
491
|
+
GLOBAL_OP: /:g:|:global:/
|
|
492
|
+
NONLOCAL_OP: /:nl:|:nonlocal:/
|
|
493
|
+
WALKER_OP: /:w:|:walker:/
|
|
494
|
+
NODE_OP: /:n:|:node:/
|
|
495
|
+
EDGE_OP: /:e:|:edge:/
|
|
496
|
+
CLASS_OP: /:cls:|:class:/
|
|
497
|
+
OBJECT_OP: /:o:|:obj:/
|
|
498
|
+
TYPE_OP: /`|:t:|:type:/
|
|
499
|
+
ENUM_OP: /:enum:/
|
|
500
|
+
ABILITY_OP: /:c:|:can:/
|
|
501
|
+
|
|
502
|
+
// [Heading]: f-string tokens.
|
|
503
|
+
FSTR_START.1: "f\""
|
|
504
|
+
FSTR_END: "\""
|
|
505
|
+
FSTR_SQ_START.1: "f'"
|
|
506
|
+
FSTR_SQ_END: "'"
|
|
507
|
+
FSTR_PIECE.-1: /[^\{\}\"]+/
|
|
508
|
+
FSTR_SQ_PIECE.-1: /[^\{\}\']+/
|
|
509
|
+
FSTR_BESC.1: /{{|}}/
|
|
510
|
+
|
|
511
|
+
RETURN_HINT: "->"
|
|
512
|
+
NULL_OK: "?"
|
|
513
|
+
COLON: ":"
|
|
514
|
+
SEMI: ";"
|
|
515
|
+
ELLIPSIS: "..."
|
|
516
|
+
DOT: "."
|
|
517
|
+
COMMA: ","
|
|
518
|
+
|
|
519
|
+
LBRACE: "{"
|
|
520
|
+
RBRACE: "}"
|
|
521
|
+
LPAREN: "("
|
|
522
|
+
RPAREN: ")"
|
|
523
|
+
LSQUARE: "["
|
|
524
|
+
RSQUARE: "]"
|
|
525
|
+
|
|
526
|
+
// TODO:AST: These should be just NAME for tokenizer and the parser (or even higher)
|
|
527
|
+
// Should treat them as type names.
|
|
528
|
+
// [Heading]: Lexer Tokens.
|
|
479
529
|
TYP_STRING: "str"
|
|
480
530
|
TYP_INT: "int"
|
|
481
531
|
TYP_FLOAT: "float"
|
|
@@ -487,6 +537,9 @@ TYP_BOOL: "bool"
|
|
|
487
537
|
TYP_BYTES: "bytes"
|
|
488
538
|
TYP_ANY: "any"
|
|
489
539
|
TYP_TYPE: "type"
|
|
540
|
+
|
|
541
|
+
// Keywords ---------------------------------------------------------------- //
|
|
542
|
+
|
|
490
543
|
KW_LET: "let"
|
|
491
544
|
KW_ABSTRACT: "abs"
|
|
492
545
|
KW_CLASS: "class"
|
|
@@ -542,121 +595,119 @@ KW_STATIC: "static"
|
|
|
542
595
|
KW_OVERRIDE: "override"
|
|
543
596
|
KW_MATCH: "match"
|
|
544
597
|
KW_CASE: "case"
|
|
545
|
-
|
|
546
|
-
KW_SELF: "self"
|
|
598
|
+
|
|
547
599
|
KW_INIT: "init"
|
|
548
600
|
KW_POST_INIT: "postinit"
|
|
601
|
+
|
|
602
|
+
KW_HERE: "here"
|
|
603
|
+
KW_SELF: "self"
|
|
549
604
|
KW_SUPER: "super"
|
|
550
605
|
KW_ROOT: "root"
|
|
551
606
|
|
|
552
|
-
FLOAT: /(\d+(\.\d*)|\.\d+)([eE][+-]?\d+)?|\d+([eE][-+]?\d+)/
|
|
553
|
-
DOC_STRING.1: /"""(.|\n|\r)*?"""|'''(.|\n|\r)*?'''/
|
|
554
|
-
PYNLINE: /::py::(.|\n|\r)*?::py::/
|
|
555
|
-
STRING: /(r?b?|b?r?)"[^"\r\n]*"|(r?b?|b?r?)'[^'\r\n]*'/
|
|
556
|
-
BOOL.1: /True|False/
|
|
557
607
|
KW_NIN.1: /\bnot\s+in\b/
|
|
558
608
|
KW_ISN.1: /\bis\s+not\b/
|
|
609
|
+
KW_AND.1: /&&|and/
|
|
610
|
+
KW_OR.1: /\|\||or/
|
|
611
|
+
NOT: "not" // TODO:AST: Rename to KW_NOT
|
|
612
|
+
|
|
613
|
+
// Literals ---------------------------------------------------------------- //
|
|
614
|
+
|
|
615
|
+
STRING: /(r?b?|b?r?)("[^"\r\n]*"|'[^'\r\n]*')/
|
|
616
|
+
| /(r?b?|b?r?)("""(.|\r|\n)*?"""|'''(.|\r|\n)*?''')/
|
|
617
|
+
|
|
618
|
+
NULL.1: "None"
|
|
619
|
+
BOOL.1: /True|False/
|
|
620
|
+
FLOAT: /(\d+(\.\d*)|\.\d+)([eE][+-]?\d+)?|\d+([eE][-+]?\d+)/
|
|
559
621
|
HEX.1: /0[xX][0-9a-fA-F_]+/
|
|
560
622
|
BIN.1: /0[bB][01_]+/
|
|
561
623
|
OCT.1: /0[oO][0-7_]+/
|
|
562
624
|
INT: /[0-9][0-9_]*/
|
|
563
|
-
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
// Identifier -------------------------------------------------------------- //
|
|
628
|
+
|
|
564
629
|
KWESC_NAME: /<>[a-zA-Z_][a-zA-Z0-9_]*/
|
|
565
630
|
NAME: /[a-zA-Z_][a-zA-Z0-9_]*/
|
|
566
631
|
|
|
567
|
-
ARROW_BI: /<-->/
|
|
568
|
-
ARROW_L: /<--/
|
|
569
|
-
ARROW_R: /-->/
|
|
570
|
-
ARROW_L_P1: /<-\:/
|
|
571
|
-
ARROW_R_P2: /:->/
|
|
572
|
-
ARROW_L_P2: /:-/
|
|
573
|
-
ARROW_R_P1: /-\:/
|
|
574
|
-
CARROW_BI: /<\+\+>/
|
|
575
|
-
CARROW_L: /<\+\+/
|
|
576
|
-
CARROW_R: /\+\+>/
|
|
577
|
-
CARROW_L_P1: /<\+\:/
|
|
578
|
-
CARROW_R_P2: /:\+>/
|
|
579
|
-
CARROW_L_P2: /:\+/
|
|
580
|
-
CARROW_R_P1: /\+\:/
|
|
581
|
-
|
|
582
|
-
GLOBAL_OP: /:g:|:global:/
|
|
583
|
-
NONLOCAL_OP: /:nl:|:nonlocal:/
|
|
584
|
-
WALKER_OP: /:w:|:walker:/
|
|
585
|
-
NODE_OP: /:n:|:node:/
|
|
586
|
-
EDGE_OP: /:e:|:edge:/
|
|
587
|
-
CLASS_OP: /:cls:|:class:/
|
|
588
|
-
OBJECT_OP: /:o:|:obj:/
|
|
589
|
-
TYPE_OP: /`|:t:|:type:/
|
|
590
|
-
ENUM_OP: /:enum:/
|
|
591
|
-
ABILITY_OP: /:c:|:can:/
|
|
592
|
-
A_PIPE_FWD: /:>/
|
|
593
|
-
A_PIPE_BKWD: /<:/
|
|
594
|
-
PIPE_FWD: /\|>/
|
|
595
|
-
PIPE_BKWD: /<\|/
|
|
596
|
-
DOT_FWD: /\.>/
|
|
597
|
-
DOT_BKWD: /<\./
|
|
598
|
-
RETURN_HINT: /->/
|
|
599
|
-
NULL_OK: /\?/
|
|
600
|
-
MATMUL_EQ: /@=/
|
|
601
|
-
DECOR_OP: /@/
|
|
602
632
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
WALRUS_EQ:
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
633
|
+
// Data Spatial Operators -------------------------------------------------- //
|
|
634
|
+
|
|
635
|
+
ARROW_BI: "<-->"
|
|
636
|
+
ARROW_L: "<--"
|
|
637
|
+
ARROW_R: "-->"
|
|
638
|
+
ARROW_L_P1: "<-:"
|
|
639
|
+
ARROW_R_P2: ":->"
|
|
640
|
+
ARROW_L_P2: ":-"
|
|
641
|
+
ARROW_R_P1: "-:"
|
|
642
|
+
CARROW_BI: "<++>"
|
|
643
|
+
CARROW_L: "<++"
|
|
644
|
+
CARROW_R: "++>"
|
|
645
|
+
CARROW_L_P1: "<+:"
|
|
646
|
+
CARROW_R_P2: ":+>"
|
|
647
|
+
CARROW_L_P2: ":+"
|
|
648
|
+
CARROW_R_P1: "+:"
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
// Assignment Operator ----------------------------------------------------- //
|
|
652
|
+
|
|
653
|
+
EQ: "="
|
|
654
|
+
WALRUS_EQ: ":="
|
|
655
|
+
|
|
656
|
+
ADD_EQ: "+="
|
|
657
|
+
SUB_EQ: "-="
|
|
658
|
+
MUL_EQ: "*="
|
|
659
|
+
DIV_EQ: "/="
|
|
660
|
+
MOD_EQ: "%="
|
|
661
|
+
MATMUL_EQ: "@="
|
|
662
|
+
STAR_POW_EQ: "**="
|
|
663
|
+
FLOOR_DIV_EQ: "//="
|
|
664
|
+
|
|
665
|
+
BW_AND_EQ: "&="
|
|
666
|
+
BW_OR_EQ: "|="
|
|
667
|
+
BW_XOR_EQ: "^="
|
|
668
|
+
BW_NOT_EQ: "~="
|
|
669
|
+
LSHIFT_EQ: "<<="
|
|
670
|
+
RSHIFT_EQ: ">>="
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
// Arithmatic -------------------------------------------------------------- //
|
|
674
|
+
|
|
675
|
+
EE: "=="
|
|
676
|
+
LT: "<"
|
|
677
|
+
GT: ">"
|
|
678
|
+
LTE: "<="
|
|
679
|
+
GTE: ">="
|
|
680
|
+
NE: "!="
|
|
681
|
+
|
|
682
|
+
PLUS: "+"
|
|
683
|
+
MINUS: "-"
|
|
684
|
+
STAR_MUL: "*"
|
|
685
|
+
DIV: "/"
|
|
686
|
+
MOD: "%"
|
|
687
|
+
STAR_POW: "**"
|
|
688
|
+
FLOOR_DIV: "//"
|
|
689
|
+
DECOR_OP: "@"
|
|
690
|
+
|
|
691
|
+
BW_AND: "&"
|
|
692
|
+
BW_OR: "|"
|
|
693
|
+
BW_XOR: "^"
|
|
694
|
+
BW_NOT: "~"
|
|
695
|
+
LSHIFT: "<<"
|
|
696
|
+
RSHIFT: ">>"
|
|
697
|
+
|
|
698
|
+
// Other Operator ---------------------------------------------------------- //
|
|
699
|
+
|
|
700
|
+
A_PIPE_FWD: ":>"
|
|
701
|
+
A_PIPE_BKWD: "<:"
|
|
702
|
+
PIPE_FWD: "|>"
|
|
703
|
+
PIPE_BKWD: "<|"
|
|
704
|
+
DOT_FWD: ".>"
|
|
705
|
+
DOT_BKWD: "<."
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
// ************************************************************************* //
|
|
709
|
+
// Comments and Whitespace //
|
|
710
|
+
// ************************************************************************* //
|
|
660
711
|
|
|
661
712
|
COMMENT: /#\*(.|\n|\r)*?\*#|#.*/
|
|
662
713
|
WS.-2: /[ \t\f\r\n]/+
|