jaclang 0.8.9__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 +147 -25
- jaclang/cli/cmdreg.py +144 -8
- jaclang/compiler/__init__.py +6 -1
- jaclang/compiler/codeinfo.py +16 -1
- jaclang/compiler/constant.py +33 -13
- jaclang/compiler/jac.lark +130 -31
- jaclang/compiler/larkparse/jac_parser.py +2 -2
- jaclang/compiler/parser.py +567 -176
- 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/pyast_gen_pass.py +324 -234
- jaclang/compiler/passes/main/pyast_load_pass.py +46 -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 -2
- 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_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 +115 -0
- jaclang/compiler/passes/tool/fuse_comments_pass.py +1 -10
- 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 +22 -25
- 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 +169 -50
- jaclang/compiler/type_system/type_utils.py +1 -1
- jaclang/compiler/type_system/types.py +6 -0
- jaclang/compiler/unitree.py +430 -84
- 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 +1 -1
- jaclang/runtimelib/client_bundle.py +169 -0
- jaclang/runtimelib/client_runtime.jac +586 -0
- jaclang/runtimelib/constructs.py +2 -0
- jaclang/runtimelib/machine.py +259 -100
- 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 -2
- 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/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 +1 -1
- jaclang/tests/test_language.py +10 -39
- jaclang/tests/test_reference.py +17 -2
- jaclang/utils/NonGPT.py +375 -0
- jaclang/utils/helpers.py +44 -16
- jaclang/utils/lang_tools.py +31 -4
- jaclang/utils/tests/test_lang_tools.py +1 -1
- jaclang/utils/treeprinter.py +8 -3
- {jaclang-0.8.9.dist-info → jaclang-0.8.10.dist-info}/METADATA +3 -3
- {jaclang-0.8.9.dist-info → jaclang-0.8.10.dist-info}/RECORD +96 -66
- 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/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.9.dist-info → jaclang-0.8.10.dist-info}/WHEEL +0 -0
- {jaclang-0.8.9.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
|
|
@@ -61,7 +65,7 @@ enum_block: LBRACE assignment_list (py_code_block | free_code)* RBRACE
|
|
|
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
|
|
|
@@ -243,7 +247,8 @@ concurrent_expr: (KW_FLOW | KW_WAIT)? walrus_assign
|
|
|
243
247
|
walrus_assign: (named_ref WALRUS_EQ)? pipe
|
|
244
248
|
|
|
245
249
|
// [Heading]: Lambda expressions.
|
|
246
|
-
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 )
|
|
247
252
|
|
|
248
253
|
// [Heading]: Pipe expressions.
|
|
249
254
|
pipe: (pipe PIPE_FWD)? pipe_back
|
|
@@ -324,10 +329,11 @@ param_list: expr_list COMMA kw_expr_list COMMA?
|
|
|
324
329
|
|
|
325
330
|
// [Heading]: Atomic expressions.
|
|
326
331
|
atom: named_ref
|
|
327
|
-
| LPAREN (expression | yield_expr) RPAREN
|
|
332
|
+
| LPAREN (expression | yield_expr | function_decl) RPAREN
|
|
328
333
|
| atom_collection
|
|
329
334
|
| atom_literal
|
|
330
335
|
| type_ref
|
|
336
|
+
| jsx_element
|
|
331
337
|
|
|
332
338
|
atom_literal: builtin_type
|
|
333
339
|
| NULL
|
|
@@ -344,15 +350,34 @@ type_ref: TYPE_OP (named_ref | builtin_type)
|
|
|
344
350
|
|
|
345
351
|
multistring: (fstring | STRING)+
|
|
346
352
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
|
350
|
-
|
|
|
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
|
|
351
364
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
|
373
|
+
|
|
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
|
|
356
381
|
|
|
357
382
|
// [Heading]: Collection values.
|
|
358
383
|
atom_collection: dict_compr
|
|
@@ -420,6 +445,37 @@ special_ref: KW_INIT
|
|
|
420
445
|
| KW_HERE
|
|
421
446
|
| KW_VISITOR
|
|
422
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
|
+
|
|
423
479
|
// [Heading]: Builtin types.
|
|
424
480
|
builtin_type: TYP_TYPE
|
|
425
481
|
| TYP_ANY
|
|
@@ -442,21 +498,6 @@ TYPE_OP: /`/
|
|
|
442
498
|
GLOBAL_OP: "global"
|
|
443
499
|
NONLOCAL_OP: "nonlocal"
|
|
444
500
|
|
|
445
|
-
// [Heading]: f-string tokens.
|
|
446
|
-
FSTR_TRIPLE_START.2: "f\"\"\""
|
|
447
|
-
FSTR_TRIPLE_END: "\"\"\""
|
|
448
|
-
FSTR_SQ_TRIPLE_START.2: "f'''"
|
|
449
|
-
FSTR_SQ_TRIPLE_END: "'''"
|
|
450
|
-
FSTR_START.1: "f\""
|
|
451
|
-
FSTR_END: "\""
|
|
452
|
-
FSTR_SQ_START.1: "f'"
|
|
453
|
-
FSTR_SQ_END: "'"
|
|
454
|
-
FSTR_TRIPLE_PIECE.-1: /(?:(?!""")(?![{}])[\s\S])+/
|
|
455
|
-
FSTR_SQ_TRIPLE_PIECE.-1: /(?:(?!''')(?![{}])[\s\S])+/
|
|
456
|
-
FSTR_PIECE.-1: /[^\{\}\"]+/
|
|
457
|
-
FSTR_SQ_PIECE.-1: /[^\{\}\']+/
|
|
458
|
-
FSTR_BESC.1: /{{|}}/
|
|
459
|
-
|
|
460
501
|
RETURN_HINT: "->"
|
|
461
502
|
NULL_OK: "?"
|
|
462
503
|
COLON: ":"
|
|
@@ -547,6 +588,7 @@ KW_STATIC: "static"
|
|
|
547
588
|
KW_OVERRIDE: "override"
|
|
548
589
|
KW_MATCH: "match"
|
|
549
590
|
KW_CASE: "case"
|
|
591
|
+
KW_CLIENT: "cl"
|
|
550
592
|
|
|
551
593
|
KW_INIT: "init"
|
|
552
594
|
KW_POST_INIT: "postinit"
|
|
@@ -568,6 +610,35 @@ NOT: "not" // TODO:AST: Rename to KW_NOT
|
|
|
568
610
|
STRING: /(r?b?|b?r?)("[^"\r\n]*"|'[^'\r\n]*')/
|
|
569
611
|
| /(r?b?|b?r?)("""(.|\r|\n)*?"""|'''(.|\r|\n)*?''')/
|
|
570
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
|
+
|
|
571
642
|
NULL.1: "None"
|
|
572
643
|
BOOL.1: /True|False/
|
|
573
644
|
FLOAT: /(\d+(\.\d*)|\.\d+)([eE][+-]?\d+)?|\d+([eE][-+]?\d+)/
|
|
@@ -656,12 +727,40 @@ PIPE_BKWD: "<|"
|
|
|
656
727
|
DOT_FWD: ".>"
|
|
657
728
|
DOT_BKWD: "<."
|
|
658
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
|
+
|
|
659
758
|
|
|
660
759
|
// ************************************************************************* //
|
|
661
760
|
// Comments and Whitespace //
|
|
662
761
|
// ************************************************************************* //
|
|
663
762
|
|
|
664
|
-
COMMENT: /#\*(.|\n|\r)*?\*#|#.*/
|
|
763
|
+
COMMENT.4: /#\*(.|\n|\r)*?\*#|#.*/
|
|
665
764
|
WS.-2: /[ \t\f\r\n]/+
|
|
666
765
|
%ignore COMMENT
|
|
667
766
|
%ignore WS
|