jaclang 0.4.7__py3-none-any.whl → 0.5.0__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 +5 -2
- jaclang/cli/cli.py +56 -8
- jaclang/cli/cmdreg.py +16 -9
- jaclang/compiler/__jac_gen__/jac_parser.py +11 -15
- jaclang/compiler/absyntree.py +53 -19
- jaclang/compiler/codeloc.py +3 -1
- jaclang/compiler/{transpiler.py → compile.py} +3 -2
- jaclang/compiler/constant.py +4 -0
- jaclang/compiler/parser.py +156 -108
- jaclang/compiler/passes/ir_pass.py +1 -0
- jaclang/compiler/passes/main/__init__.py +2 -1
- jaclang/compiler/passes/main/def_impl_match_pass.py +1 -0
- jaclang/compiler/passes/main/def_use_pass.py +1 -0
- jaclang/compiler/passes/main/import_pass.py +18 -18
- jaclang/compiler/passes/main/pyast_gen_pass.py +1228 -853
- jaclang/compiler/passes/main/pyast_load_pass.py +3 -1
- jaclang/compiler/passes/main/pybc_gen_pass.py +46 -0
- jaclang/compiler/passes/main/pyout_pass.py +6 -7
- jaclang/compiler/passes/main/schedules.py +5 -9
- jaclang/compiler/passes/main/sub_node_tab_pass.py +1 -0
- jaclang/compiler/passes/main/sym_tab_build_pass.py +21 -9
- jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +2 -1
- jaclang/compiler/passes/main/tests/test_def_use_pass.py +2 -1
- jaclang/compiler/passes/main/tests/test_import_pass.py +2 -1
- jaclang/compiler/passes/main/tests/test_pyast_build_pass.py +1 -0
- jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +15 -38
- jaclang/compiler/passes/main/tests/test_pybc_gen_pass.py +25 -0
- jaclang/compiler/passes/main/tests/test_sub_node_pass.py +1 -1
- jaclang/compiler/passes/main/tests/test_sym_tab_build_pass.py +2 -1
- jaclang/compiler/passes/main/tests/test_type_check_pass.py +17 -1
- jaclang/compiler/passes/main/type_check_pass.py +9 -6
- jaclang/compiler/passes/tool/__init__.py +1 -0
- jaclang/compiler/passes/tool/ast_printer_pass.py +1 -0
- jaclang/compiler/passes/tool/fuse_comments_pass.py +1 -1
- jaclang/compiler/passes/tool/jac_formatter_pass.py +69 -32
- jaclang/compiler/passes/tool/schedules.py +1 -0
- jaclang/compiler/passes/tool/sym_tab_printer_pass.py +1 -0
- jaclang/compiler/passes/tool/tests/test_ast_print_pass.py +2 -1
- jaclang/compiler/passes/tool/tests/test_fuse_comments_pass.py +1 -0
- jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +4 -3
- jaclang/compiler/passes/tool/tests/test_symtab_print_pass.py +2 -1
- jaclang/compiler/passes/transform.py +1 -0
- jaclang/compiler/passes/utils/mypy_ast_build.py +203 -17
- jaclang/compiler/symtable.py +1 -0
- jaclang/compiler/tests/test_importer.py +3 -2
- jaclang/compiler/tests/test_parser.py +1 -0
- jaclang/compiler/tests/test_workspace.py +1 -0
- jaclang/compiler/workspace.py +18 -5
- jaclang/core/construct.py +9 -32
- jaclang/{compiler → core}/importer.py +95 -85
- jaclang/core/utils.py +17 -12
- jaclang/plugin/__init__.py +1 -0
- jaclang/plugin/default.py +145 -43
- jaclang/plugin/feature.py +65 -19
- jaclang/plugin/spec.py +56 -34
- jaclang/plugin/tests/test_features.py +9 -0
- jaclang/utils/helpers.py +1 -0
- jaclang/utils/lang_tools.py +13 -19
- jaclang/utils/tests/test_lang_tools.py +2 -1
- jaclang/utils/treeprinter.py +2 -1
- jaclang/vendor/lark/common.py +3 -1
- jaclang/vendor/lark/lexer.py +6 -12
- jaclang/vendor/lark/parsers/lalr_parser.py +1 -0
- jaclang/vendor/mypy/applytype.py +2 -1
- jaclang/vendor/mypy/binder.py +1 -1
- jaclang/vendor/mypy/build.py +7 -9
- jaclang/vendor/mypy/checker.py +57 -33
- jaclang/vendor/mypy/checkexpr.py +42 -29
- jaclang/vendor/mypy/checkmember.py +13 -1
- jaclang/vendor/mypy/checkpattern.py +1 -1
- jaclang/vendor/mypy/checkstrformat.py +2 -4
- jaclang/vendor/mypy/constraints.py +10 -5
- jaclang/vendor/mypy/dmypy_server.py +3 -3
- jaclang/vendor/mypy/dmypy_util.py +62 -3
- jaclang/vendor/mypy/errors.py +1 -1
- jaclang/vendor/mypy/evalexpr.py +1 -0
- jaclang/vendor/mypy/expandtype.py +29 -29
- jaclang/vendor/mypy/fastparse.py +51 -31
- jaclang/vendor/mypy/inspections.py +5 -3
- jaclang/vendor/mypy/join.py +4 -4
- jaclang/vendor/mypy/main.py +6 -6
- jaclang/vendor/mypy/message_registry.py +1 -2
- jaclang/vendor/mypy/messages.py +31 -23
- jaclang/vendor/mypy/metastore.py +1 -2
- jaclang/vendor/mypy/modulefinder.py +2 -22
- jaclang/vendor/mypy/nodes.py +22 -20
- jaclang/vendor/mypy/options.py +4 -0
- jaclang/vendor/mypy/parse.py +6 -2
- jaclang/vendor/mypy/patterns.py +6 -6
- jaclang/vendor/mypy/plugin.py +3 -1
- jaclang/vendor/mypy/plugins/attrs.py +52 -10
- jaclang/vendor/mypy/plugins/common.py +2 -1
- jaclang/vendor/mypy/plugins/enums.py +3 -2
- jaclang/vendor/mypy/plugins/functools.py +1 -0
- jaclang/vendor/mypy/renaming.py +1 -1
- jaclang/vendor/mypy/report.py +15 -15
- jaclang/vendor/mypy/semanal.py +22 -13
- jaclang/vendor/mypy/semanal_enum.py +1 -1
- jaclang/vendor/mypy/semanal_namedtuple.py +1 -2
- jaclang/vendor/mypy/semanal_shared.py +3 -6
- jaclang/vendor/mypy/semanal_typeddict.py +16 -5
- jaclang/vendor/mypy/server/astdiff.py +15 -9
- jaclang/vendor/mypy/server/astmerge.py +5 -5
- jaclang/vendor/mypy/stats.py +0 -5
- jaclang/vendor/mypy/stubdoc.py +1 -1
- jaclang/vendor/mypy/stubgen.py +12 -21
- jaclang/vendor/mypy/stubgenc.py +16 -8
- jaclang/vendor/mypy/stubtest.py +57 -48
- jaclang/vendor/mypy/stubutil.py +28 -15
- jaclang/vendor/mypy/subtypes.py +4 -4
- jaclang/vendor/mypy/test/helpers.py +2 -2
- jaclang/vendor/mypy/test/meta/test_parse_data.py +1 -0
- jaclang/vendor/mypy/test/meta/test_update_data.py +1 -0
- jaclang/vendor/mypy/test/testargs.py +1 -0
- jaclang/vendor/mypy/test/testcheck.py +4 -1
- jaclang/vendor/mypy/test/testconstraints.py +25 -7
- jaclang/vendor/mypy/test/testerrorstream.py +1 -0
- jaclang/vendor/mypy/test/testformatter.py +2 -2
- jaclang/vendor/mypy/test/testparse.py +6 -4
- jaclang/vendor/mypy/test/testpythoneval.py +1 -0
- jaclang/vendor/mypy/test/testreports.py +1 -0
- jaclang/vendor/mypy/test/teststubgen.py +1 -2
- jaclang/vendor/mypy/test/teststubtest.py +98 -4
- jaclang/vendor/mypy/test/testtypes.py +1 -1
- jaclang/vendor/mypy/test/testutil.py +22 -0
- jaclang/vendor/mypy/typeanal.py +302 -158
- jaclang/vendor/mypy/typeops.py +22 -13
- jaclang/vendor/mypy/types.py +33 -34
- jaclang/vendor/mypy/typestate.py +2 -2
- jaclang/vendor/mypy/util.py +7 -6
- jaclang/vendor/mypy/version.py +1 -1
- jaclang/vendor/mypyc/analysis/ircheck.py +1 -0
- jaclang/vendor/mypyc/codegen/emitfunc.py +5 -3
- jaclang/vendor/mypyc/codegen/emitmodule.py +12 -12
- jaclang/vendor/mypyc/codegen/emitwrapper.py +2 -2
- jaclang/vendor/mypyc/ir/class_ir.py +10 -6
- jaclang/vendor/mypyc/irbuild/builder.py +3 -4
- jaclang/vendor/mypyc/irbuild/function.py +5 -3
- jaclang/vendor/mypyc/irbuild/nonlocalcontrol.py +1 -2
- jaclang/vendor/mypyc/irbuild/prepare.py +6 -6
- jaclang/vendor/mypyc/primitives/registry.py +15 -5
- jaclang/vendor/mypyc/test/test_run.py +1 -2
- jaclang/vendor/mypyc/transform/uninit.py +3 -3
- jaclang/vendor/pluggy/_callers.py +1 -0
- jaclang/vendor/pluggy/_hooks.py +6 -10
- jaclang/vendor/pluggy/_result.py +1 -0
- jaclang/vendor/pluggy/_tracing.py +1 -0
- {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/METADATA +1 -1
- {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/RECORD +152 -150
- {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/WHEEL +0 -0
- {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/entry_points.txt +0 -0
- {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/top_level.txt +0 -0
jaclang/compiler/absyntree.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Abstract class for IR Passes for Jac."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
import ast as ast3
|
|
@@ -99,6 +100,13 @@ class AstNode:
|
|
|
99
100
|
"""Print ast."""
|
|
100
101
|
return dotgen_ast_tree(self)
|
|
101
102
|
|
|
103
|
+
def flatten(self) -> list[AstNode]:
|
|
104
|
+
"""Flatten ast."""
|
|
105
|
+
ret = [self]
|
|
106
|
+
for k in self.kid:
|
|
107
|
+
ret += k.flatten()
|
|
108
|
+
return ret
|
|
109
|
+
|
|
102
110
|
|
|
103
111
|
class AstSymbolNode(AstNode):
|
|
104
112
|
"""Nodes that have link to a symbol in symbol table."""
|
|
@@ -127,9 +135,11 @@ class AstAccessNode(AstNode):
|
|
|
127
135
|
return (
|
|
128
136
|
SymbolAccess.PRIVATE
|
|
129
137
|
if self.access and self.access.tag.value == Tok.KW_PRIV
|
|
130
|
-
else
|
|
131
|
-
|
|
132
|
-
|
|
138
|
+
else (
|
|
139
|
+
SymbolAccess.PROTECTED
|
|
140
|
+
if self.access and self.access.tag.value == Tok.KW_PROT
|
|
141
|
+
else SymbolAccess.PUBLIC
|
|
142
|
+
)
|
|
133
143
|
)
|
|
134
144
|
|
|
135
145
|
|
|
@@ -387,19 +397,17 @@ class Import(ElementStmt, CodeBlockStmt):
|
|
|
387
397
|
def __init__(
|
|
388
398
|
self,
|
|
389
399
|
lang: SubTag[Name],
|
|
390
|
-
|
|
400
|
+
paths: list[ModulePath],
|
|
391
401
|
items: Optional[SubNodeList[ModuleItem]],
|
|
392
402
|
is_absorb: bool, # For includes
|
|
393
403
|
kid: Sequence[AstNode],
|
|
394
404
|
doc: Optional[String] = None,
|
|
395
|
-
sub_module: Optional[Module] = None,
|
|
396
405
|
) -> None:
|
|
397
406
|
"""Initialize import node."""
|
|
398
407
|
self.lang = lang
|
|
399
|
-
self.
|
|
408
|
+
self.paths = paths
|
|
400
409
|
self.items = items
|
|
401
410
|
self.is_absorb = is_absorb
|
|
402
|
-
self.sub_module = sub_module
|
|
403
411
|
AstNode.__init__(self, kid=kid)
|
|
404
412
|
AstDocNode.__init__(self, doc=doc)
|
|
405
413
|
|
|
@@ -412,10 +420,12 @@ class ModulePath(AstSymbolNode):
|
|
|
412
420
|
path: Sequence[Token],
|
|
413
421
|
alias: Optional[Name],
|
|
414
422
|
kid: Sequence[AstNode],
|
|
423
|
+
sub_module: Optional[Module] = None,
|
|
415
424
|
) -> None:
|
|
416
425
|
"""Initialize module path node."""
|
|
417
426
|
self.path = path
|
|
418
427
|
self.alias = alias
|
|
428
|
+
self.sub_module = sub_module
|
|
419
429
|
self.path_str: str = "".join([p.value for p in path])
|
|
420
430
|
AstNode.__init__(self, kid=kid)
|
|
421
431
|
AstSymbolNode.__init__(
|
|
@@ -472,21 +482,39 @@ class Architype(ArchSpec, AstAccessNode, ArchBlockStmt):
|
|
|
472
482
|
self,
|
|
473
483
|
sym_name=name.value,
|
|
474
484
|
sym_name_node=name,
|
|
475
|
-
sym_type=
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
485
|
+
sym_type=(
|
|
486
|
+
SymbolType.OBJECT_ARCH
|
|
487
|
+
if arch_type.name == Tok.KW_OBJECT
|
|
488
|
+
else (
|
|
489
|
+
SymbolType.NODE_ARCH
|
|
490
|
+
if arch_type.name == Tok.KW_NODE
|
|
491
|
+
else (
|
|
492
|
+
SymbolType.EDGE_ARCH
|
|
493
|
+
if arch_type.name == Tok.KW_EDGE
|
|
494
|
+
else (
|
|
495
|
+
SymbolType.WALKER_ARCH
|
|
496
|
+
if arch_type.name == Tok.KW_WALKER
|
|
497
|
+
else SymbolType.TYPE
|
|
498
|
+
)
|
|
499
|
+
)
|
|
500
|
+
)
|
|
501
|
+
),
|
|
484
502
|
)
|
|
485
503
|
AstAccessNode.__init__(self, access=access)
|
|
486
504
|
AstDocNode.__init__(self, doc=doc)
|
|
487
505
|
AstSemStrNode.__init__(self, semstr=semstr)
|
|
488
506
|
ArchSpec.__init__(self, decorators=decorators)
|
|
489
507
|
|
|
508
|
+
@property
|
|
509
|
+
def is_abstract(self) -> bool:
|
|
510
|
+
"""Check if has an abstract method."""
|
|
511
|
+
body = (
|
|
512
|
+
self.body.items
|
|
513
|
+
if isinstance(self.body, SubNodeList)
|
|
514
|
+
else self.body.body.items if isinstance(self.body, ArchDef) else []
|
|
515
|
+
)
|
|
516
|
+
return any(isinstance(i, Ability) and i.is_abstract for i in body)
|
|
517
|
+
|
|
490
518
|
|
|
491
519
|
class ArchDef(ArchSpec, AstImplOnlyNode):
|
|
492
520
|
"""ArchDef node type for Jac Ast."""
|
|
@@ -589,6 +617,7 @@ class Ability(
|
|
|
589
617
|
name_ref: NameSpec,
|
|
590
618
|
is_func: bool,
|
|
591
619
|
is_async: bool,
|
|
620
|
+
is_override: bool,
|
|
592
621
|
is_static: bool,
|
|
593
622
|
is_abstract: bool,
|
|
594
623
|
access: Optional[SubTag[Token]],
|
|
@@ -602,6 +631,7 @@ class Ability(
|
|
|
602
631
|
"""Initialize func arch node."""
|
|
603
632
|
self.name_ref = name_ref
|
|
604
633
|
self.is_func = is_func
|
|
634
|
+
self.is_override = is_override
|
|
605
635
|
self.is_static = is_static
|
|
606
636
|
self.is_abstract = is_abstract
|
|
607
637
|
self.decorators = decorators
|
|
@@ -755,7 +785,11 @@ class ArchRefChain(AstNode):
|
|
|
755
785
|
"""Resolve name."""
|
|
756
786
|
|
|
757
787
|
def get_tag(x: ArchRef) -> str:
|
|
758
|
-
return
|
|
788
|
+
return (
|
|
789
|
+
"en"
|
|
790
|
+
if x.arch.value == "enum"
|
|
791
|
+
else "cls" if x.arch.value == "class" else x.arch.value[1]
|
|
792
|
+
)
|
|
759
793
|
|
|
760
794
|
return ".".join([f"({get_tag(x)}){x.py_resolve_name()}" for x in self.archs])
|
|
761
795
|
|
|
@@ -1449,7 +1483,7 @@ class KVPair(AstNode):
|
|
|
1449
1483
|
|
|
1450
1484
|
def __init__(
|
|
1451
1485
|
self,
|
|
1452
|
-
key: Expr,
|
|
1486
|
+
key: Optional[Expr], # is **key if blank
|
|
1453
1487
|
value: Expr,
|
|
1454
1488
|
kid: Sequence[AstNode],
|
|
1455
1489
|
) -> None:
|
|
@@ -1464,7 +1498,7 @@ class KWPair(AstNode):
|
|
|
1464
1498
|
|
|
1465
1499
|
def __init__(
|
|
1466
1500
|
self,
|
|
1467
|
-
key: NameSpec,
|
|
1501
|
+
key: Optional[NameSpec], # is **value if blank
|
|
1468
1502
|
value: Expr,
|
|
1469
1503
|
kid: Sequence[AstNode],
|
|
1470
1504
|
) -> None:
|
jaclang/compiler/codeloc.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Code location info for AST nodes."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
import ast as ast3
|
|
@@ -17,8 +18,9 @@ class CodeGenTarget:
|
|
|
17
18
|
|
|
18
19
|
py: str = ""
|
|
19
20
|
jac: str = ""
|
|
20
|
-
py_ast:
|
|
21
|
+
py_ast: list[ast3.AST] = field(default_factory=lambda: [])
|
|
21
22
|
mypy_ast: list[MypyNode] = field(default_factory=lambda: [])
|
|
23
|
+
py_bytecode: Optional[bytes] = None
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
class CodeLocInfo:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Transpilation functions."""
|
|
2
|
+
|
|
2
3
|
from typing import Optional, Type
|
|
3
4
|
|
|
4
5
|
import jaclang.compiler.absyntree as ast
|
|
@@ -10,8 +11,8 @@ from jaclang.compiler.passes.tool.schedules import format_pass
|
|
|
10
11
|
from jaclang.compiler.passes.transform import Alert
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
def
|
|
14
|
-
"""
|
|
14
|
+
def compile_jac(file_path: str) -> list[Alert]:
|
|
15
|
+
"""Start Compile for Jac file and return python code as string."""
|
|
15
16
|
code = jac_file_to_pass(
|
|
16
17
|
file_path=file_path,
|
|
17
18
|
schedule=pass_schedule,
|
jaclang/compiler/constant.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Constants across the project."""
|
|
2
|
+
|
|
2
3
|
from enum import Enum
|
|
3
4
|
|
|
4
5
|
|
|
@@ -78,6 +79,7 @@ class Tokens(str, Enum):
|
|
|
78
79
|
KW_LET = "KW_LET"
|
|
79
80
|
KW_ABSTRACT = "KW_ABSTRACT"
|
|
80
81
|
KW_OBJECT = "KW_OBJECT"
|
|
82
|
+
KW_CLASS = "KW_CLASS"
|
|
81
83
|
KW_ENUM = "KW_ENUM"
|
|
82
84
|
KW_NODE = "KW_NODE"
|
|
83
85
|
KW_IGNORE = "KW_IGNORE"
|
|
@@ -162,6 +164,7 @@ class Tokens(str, Enum):
|
|
|
162
164
|
COMMA = "COMMA"
|
|
163
165
|
KW_CAN = "KW_CAN"
|
|
164
166
|
KW_STATIC = "KW_STATIC"
|
|
167
|
+
KW_OVERRIDE = "KW_OVERRIDE"
|
|
165
168
|
KW_MATCH = "KW_MATCH"
|
|
166
169
|
KW_CASE = "KW_CASE"
|
|
167
170
|
PLUS = "PLUS"
|
|
@@ -205,6 +208,7 @@ class Tokens(str, Enum):
|
|
|
205
208
|
WALKER_OP = "WALKER_OP"
|
|
206
209
|
NODE_OP = "NODE_OP"
|
|
207
210
|
EDGE_OP = "EDGE_OP"
|
|
211
|
+
CLASS_OP = "CLASS_OP"
|
|
208
212
|
OBJECT_OP = "OBJECT_OP"
|
|
209
213
|
TYPE_OP = "TYPE_OP"
|
|
210
214
|
ENUM_OP = "ENUM_OP"
|