jaclang 0.7.29__py3-none-any.whl → 0.7.31__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.

Files changed (40) hide show
  1. jaclang/__init__.py +419 -3
  2. jaclang/compiler/__init__.py +1 -1
  3. jaclang/compiler/absyntree.py +15 -5
  4. jaclang/compiler/compile.py +1 -1
  5. jaclang/compiler/constant.py +4 -5
  6. jaclang/compiler/jac.lark +227 -180
  7. jaclang/compiler/parser.py +1335 -1826
  8. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +2 -2
  9. jaclang/compiler/passes/main/import_pass.py +3 -2
  10. jaclang/compiler/passes/main/pyast_gen_pass.py +570 -747
  11. jaclang/compiler/passes/main/tests/test_import_pass.py +4 -1
  12. jaclang/compiler/passes/main/tests/test_type_check_pass.py +6 -3
  13. jaclang/compiler/passes/tool/jac_formatter_pass.py +0 -1
  14. jaclang/compiler/tests/test_importer.py +45 -1
  15. jaclang/compiler/tests/test_parser.py +13 -5
  16. jaclang/plugin/builtin.py +11 -0
  17. jaclang/plugin/default.py +55 -20
  18. jaclang/plugin/feature.py +14 -5
  19. jaclang/plugin/spec.py +16 -6
  20. jaclang/plugin/tests/fixtures/graph_purger.jac +2 -0
  21. jaclang/plugin/tests/fixtures/other_root_access.jac +1 -0
  22. jaclang/plugin/tests/fixtures/savable_object.jac +2 -0
  23. jaclang/plugin/tests/test_jaseci.py +1 -1
  24. jaclang/runtimelib/architype.py +11 -21
  25. jaclang/runtimelib/context.py +25 -9
  26. jaclang/runtimelib/importer.py +26 -3
  27. jaclang/runtimelib/machine.py +2 -2
  28. jaclang/settings.py +2 -0
  29. jaclang/tests/fixtures/create_dynamic_architype.jac +1 -1
  30. jaclang/tests/fixtures/nested_impls.jac +55 -0
  31. jaclang/tests/test_cli.py +1 -1
  32. jaclang/tests/test_language.py +27 -13
  33. jaclang/tests/test_reference.py +2 -2
  34. jaclang/utils/helpers.py +4 -3
  35. jaclang/utils/test.py +2 -2
  36. jaclang/utils/tests/test_lang_tools.py +4 -2
  37. {jaclang-0.7.29.dist-info → jaclang-0.7.31.dist-info}/METADATA +2 -2
  38. {jaclang-0.7.29.dist-info → jaclang-0.7.31.dist-info}/RECORD +40 -39
  39. {jaclang-0.7.29.dist-info → jaclang-0.7.31.dist-info}/WHEEL +1 -1
  40. {jaclang-0.7.29.dist-info → jaclang-0.7.31.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
- module: (doc_tag? element (element_with_doc | element)*)?
5
- | doc_tag (element_with_doc (element_with_doc | element)*)?
6
-
7
- doc_tag: STRING | DOC_STRING
8
- element_with_doc: doc_tag element
9
-
10
- element: import_stmt
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: doc_tag? (py_code_block | abstract_ability | ability | architype | has_stmt | free_code)
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,32 +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
301
- pipe_back: (pipe_back PIPE_BKWD)? elvis_check
302
-
303
- // Elvis expressions
304
- elvis_check: (elvis_check ELVIS_OP)? bitwise_or
308
+ // [Heading]: Pipe back expressions.
309
+ pipe_back: (pipe_back PIPE_BKWD)? bitwise_or
305
310
 
306
- // Bitwise expressions
311
+ // [Heading]: Bitwise expressions.
307
312
  bitwise_or: (bitwise_or BW_OR)? bitwise_xor
308
313
  bitwise_xor: (bitwise_xor BW_XOR)? bitwise_and
309
314
  bitwise_and: (bitwise_and BW_AND)? shift
310
315
  shift: (shift (RSHIFT | LSHIFT))? logical_or
311
316
 
312
- // Logical and compare expressions
317
+ // [Heading]: Logical and compare expressions.
313
318
  logical_or: logical_and (KW_OR logical_and)*
314
319
  logical_and: logical_not (KW_AND logical_not)*
315
320
  logical_not: NOT logical_not | compare
@@ -326,34 +331,34 @@ cmp_op: KW_ISN
326
331
  | LT
327
332
  | EE
328
333
 
329
- // Arithmetic expressions
334
+ // [Heading]: Arithmetic expressions.
330
335
  arithmetic: (arithmetic (MINUS | PLUS))? term
331
336
  term: (term (MOD | DIV | FLOOR_DIV | STAR_MUL | DECOR_OP))? power
332
337
  power: (power STAR_POW)? factor
333
338
  factor: (BW_NOT | MINUS | PLUS) factor | connect
334
339
 
335
- // Connect expressions
340
+ // [Heading]: Connect expressions.
336
341
  connect: (connect (connect_op | disconnect_op))? atomic_pipe
337
342
 
338
- // Atomic expressions
343
+ // [Heading]: Atomic expressions.
339
344
  atomic_pipe: (atomic_pipe A_PIPE_FWD)? atomic_pipe_back
340
345
 
341
- // Atomic pipe back expressions
346
+ // [Heading]: Atomic pipe back expressions.
342
347
  atomic_pipe_back: (atomic_pipe_back A_PIPE_BKWD)? ds_spawn
343
348
 
344
- // Data spatial spawn expressions
349
+ // [Heading]: Data spatial spawn expressions.
345
350
  ds_spawn: (ds_spawn KW_SPAWN)? unpack
346
351
 
347
- // Unpack expressions
352
+ // [Heading]: Unpack expressions.
348
353
  unpack: STAR_MUL? ref
349
354
 
350
- // References (unused)
355
+ // [Heading]: References (unused).
351
356
  ref: BW_AND? pipe_call
352
357
 
353
- // Data spatial calls
358
+ // [Heading]: Data spatial calls.
354
359
  pipe_call: (PIPE_FWD | A_PIPE_FWD | KW_SPAWN | KW_AWAIT)? atomic_chain
355
360
 
356
- // Subscripted and dotted expressions
361
+ // [Heading]: Subscripted and dotted expressions.
357
362
  atomic_chain: atomic_chain NULL_OK? (filter_compr | assign_compr | index_slice)
358
363
  | atomic_chain NULL_OK? (DOT_BKWD | DOT_FWD | DOT) named_ref
359
364
  | (atomic_call | atom | edge_ref_chain)
@@ -364,14 +369,14 @@ index_slice: LSQUARE
364
369
  RSQUARE
365
370
  | list_val
366
371
 
367
- // Function calls
372
+ // [Heading]: Function calls.
368
373
  atomic_call: atomic_chain LPAREN param_list? (KW_BY atomic_call)? RPAREN
369
374
 
370
375
  param_list: expr_list COMMA kw_expr_list COMMA?
371
376
  | kw_expr_list COMMA?
372
377
  | expr_list COMMA?
373
378
 
374
- // Atom
379
+ // [Heading]: Atom.
375
380
  atom: named_ref
376
381
  | LPAREN (expression | yield_expr) RPAREN
377
382
  | atom_collection
@@ -391,7 +396,7 @@ atom_literal: builtin_type
391
396
 
392
397
  type_ref: TYPE_OP (named_ref | builtin_type)
393
398
 
394
- multistring: (fstring | STRING | DOC_STRING)+
399
+ multistring: (fstring | STRING)+
395
400
 
396
401
  fstring: FSTR_START fstr_parts FSTR_END
397
402
  | FSTR_SQ_START fstr_sq_parts FSTR_SQ_END
@@ -399,7 +404,7 @@ fstring: FSTR_START fstr_parts FSTR_END
399
404
  fstr_parts: (FSTR_PIECE | FSTR_BESC | LBRACE expression RBRACE )*
400
405
  fstr_sq_parts: (FSTR_SQ_PIECE | FSTR_BESC | LBRACE expression RBRACE )*
401
406
 
402
- // Collection values
407
+ // [Heading]: Collection values.
403
408
  atom_collection: dict_compr
404
409
  | set_compr
405
410
  | gen_compr
@@ -423,7 +428,7 @@ set_val: LBRACE expr_list COMMA? RBRACE
423
428
  kv_pair: expression COLON expression | STAR_POW expression
424
429
  expr_list: (expr_list COMMA)? expression
425
430
 
426
- // Tuples and Jac Tuples
431
+ // [Heading]: Tuples and Jac Tuples.
427
432
  tuple_list: expression COMMA expr_list COMMA kw_expr_list COMMA?
428
433
  | expression COMMA kw_expr_list COMMA?
429
434
  | expression COMMA expr_list COMMA?
@@ -433,7 +438,7 @@ tuple_list: expression COMMA expr_list COMMA kw_expr_list COMMA?
433
438
  kw_expr_list: (kw_expr_list COMMA)? kw_expr
434
439
  kw_expr: named_ref EQ expression | STAR_POW expression
435
440
 
436
- // Data Spatial References
441
+ // [Heading]: Data Spatial References.
437
442
  edge_ref_chain: (EDGE_OP|NODE_OP)? LSQUARE expression? (edge_op_ref (filter_compr | expression)?)+ RSQUARE
438
443
  edge_op_ref: edge_any | edge_from | edge_to
439
444
  edge_to: ARROW_R | ARROW_R_P1 typed_filter_compare_list ARROW_R_P2
@@ -445,7 +450,7 @@ connect_to: CARROW_R | CARROW_R_P1 expression (COLON kw_expr_list)? CARROW_R_P2
445
450
  connect_from: CARROW_L | CARROW_L_P1 expression (COLON kw_expr_list)? CARROW_L_P2
446
451
  connect_any: CARROW_BI | CARROW_L_P1 expression (COLON kw_expr_list)? CARROW_R_P2
447
452
 
448
- // Special Comprehensions
453
+ // [Heading]: Special Comprehensions.
449
454
  filter_compr: LPAREN NULL_OK filter_compare_list RPAREN
450
455
  | LPAREN TYPE_OP NULL_OK typed_filter_compare_list RPAREN
451
456
  assign_compr: LPAREN EQ kw_expr_list RPAREN
@@ -453,7 +458,7 @@ filter_compare_list: (filter_compare_list COMMA)? filter_compare_item
453
458
  typed_filter_compare_list: expression (COLON filter_compare_list)?
454
459
  filter_compare_item: named_ref cmp_op expression
455
460
 
456
- // Names and references
461
+ // [Heading]: Names and references.
457
462
  named_ref: special_ref
458
463
  | KWESC_NAME
459
464
  | NAME
@@ -465,7 +470,7 @@ special_ref: KW_INIT
465
470
  | KW_SELF
466
471
  | KW_HERE
467
472
 
468
- // Builtin types
473
+ // [Heading]: Builtin types.
469
474
  builtin_type: TYP_TYPE
470
475
  | TYP_ANY
471
476
  | TYP_BOOL
@@ -478,7 +483,49 @@ builtin_type: TYP_TYPE
478
483
  | TYP_BYTES
479
484
  | TYP_STRING
480
485
 
481
- // Lexer Tokens
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.
482
529
  TYP_STRING: "str"
483
530
  TYP_INT: "int"
484
531
  TYP_FLOAT: "float"
@@ -490,6 +537,9 @@ TYP_BOOL: "bool"
490
537
  TYP_BYTES: "bytes"
491
538
  TYP_ANY: "any"
492
539
  TYP_TYPE: "type"
540
+
541
+ // Keywords ---------------------------------------------------------------- //
542
+
493
543
  KW_LET: "let"
494
544
  KW_ABSTRACT: "abs"
495
545
  KW_CLASS: "class"
@@ -545,122 +595,119 @@ KW_STATIC: "static"
545
595
  KW_OVERRIDE: "override"
546
596
  KW_MATCH: "match"
547
597
  KW_CASE: "case"
548
- KW_HERE: "here"
549
- KW_SELF: "self"
598
+
550
599
  KW_INIT: "init"
551
600
  KW_POST_INIT: "postinit"
601
+
602
+ KW_HERE: "here"
603
+ KW_SELF: "self"
552
604
  KW_SUPER: "super"
553
605
  KW_ROOT: "root"
554
606
 
555
- FLOAT: /(\d+(\.\d*)|\.\d+)([eE][+-]?\d+)?|\d+([eE][-+]?\d+)/
556
- DOC_STRING.1: /"""(.|\n|\r)*?"""|'''(.|\n|\r)*?'''/
557
- PYNLINE: /::py::(.|\n|\r)*?::py::/
558
- STRING: /(r?b?|b?r?)"[^"\r\n]*"|(r?b?|b?r?)'[^'\r\n]*'/
559
- BOOL.1: /True|False/
560
607
  KW_NIN.1: /\bnot\s+in\b/
