jaclang 0.8.8__py3-none-any.whl → 0.8.10__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/cli/cli.py +194 -10
- jaclang/cli/cmdreg.py +144 -8
- jaclang/compiler/__init__.py +6 -1
- jaclang/compiler/codeinfo.py +16 -1
- jaclang/compiler/constant.py +33 -8
- jaclang/compiler/jac.lark +154 -62
- jaclang/compiler/larkparse/jac_parser.py +2 -2
- jaclang/compiler/parser.py +656 -149
- jaclang/compiler/passes/__init__.py +2 -1
- jaclang/compiler/passes/ast_gen/__init__.py +5 -0
- jaclang/compiler/passes/ast_gen/base_ast_gen_pass.py +54 -0
- jaclang/compiler/passes/ast_gen/jsx_processor.py +344 -0
- jaclang/compiler/passes/ecmascript/__init__.py +25 -0
- jaclang/compiler/passes/ecmascript/es_unparse.py +576 -0
- jaclang/compiler/passes/ecmascript/esast_gen_pass.py +2068 -0
- jaclang/compiler/passes/ecmascript/estree.py +972 -0
- jaclang/compiler/passes/ecmascript/tests/__init__.py +1 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/advanced_language_features.jac +170 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/class_separate_impl.impl.jac +30 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/class_separate_impl.jac +14 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/client_jsx.jac +89 -0
- jaclang/compiler/passes/ecmascript/tests/fixtures/core_language_features.jac +195 -0
- jaclang/compiler/passes/ecmascript/tests/test_esast_gen_pass.py +167 -0
- jaclang/compiler/passes/ecmascript/tests/test_js_generation.py +239 -0
- jaclang/compiler/passes/main/__init__.py +0 -3
- jaclang/compiler/passes/main/annex_pass.py +23 -1
- jaclang/compiler/passes/main/def_use_pass.py +1 -0
- jaclang/compiler/passes/main/pyast_gen_pass.py +413 -255
- jaclang/compiler/passes/main/pyast_load_pass.py +48 -11
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +2 -0
- jaclang/compiler/passes/main/sym_tab_build_pass.py +18 -1
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.cl.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_arity.jac +3 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_class_construct.jac +33 -0
- jaclang/compiler/passes/main/tests/fixtures/defuse_modpath.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/member_access_type_resolve.jac +2 -1
- jaclang/compiler/passes/main/tests/test_checker_pass.py +31 -3
- jaclang/compiler/passes/main/tests/test_def_use_pass.py +12 -0
- jaclang/compiler/passes/main/tests/test_import_pass.py +23 -4
- jaclang/compiler/passes/main/tests/test_predynamo_pass.py +13 -14
- jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +25 -0
- jaclang/compiler/passes/main/type_checker_pass.py +7 -0
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +219 -20
- jaclang/compiler/passes/tool/fuse_comments_pass.py +1 -10
- jaclang/compiler/passes/tool/jac_formatter_pass.py +2 -2
- jaclang/compiler/passes/tool/tests/fixtures/import_fmt.jac +7 -1
- jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +135 -29
- jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +4 -1
- jaclang/compiler/passes/transform.py +9 -1
- jaclang/compiler/passes/uni_pass.py +5 -7
- jaclang/compiler/program.py +27 -26
- jaclang/compiler/tests/test_client_codegen.py +113 -0
- jaclang/compiler/tests/test_importer.py +12 -10
- jaclang/compiler/tests/test_parser.py +249 -3
- jaclang/compiler/type_system/type_evaluator.jac +1078 -0
- jaclang/compiler/type_system/type_utils.py +1 -1
- jaclang/compiler/type_system/types.py +6 -0
- jaclang/compiler/unitree.py +438 -82
- jaclang/langserve/engine.jac +224 -288
- jaclang/langserve/sem_manager.jac +12 -8
- jaclang/langserve/server.jac +48 -48
- jaclang/langserve/tests/fixtures/greet.py +17 -0
- jaclang/langserve/tests/fixtures/md_path.jac +22 -0
- jaclang/langserve/tests/fixtures/user.jac +15 -0
- jaclang/langserve/tests/test_server.py +66 -371
- jaclang/lib.py +17 -0
- jaclang/runtimelib/archetype.py +25 -25
- jaclang/runtimelib/client_bundle.py +169 -0
- jaclang/runtimelib/client_runtime.jac +586 -0
- jaclang/runtimelib/constructs.py +4 -2
- jaclang/runtimelib/machine.py +308 -139
- jaclang/runtimelib/meta_importer.py +111 -22
- jaclang/runtimelib/mtp.py +15 -0
- jaclang/runtimelib/server.py +1089 -0
- jaclang/runtimelib/tests/fixtures/client_app.jac +18 -0
- jaclang/runtimelib/tests/fixtures/custom_access_validation.jac +1 -1
- jaclang/runtimelib/tests/fixtures/savable_object.jac +4 -5
- jaclang/runtimelib/tests/fixtures/serve_api.jac +75 -0
- jaclang/runtimelib/tests/test_client_bundle.py +55 -0
- jaclang/runtimelib/tests/test_client_render.py +63 -0
- jaclang/runtimelib/tests/test_serve.py +1069 -0
- jaclang/settings.py +0 -3
- jaclang/tests/fixtures/attr_pattern_case.jac +18 -0
- jaclang/tests/fixtures/funccall_genexpr.jac +7 -0
- jaclang/tests/fixtures/funccall_genexpr.py +5 -0
- jaclang/tests/fixtures/iife_functions.jac +142 -0
- jaclang/tests/fixtures/iife_functions_client.jac +143 -0
- jaclang/tests/fixtures/multistatement_lambda.jac +116 -0
- jaclang/tests/fixtures/multistatement_lambda_client.jac +113 -0
- jaclang/tests/fixtures/needs_import_dup.jac +6 -4
- jaclang/tests/fixtures/py2jac_empty.py +0 -0
- jaclang/tests/fixtures/py_run.py +7 -5
- jaclang/tests/fixtures/pyfunc_fstr.py +2 -2
- jaclang/tests/fixtures/simple_lambda_test.jac +12 -0
- jaclang/tests/test_cli.py +134 -18
- jaclang/tests/test_language.py +120 -32
- jaclang/tests/test_reference.py +20 -3
- jaclang/utils/NonGPT.py +375 -0
- jaclang/utils/helpers.py +64 -20
- jaclang/utils/lang_tools.py +31 -4
- jaclang/utils/tests/test_lang_tools.py +5 -16
- jaclang/utils/treeprinter.py +8 -3
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/METADATA +3 -3
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/RECORD +106 -71
- jaclang/compiler/passes/main/binder_pass.py +0 -594
- jaclang/compiler/passes/main/tests/fixtures/sym_binder.jac +0 -47
- jaclang/compiler/passes/main/tests/test_binder_pass.py +0 -111
- jaclang/compiler/type_system/type_evaluator.py +0 -844
- jaclang/langserve/tests/session.jac +0 -294
- jaclang/langserve/tests/test_dev_server.py +0 -80
- jaclang/runtimelib/importer.py +0 -351
- jaclang/tests/test_typecheck.py +0 -542
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/WHEEL +0 -0
- {jaclang-0.8.8.dist-info → jaclang-0.8.10.dist-info}/entry_points.txt +0 -0
jaclang/compiler/jac.lark
CHANGED
|
@@ -5,15 +5,19 @@ module: (toplevel_stmt (tl_stmt_with_doc | toplevel_stmt)*)?
|
|
|
5
5
|
| STRING (tl_stmt_with_doc | toplevel_stmt)*
|
|
6
6
|
|
|
7
7
|
tl_stmt_with_doc: STRING toplevel_stmt
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
toplevel_stmt: KW_CLIENT? onelang_stmt
|
|
10
|
+
| KW_CLIENT LBRACE onelang_stmt* RBRACE
|
|
11
|
+
| py_code_block
|
|
12
|
+
|
|
13
|
+
onelang_stmt: import_stmt
|
|
9
14
|
| archetype
|
|
10
|
-
| impl_def
|
|
11
|
-
| sem_def
|
|
12
15
|
| ability
|
|
13
16
|
| global_var
|
|
14
17
|
| free_code
|
|
15
|
-
| py_code_block
|
|
16
18
|
| test
|
|
19
|
+
| impl_def
|
|
20
|
+
| sem_def
|
|
17
21
|
|
|
18
22
|
// [Heading]: Import/Include Statements.
|
|
19
23
|
import_stmt: KW_IMPORT KW_FROM from_path LBRACE import_items RBRACE
|
|
@@ -28,7 +32,7 @@ import_items: (import_item COMMA)* import_item COMMA?
|
|
|
28
32
|
import_item: named_ref (KW_AS NAME)?
|
|
29
33
|
dotted_name: named_ref (DOT named_ref)*
|
|
30
34
|
|
|
31
|
-
// [Heading]: Archetypes.
|
|
35
|
+
// [Heading]: Class Archetypes.
|
|
32
36
|
archetype: decorators? KW_ASYNC? archetype_decl
|
|
33
37
|
| enum
|
|
34
38
|
|
|
@@ -44,7 +48,7 @@ arch_type: KW_WALKER
|
|
|
44
48
|
| KW_NODE
|
|
45
49
|
| KW_CLASS
|
|
46
50
|
|
|
47
|
-
// [Heading]: Archetype bodies.
|
|
51
|
+
// [Heading]: Class Archetype bodies.
|
|
48
52
|
member_block: LBRACE member_stmt* RBRACE
|
|
49
53
|
member_stmt: STRING? (py_code_block | ability | archetype | impl_def | has_stmt | free_code)
|
|
50
54
|
has_stmt: KW_STATIC? (KW_LET | KW_HAS) access_tag? has_assign_list SEMI
|
|
@@ -55,13 +59,13 @@ type_tag: COLON expression
|
|
|
55
59
|
// [Heading]: Enumerations.
|
|
56
60
|
enum: decorators? enum_decl
|
|
57
61
|
enum_decl: KW_ENUM access_tag? NAME inherited_archs? (enum_block | SEMI)
|
|
58
|
-
enum_block: LBRACE assignment_list
|
|
62
|
+
enum_block: LBRACE assignment_list (py_code_block | free_code)* RBRACE
|
|
59
63
|
|
|
60
64
|
// [Heading]: Functions and Abilities.
|
|
61
65
|
ability: decorators? KW_ASYNC? (ability_decl | function_decl)
|
|
62
66
|
|
|
63
67
|
function_decl: KW_OVERRIDE? KW_STATIC? KW_DEF access_tag? named_ref func_decl? (block_tail | KW_ABSTRACT? SEMI)
|
|
64
|
-
ability_decl: KW_OVERRIDE? KW_STATIC? KW_CAN access_tag? named_ref event_clause (block_tail | KW_ABSTRACT? SEMI)
|
|
68
|
+
ability_decl: KW_OVERRIDE? KW_STATIC? KW_CAN access_tag? named_ref? event_clause (block_tail | KW_ABSTRACT? SEMI)
|
|
65
69
|
block_tail: code_block | KW_BY expression SEMI
|
|
66
70
|
event_clause: KW_WITH expression? (KW_EXIT | KW_ENTRY)
|
|
67
71
|
|
|
@@ -79,13 +83,13 @@ impl_spec: inherited_archs | func_decl | event_clause
|
|
|
79
83
|
impl_tail: enum_block | block_tail
|
|
80
84
|
|
|
81
85
|
// [Heading]: Semstrings.
|
|
82
|
-
sem_def: KW_SEM dotted_name EQ STRING SEMI
|
|
86
|
+
sem_def: KW_SEM dotted_name (EQ | KW_IS) STRING SEMI
|
|
83
87
|
|
|
84
88
|
// [Heading]: Global variables.
|
|
85
89
|
global_var: (KW_LET | KW_GLOBAL) access_tag? assignment_list SEMI
|
|
86
|
-
assignment_list: (
|
|
90
|
+
assignment_list: (assignment | named_ref) (COMMA (assignment | named_ref))* COMMA?
|
|
87
91
|
|
|
88
|
-
// [Heading]:
|
|
92
|
+
// [Heading]: With entry blocks.
|
|
89
93
|
free_code: KW_WITH KW_ENTRY (COLON NAME)? code_block
|
|
90
94
|
|
|
91
95
|
// [Heading]: Inline python.
|
|
@@ -147,7 +151,6 @@ finally_stmt: KW_FINALLY code_block
|
|
|
147
151
|
match_stmt: KW_MATCH expression LBRACE match_case_block+ RBRACE
|
|
148
152
|
match_case_block: KW_CASE pattern_seq (KW_IF expression)? COLON statement+
|
|
149
153
|
|
|
150
|
-
// [Heading]: Match patterns.
|
|
151
154
|
pattern_seq: (or_pattern | as_pattern)
|
|
152
155
|
or_pattern: (pattern BW_OR)* pattern
|
|
153
156
|
as_pattern: or_pattern KW_AS NAME
|
|
@@ -157,28 +160,18 @@ pattern: literal_pattern
|
|
|
157
160
|
| capture_pattern
|
|
158
161
|
| sequence_pattern
|
|
159
162
|
| mapping_pattern
|
|
163
|
+
| attr_pattern
|
|
160
164
|
| class_pattern
|
|
161
165
|
|
|
162
|
-
|
|
163
|
-
// [Heading]: Match literal patterns.
|
|
164
166
|
literal_pattern: (INT | FLOAT | multistring)
|
|
165
|
-
|
|
166
|
-
// [Heading]: Match singleton patterns.
|
|
167
167
|
singleton_pattern: (NULL | BOOL)
|
|
168
|
-
|
|
169
|
-
// [Heading]: Match capture patterns.
|
|
170
168
|
capture_pattern: NAME
|
|
171
|
-
|
|
172
|
-
// [Heading]: Match sequence patterns.
|
|
173
169
|
sequence_pattern: LSQUARE list_inner_pattern (COMMA list_inner_pattern)* RSQUARE
|
|
174
170
|
| LPAREN list_inner_pattern (COMMA list_inner_pattern)* RPAREN
|
|
175
|
-
|
|
176
|
-
// [Heading]: Match mapping patterns.
|
|
177
171
|
mapping_pattern: LBRACE (dict_inner_pattern (COMMA dict_inner_pattern)*)? RBRACE
|
|
178
172
|
list_inner_pattern: (pattern_seq | STAR_MUL NAME)
|
|
179
173
|
dict_inner_pattern: (literal_pattern COLON pattern_seq | STAR_POW NAME)
|
|
180
|
-
|
|
181
|
-
// [Heading]: Match class patterns.
|
|
174
|
+
attr_pattern: NAME (DOT NAME)+
|
|
182
175
|
class_pattern: NAME (DOT NAME)* LPAREN kw_pattern_list? RPAREN
|
|
183
176
|
| NAME (DOT NAME)* LPAREN pattern_list (COMMA kw_pattern_list)? RPAREN
|
|
184
177
|
|
|
@@ -195,7 +188,7 @@ global_ref: GLOBAL_OP name_list
|
|
|
195
188
|
nonlocal_ref: NONLOCAL_OP name_list
|
|
196
189
|
name_list: (named_ref COMMA)* named_ref
|
|
197
190
|
|
|
198
|
-
// [Heading]:
|
|
191
|
+
// [Heading]: Typed context blocks (OSP).
|
|
199
192
|
typed_ctx_block: RETURN_HINT expression code_block
|
|
200
193
|
|
|
201
194
|
// [Heading]: Return statements.
|
|
@@ -219,13 +212,9 @@ report_stmt: KW_REPORT expression
|
|
|
219
212
|
// [Heading]: Control statements.
|
|
220
213
|
ctrl_stmt: KW_SKIP | KW_BREAK | KW_CONTINUE
|
|
221
214
|
|
|
222
|
-
// [Heading]:
|
|
215
|
+
// [Heading]: Walker visit and disengage (OSP).
|
|
223
216
|
spatial_stmt: visit_stmt | disenage_stmt
|
|
224
|
-
|
|
225
|
-
// [Heading]: Visit statements.
|
|
226
217
|
visit_stmt: KW_VISIT (COLON expression COLON)? expression (else_stmt | SEMI)
|
|
227
|
-
|
|
228
|
-
// [Heading]: Disengage statements.
|
|
229
218
|
disenage_stmt: KW_DISENGAGE SEMI
|
|
230
219
|
|
|
231
220
|
// [Heading]: Assignments.
|
|
@@ -235,7 +224,6 @@ assignment: KW_LET? (atomic_chain EQ)+ (yield_expr | expression)
|
|
|
235
224
|
|
|
236
225
|
aug_op: RSHIFT_EQ
|
|
237
226
|
| LSHIFT_EQ
|
|
238
|
-
| BW_NOT_EQ
|
|
239
227
|
| BW_XOR_EQ
|
|
240
228
|
| BW_OR_EQ
|
|
241
229
|
| BW_AND_EQ
|
|
@@ -259,7 +247,8 @@ concurrent_expr: (KW_FLOW | KW_WAIT)? walrus_assign
|
|
|
259
247
|
walrus_assign: (named_ref WALRUS_EQ)? pipe
|
|
260
248
|
|
|
261
249
|
// [Heading]: Lambda expressions.
|
|
262
|
-
lambda_expr: KW_LAMBDA func_decl_params
|
|
250
|
+
lambda_expr: KW_LAMBDA func_decl_params (RETURN_HINT expression)? ( COLON expression | code_block )
|
|
251
|
+
| KW_LAMBDA func_decl? ( COLON expression | code_block )
|
|
263
252
|
|
|
264
253
|
// [Heading]: Pipe expressions.
|
|
265
254
|
pipe: (pipe PIPE_FWD)? pipe_back
|
|
@@ -296,28 +285,29 @@ term: (term (MOD | DIV | FLOOR_DIV | STAR_MUL | DECOR_OP))? power
|
|
|
296
285
|
power: (power STAR_POW)? factor
|
|
297
286
|
factor: (BW_NOT | MINUS | PLUS) factor | connect
|
|
298
287
|
|
|
299
|
-
// [Heading]: Connect expressions.
|
|
288
|
+
// [Heading]: Connect expressions (OSP).
|
|
300
289
|
connect: (connect (connect_op | disconnect_op))? atomic_pipe
|
|
301
290
|
|
|
302
|
-
// [Heading]:
|
|
291
|
+
// [Heading]: Pipe atomic expressions.
|
|
303
292
|
atomic_pipe: (atomic_pipe A_PIPE_FWD)? atomic_pipe_back
|
|
304
293
|
|
|
305
|
-
// [Heading]:
|
|
294
|
+
// [Heading]: Pipe back atomic expressions.
|
|
306
295
|
atomic_pipe_back: (atomic_pipe_back A_PIPE_BKWD)? os_spawn
|
|
307
296
|
|
|
308
|
-
// [Heading]:
|
|
297
|
+
// [Heading]: Spawn expressions (OSP).
|
|
309
298
|
os_spawn: (os_spawn KW_SPAWN)? unpack
|
|
310
299
|
|
|
311
300
|
// [Heading]: Unpack expressions.
|
|
312
301
|
unpack: STAR_MUL? ref
|
|
313
302
|
|
|
314
|
-
// [Heading]: References (
|
|
315
|
-
ref: BW_AND?
|
|
303
|
+
// [Heading]: References (OSP).
|
|
304
|
+
ref: BW_AND? await_expr
|
|
316
305
|
|
|
317
|
-
// [Heading]:
|
|
318
|
-
|
|
306
|
+
// [Heading]: Pipe-style function call.
|
|
307
|
+
await_expr: KW_AWAIT? pipe_call
|
|
308
|
+
pipe_call: (PIPE_FWD | A_PIPE_FWD | KW_SPAWN)? atomic_chain
|
|
319
309
|
|
|
320
|
-
// [Heading]:
|
|
310
|
+
// [Heading]: Attributes and Subscript expressions.
|
|
321
311
|
atomic_chain: atomic_chain NULL_OK? (filter_compr | assign_compr | index_slice)
|
|
322
312
|
| atomic_chain NULL_OK? (DOT_BKWD | DOT_FWD | DOT) named_ref
|
|
323
313
|
| (atomic_call | atom | edge_ref_chain)
|
|
@@ -329,7 +319,7 @@ index_slice: LSQUARE
|
|
|
329
319
|
| list_val
|
|
330
320
|
|
|
331
321
|
// [Heading]: Function calls.
|
|
332
|
-
atomic_call: atomic_chain LPAREN param_list? by_llm? RPAREN
|
|
322
|
+
atomic_call: atomic_chain (gen_compr | LPAREN param_list? by_llm? RPAREN)
|
|
333
323
|
|
|
334
324
|
by_llm: KW_BY expression
|
|
335
325
|
|
|
@@ -337,12 +327,13 @@ param_list: expr_list COMMA kw_expr_list COMMA?
|
|
|
337
327
|
| kw_expr_list COMMA?
|
|
338
328
|
| expr_list COMMA?
|
|
339
329
|
|
|
340
|
-
// [Heading]:
|
|
330
|
+
// [Heading]: Atomic expressions.
|
|
341
331
|
atom: named_ref
|
|
342
|
-
| LPAREN (expression | yield_expr) RPAREN
|
|
332
|
+
| LPAREN (expression | yield_expr | function_decl) RPAREN
|
|
343
333
|
| atom_collection
|
|
344
334
|
| atom_literal
|
|
345
335
|
| type_ref
|
|
336
|
+
| jsx_element
|
|
346
337
|
|
|
347
338
|
atom_literal: builtin_type
|
|
348
339
|
| NULL
|
|
@@ -359,11 +350,34 @@ type_ref: TYPE_OP (named_ref | builtin_type)
|
|
|
359
350
|
|
|
360
351
|
multistring: (fstring | STRING)+
|
|
361
352
|
|
|
362
|
-
|
|
363
|
-
|
|
353
|
+
// [Heading]: Formatted string literals.
|
|
354
|
+
fstring: F_DQ_START fstr_dq_part* F_DQ_END
|
|
355
|
+
| F_SQ_START fstr_sq_part* F_SQ_END
|
|
356
|
+
| F_TDQ_START fstr_tdq_part* F_TDQ_END
|
|
357
|
+
| F_TSQ_START fstr_tsq_part* F_TSQ_END
|
|
358
|
+
| RF_DQ_START rfstr_dq_part* F_DQ_END
|
|
359
|
+
| RF_SQ_START rfstr_sq_part* F_SQ_END
|
|
360
|
+
| RF_TDQ_START rfstr_tdq_part* F_TDQ_END
|
|
361
|
+
| RF_TSQ_START rfstr_tsq_part* F_TSQ_END
|
|
362
|
+
|
|
363
|
+
fstr_dq_part: F_TEXT_DQ | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
364
|
+
|
|
365
|
+
fstr_sq_part: F_TEXT_SQ | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
366
|
+
|
|
367
|
+
fstr_tdq_part: F_TEXT_TDQ | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
368
|
+
|
|
369
|
+
fstr_tsq_part: F_TEXT_TSQ | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
370
|
+
|
|
371
|
+
// Add separate rules for raw f-strings
|
|
372
|
+
rfstr_dq_part: RF_TEXT_DQ | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
364
373
|
|
|
365
|
-
|
|
366
|
-
|
|
374
|
+
rfstr_sq_part: RF_TEXT_SQ | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
375
|
+
|
|
376
|
+
rfstr_tdq_part: RF_TEXT_TDQ | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
377
|
+
|
|
378
|
+
rfstr_tsq_part: RF_TEXT_TSQ | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
379
|
+
|
|
380
|
+
fformat: F_FORMAT_TEXT | D_LBRACE | D_RBRACE | LBRACE expression CONV? (COLON fformat*)? RBRACE
|
|
367
381
|
|
|
368
382
|
// [Heading]: Collection values.
|
|
369
383
|
atom_collection: dict_compr
|
|
@@ -389,7 +403,6 @@ set_val: LBRACE expr_list COMMA? RBRACE
|
|
|
389
403
|
kv_pair: expression COLON expression | STAR_POW expression
|
|
390
404
|
expr_list: (expr_list COMMA)? expression
|
|
391
405
|
|
|
392
|
-
// [Heading]: Tuples and Jac Tuples.
|
|
393
406
|
tuple_list: expression COMMA expr_list COMMA kw_expr_list COMMA?
|
|
394
407
|
| expression COMMA kw_expr_list COMMA?
|
|
395
408
|
| expression COMMA expr_list COMMA?
|
|
@@ -399,7 +412,7 @@ tuple_list: expression COMMA expr_list COMMA kw_expr_list COMMA?
|
|
|
399
412
|
kw_expr_list: (kw_expr_list COMMA)? kw_expr
|
|
400
413
|
kw_expr: named_ref EQ expression | STAR_POW expression
|
|
401
414
|
|
|
402
|
-
// [Heading]:
|
|
415
|
+
// [Heading]: Edge references (OSP).
|
|
403
416
|
edge_ref_chain: LSQUARE KW_ASYNC? (KW_NODE| KW_EDGE)? expression? (edge_op_ref (filter_compr | expression)?)+ RSQUARE
|
|
404
417
|
edge_op_ref: edge_any | edge_from | edge_to
|
|
405
418
|
edge_to: ARROW_R | ARROW_R_P1 typed_filter_compare_list ARROW_R_P2
|
|
@@ -411,7 +424,7 @@ connect_to: CARROW_R | CARROW_R_P1 expression (COLON kw_expr_list)? CARROW_R_P2
|
|
|
411
424
|
connect_from: CARROW_L | CARROW_L_P1 expression (COLON kw_expr_list)? CARROW_L_P2
|
|
412
425
|
connect_any: CARROW_BI | CARROW_L_P1 expression (COLON kw_expr_list)? CARROW_R_P2
|
|
413
426
|
|
|
414
|
-
// [Heading]:
|
|
427
|
+
// [Heading]: Filter and assign comprehensions.
|
|
415
428
|
filter_compr: LPAREN NULL_OK filter_compare_list RPAREN
|
|
416
429
|
| LPAREN TYPE_OP NULL_OK typed_filter_compare_list RPAREN
|
|
417
430
|
assign_compr: LPAREN EQ kw_expr_list RPAREN
|
|
@@ -432,6 +445,37 @@ special_ref: KW_INIT
|
|
|
432
445
|
| KW_HERE
|
|
433
446
|
| KW_VISITOR
|
|
434
447
|
|
|
448
|
+
// [Heading]: JSX Elements.
|
|
449
|
+
jsx_element: jsx_self_closing
|
|
450
|
+
| jsx_fragment
|
|
451
|
+
| jsx_opening_closing
|
|
452
|
+
|
|
453
|
+
jsx_self_closing: JSX_OPEN_START jsx_element_name jsx_attributes? JSX_SELF_CLOSE
|
|
454
|
+
jsx_opening_closing: jsx_opening_element jsx_children? jsx_closing_element
|
|
455
|
+
jsx_fragment: JSX_FRAG_OPEN jsx_children? JSX_FRAG_CLOSE
|
|
456
|
+
|
|
457
|
+
jsx_opening_element: JSX_OPEN_START jsx_element_name jsx_attributes? JSX_TAG_END
|
|
458
|
+
jsx_closing_element: JSX_CLOSE_START jsx_element_name JSX_TAG_END
|
|
459
|
+
|
|
460
|
+
jsx_element_name: JSX_NAME (DOT JSX_NAME)*
|
|
461
|
+
|
|
462
|
+
jsx_attributes: jsx_attribute+
|
|
463
|
+
jsx_attribute: jsx_spread_attribute | jsx_normal_attribute
|
|
464
|
+
|
|
465
|
+
jsx_spread_attribute: LBRACE ELLIPSIS expression RBRACE
|
|
466
|
+
jsx_normal_attribute: JSX_NAME (EQ jsx_attr_value)?
|
|
467
|
+
|
|
468
|
+
jsx_attr_value: STRING
|
|
469
|
+
| LBRACE expression RBRACE
|
|
470
|
+
|
|
471
|
+
jsx_children: jsx_child+
|
|
472
|
+
jsx_child: jsx_element
|
|
473
|
+
| jsx_expression
|
|
474
|
+
| jsx_text
|
|
475
|
+
|
|
476
|
+
jsx_expression: LBRACE expression RBRACE
|
|
477
|
+
jsx_text: JSX_TEXT
|
|
478
|
+
|
|
435
479
|
// [Heading]: Builtin types.
|
|
436
480
|
builtin_type: TYP_TYPE
|
|
437
481
|
| TYP_ANY
|
|
@@ -454,15 +498,6 @@ TYPE_OP: /`/
|
|
|
454
498
|
GLOBAL_OP: "global"
|
|
455
499
|
NONLOCAL_OP: "nonlocal"
|
|
456
500
|
|
|
457
|
-
// [Heading]: f-string tokens.
|
|
458
|
-
FSTR_START.1: "f\""
|
|
459
|
-
FSTR_END: "\""
|
|
460
|
-
FSTR_SQ_START.1: "f'"
|
|
461
|
-
FSTR_SQ_END: "'"
|
|
462
|
-
FSTR_PIECE.-1: /[^\{\}\"]+/
|
|
463
|
-
FSTR_SQ_PIECE.-1: /[^\{\}\']+/
|
|
464
|
-
FSTR_BESC.1: /{{|}}/
|
|
465
|
-
|
|
466
501
|
RETURN_HINT: "->"
|
|
467
502
|
NULL_OK: "?"
|
|
468
503
|
COLON: ":"
|
|
@@ -553,6 +588,7 @@ KW_STATIC: "static"
|
|
|
553
588
|
KW_OVERRIDE: "override"
|
|
554
589
|
KW_MATCH: "match"
|
|
555
590
|
KW_CASE: "case"
|
|
591
|
+
KW_CLIENT: "cl"
|
|
556
592
|
|
|
557
593
|
KW_INIT: "init"
|
|
558
594
|
KW_POST_INIT: "postinit"
|
|
@@ -574,6 +610,35 @@ NOT: "not" // TODO:AST: Rename to KW_NOT
|
|
|
574
610
|
STRING: /(r?b?|b?r?)("[^"\r\n]*"|'[^'\r\n]*')/
|
|
575
611
|
| /(r?b?|b?r?)("""(.|\r|\n)*?"""|'''(.|\r|\n)*?''')/
|
|
576
612
|
|
|
613
|
+
RF_DQ_START.3: /[rR][fF]"|[fF][rR]"/
|
|
614
|
+
RF_SQ_START.3: /[rR][fF]'|[fF][rR]'/
|
|
615
|
+
RF_TDQ_START.3: /[rR][fF]"""|[fF][rR]"""/
|
|
616
|
+
RF_TSQ_START.3: /[rR][fF]'''|[fF][rR]'''/
|
|
617
|
+
F_DQ_START.2: /[fF]"/
|
|
618
|
+
F_SQ_START.2: /[fF]'/
|
|
619
|
+
F_TDQ_START.2: /[fF]"""/
|
|
620
|
+
F_TSQ_START.2: /[fF]'''/
|
|
621
|
+
|
|
622
|
+
F_DQ_END: "\""
|
|
623
|
+
F_SQ_END: "'"
|
|
624
|
+
F_TDQ_END: "\"\"\""
|
|
625
|
+
F_TSQ_END: "'''"
|
|
626
|
+
|
|
627
|
+
D_RBRACE: "}}"
|
|
628
|
+
D_LBRACE: "{{"
|
|
629
|
+
|
|
630
|
+
F_TEXT_DQ.-1: /[^"{}\n\\]+|\\./
|
|
631
|
+
F_TEXT_SQ.-1: /[^'{}\n\\]+|\\./
|
|
632
|
+
F_TEXT_TDQ.-1: /(?:[^"{}\\]|"(?!""))+|\\./s
|
|
633
|
+
F_TEXT_TSQ.-1: /(?:[^'{}\\]|'(?!''))+|\\./s
|
|
634
|
+
RF_TEXT_DQ.-1: /[^"{}]+/
|
|
635
|
+
RF_TEXT_SQ.-1: /[^'{}]+/
|
|
636
|
+
RF_TEXT_TDQ.-1: /(?:[^"{}]|"(?!""))+/s
|
|
637
|
+
RF_TEXT_TSQ.-1: /(?:[^'{}]|'(?!''))+/s
|
|
638
|
+
F_FORMAT_TEXT.-1: /[^{}]+/
|
|
639
|
+
|
|
640
|
+
CONV: /![rRsSaA]/
|
|
641
|
+
|
|
577
642
|
NULL.1: "None"
|
|
578
643
|
BOOL.1: /True|False/
|
|
579
644
|
FLOAT: /(\d+(\.\d*)|\.\d+)([eE][+-]?\d+)?|\d+([eE][-+]?\d+)/
|
|
@@ -624,7 +689,6 @@ FLOOR_DIV_EQ: "//="
|
|
|
624
689
|
BW_AND_EQ: "&="
|
|
625
690
|
BW_OR_EQ: "|="
|
|
626
691
|
BW_XOR_EQ: "^="
|
|
627
|
-
BW_NOT_EQ: "~="
|
|
628
692
|
LSHIFT_EQ: "<<="
|
|
629
693
|
RSHIFT_EQ: ">>="
|
|
630
694
|
|
|
@@ -663,12 +727,40 @@ PIPE_BKWD: "<|"
|
|
|
663
727
|
DOT_FWD: ".>"
|
|
664
728
|
DOT_BKWD: "<."
|
|
665
729
|
|
|
730
|
+
// JSX Contextual Tokens --------------------------------------------------- //
|
|
731
|
+
|
|
732
|
+
// JSX opening tag start: < followed by identifier or uppercase
|
|
733
|
+
// Using lower priority so it doesn't interfere with LT operator
|
|
734
|
+
JSX_OPEN_START.2: /<(?=[A-Z_a-z])/
|
|
735
|
+
|
|
736
|
+
// JSX self-closing end: />
|
|
737
|
+
JSX_SELF_CLOSE: /\/>/
|
|
738
|
+
|
|
739
|
+
// JSX tag end: > (used for both opening and closing)
|
|
740
|
+
JSX_TAG_END: />/
|
|
741
|
+
|
|
742
|
+
// JSX closing tag start: </
|
|
743
|
+
JSX_CLOSE_START: /<\//
|
|
744
|
+
|
|
745
|
+
// JSX fragment open: <>
|
|
746
|
+
JSX_FRAG_OPEN: /<>/
|
|
747
|
+
|
|
748
|
+
// JSX fragment close: </>
|
|
749
|
+
JSX_FRAG_CLOSE: /<\/>/
|
|
750
|
+
|
|
751
|
+
// JSX identifier (NAME in JSX context) - allows hyphens for attributes like data-age, aria-label
|
|
752
|
+
JSX_NAME: /[A-Z_a-z][A-Z_a-z0-9\-]*/
|
|
753
|
+
|
|
754
|
+
// JSX text content (anything except < > { } and must not start/end with whitespace-only)
|
|
755
|
+
// Using negative priority so it's only matched as last resort within JSX
|
|
756
|
+
JSX_TEXT.-1: /[^<>{}\n]+/
|
|
757
|
+
|
|
666
758
|
|
|
667
759
|
// ************************************************************************* //
|
|
668
760
|
// Comments and Whitespace //
|
|
669
761
|
// ************************************************************************* //
|
|
670
762
|
|
|
671
|
-
COMMENT: /#\*(.|\n|\r)*?\*#|#.*/
|
|
763
|
+
COMMENT.4: /#\*(.|\n|\r)*?\*#|#.*/
|
|
672
764
|
WS.-2: /[ \t\f\r\n]/+
|
|
673
765
|
%ignore COMMENT
|
|
674
766
|
%ignore WS
|