561
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+)/
562
621
  HEX.1: /0[xX][0-9a-fA-F_]+/
563
622
  BIN.1: /0[bB][01_]+/
564
623
  OCT.1: /0[oO][0-7_]+/
565
624
  INT: /[0-9][0-9_]*/
566
- NULL.1: /None/
625
+
626
+
627
+ // Identifier -------------------------------------------------------------- //
628
+
567
629
  KWESC_NAME: /<>[a-zA-Z_][a-zA-Z0-9_]*/
568
630
  NAME: /[a-zA-Z_][a-zA-Z0-9_]*/
569
631
 
570
- ARROW_BI: /<-->/
571
- ARROW_L: /<--/
572
- ARROW_R: /-->/
573
- ARROW_L_P1: /<-\:/
574
- ARROW_R_P2: /:->/
575
- ARROW_L_P2: /:-/
576
- ARROW_R_P1: /-\:/
577
- CARROW_BI: /<\+\+>/
578
- CARROW_L: /<\+\+/
579
- CARROW_R: /\+\+>/
580
- CARROW_L_P1: /<\+\:/
581
- CARROW_R_P2: /:\+>/
582
- CARROW_L_P2: /:\+/
583
- CARROW_R_P1: /\+\:/
584
-
585
- GLOBAL_OP: /:g:|:global:/
586
- NONLOCAL_OP: /:nl:|:nonlocal:/
587
- WALKER_OP: /:w:|:walker:/
588
- NODE_OP: /:n:|:node:/
589
- EDGE_OP: /:e:|:edge:/
590
- CLASS_OP: /:cls:|:class:/
591
- OBJECT_OP: /:o:|:obj:/
592
- TYPE_OP: /`|:t:|:type:/
593
- ENUM_OP: /:enum:/
594
- ABILITY_OP: /:c:|:can:/
595
- A_PIPE_FWD: /:>/
596
- A_PIPE_BKWD: /<:/
597
- PIPE_FWD: /\|>/
598
- PIPE_BKWD: /<\|/
599
- DOT_FWD: /\.>/
600
- DOT_BKWD: /<\./
601
- RETURN_HINT: /->/
602
- ELVIS_OP: /\?:/
603
- NULL_OK: /\?/
604
- MATMUL_EQ: /@=/
605
- DECOR_OP: /@/
606
632
 
607
- KW_AND.1: /&&|and/
608
- KW_OR.1: /\|\||or/
609
- ADD_EQ: /\+=/
610
- SUB_EQ: /-=/
611
- STAR_POW_EQ: /\*\*\=/
612
- MUL_EQ: /\*=/
613
- FLOOR_DIV_EQ: /\/\/=/
614
- DIV_EQ: /\/=/
615
- MOD_EQ: /%=/
616
- BW_AND_EQ: /&=/
617
- BW_OR_EQ: /\|=/
618
- BW_XOR_EQ: /\^=/
619
- BW_NOT_EQ: /~=/
620
- LSHIFT_EQ: /<<=/
621
- RSHIFT_EQ: />>=/
622
- LSHIFT: /<</
623
- RSHIFT: />>/
624
- LTE: /<=/
625
- GTE: />=/
626
- NE: /!=/
627
- NOT: "not"
628
- WALRUS_EQ: /:=/
629
- COLON: /:/
630
- LBRACE: /{/
631
- RBRACE: /}/
632
- SEMI: /;/
633
- EE: /==/
634
- EQ: /=/
635
- ELLIPSIS: /\.\.\./
636
- DOT: /\./
637
- LT: /</
638
- GT: />/
639
- COMMA: /,/
640
- PLUS: /\+/
641
- MINUS: /-/
642
- STAR_POW: /\*\*/
643
- STAR_MUL: /\*/
644
- FLOOR_DIV: /\/\//
645
- DIV: /\//
646
- MOD: /%/
647
- BW_AND: /&/
648
- BW_OR: /\|/
649
- BW_XOR: /\^/
650
- BW_NOT: /~/
651
- LPAREN: /\(/
652
- RPAREN: /\)/
653
- LSQUARE: /\[/
654
- RSQUARE: /\]/
655
-
656
- // f-string tokens
657
- FSTR_START.1: "f\""
658
- FSTR_END: "\""
659
- FSTR_SQ_START.1: "f'"
660
- FSTR_SQ_END: "'"
661
- FSTR_PIECE.-1: /[^\{\}\"]+/
662
- FSTR_SQ_PIECE.-1: /[^\{\}\']+/
663
- FSTR_BESC.1: /{{|}}/
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
+ // ************************************************************************* //
664
711
 
665
712
  COMMENT: /#\*(.|\n|\r)*?\*#|#.*/
666
713
  WS.-2: /[ \t\f\r\n]/+