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/__init__.py
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
"""The Jac Programming Language."""
|
|
2
|
+
|
|
2
3
|
import os
|
|
3
4
|
import sys
|
|
4
5
|
|
|
5
6
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "vendor"))
|
|
6
7
|
|
|
7
|
-
from jaclang.
|
|
8
|
+
from jaclang.plugin.default import JacFeatureDefaults # noqa: E402
|
|
8
9
|
from jaclang.plugin.feature import JacFeature # noqa: E402
|
|
9
10
|
from jaclang.vendor import lark # noqa: E402
|
|
10
11
|
from jaclang.vendor import mypy # noqa: E402
|
|
11
12
|
from jaclang.vendor import pluggy # noqa: E402
|
|
12
13
|
|
|
14
|
+
jac_import = JacFeature.jac_import
|
|
15
|
+
|
|
13
16
|
__all__ = [
|
|
14
17
|
"jac_import",
|
|
15
18
|
"lark",
|
|
16
19
|
"mypy",
|
|
17
20
|
"pluggy",
|
|
18
21
|
]
|
|
19
|
-
|
|
22
|
+
JacFeature.pm.register(JacFeatureDefaults)
|
|
20
23
|
JacFeature.pm.load_setuptools_entrypoints("jac")
|
jaclang/cli/cli.py
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"""Command line interface tool for the Jac language."""
|
|
2
|
+
|
|
2
3
|
import os
|
|
4
|
+
import pickle
|
|
3
5
|
import shutil
|
|
4
6
|
from typing import Optional
|
|
5
7
|
|
|
6
|
-
from jaclang import jac_import
|
|
8
|
+
from jaclang import jac_import
|
|
7
9
|
from jaclang.cli.cmdreg import CommandRegistry, CommandShell
|
|
10
|
+
from jaclang.compiler.compile import jac_file_to_pass
|
|
8
11
|
from jaclang.compiler.constant import Constants
|
|
12
|
+
from jaclang.compiler.passes.main.schedules import py_code_gen_typed
|
|
9
13
|
from jaclang.compiler.passes.tool.schedules import format_pass
|
|
10
|
-
from jaclang.compiler.transpiler import jac_file_to_pass
|
|
11
14
|
from jaclang.plugin.feature import JacFeature as Jac
|
|
12
15
|
from jaclang.utils.lang_tools import AstTool
|
|
13
16
|
|
|
14
|
-
|
|
15
17
|
cmd_registry = CommandRegistry()
|
|
16
18
|
|
|
17
19
|
|
|
@@ -45,13 +47,59 @@ def run(filename: str, main: bool = True) -> None:
|
|
|
45
47
|
:param filename: The path to the .jac file.
|
|
46
48
|
:param main: If True, use '__main__' as the module name, else use the actual module name.
|
|
47
49
|
"""
|
|
50
|
+
base, mod = os.path.split(filename)
|
|
51
|
+
base = base if base else "./"
|
|
52
|
+
mod = mod[:-4]
|
|
48
53
|
if filename.endswith(".jac"):
|
|
49
|
-
|
|
50
|
-
base = base if base else "./"
|
|
51
|
-
mod = mod[:-4]
|
|
52
|
-
__jac_import__(
|
|
54
|
+
jac_import(
|
|
53
55
|
target=mod, base_path=base, override_name="__main__" if main else None
|
|
54
56
|
)
|
|
57
|
+
elif filename.endswith(".jir"):
|
|
58
|
+
with open(filename, "rb") as f:
|
|
59
|
+
ir = pickle.load(f)
|
|
60
|
+
jac_import(
|
|
61
|
+
target=mod,
|
|
62
|
+
base_path=base,
|
|
63
|
+
override_name="__main__" if main else None,
|
|
64
|
+
mod_bundle=ir,
|
|
65
|
+
)
|
|
66
|
+
else:
|
|
67
|
+
print("Not a .jac file.")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@cmd_registry.register
|
|
71
|
+
def build(filename: str) -> None:
|
|
72
|
+
"""Build the specified .jac file."""
|
|
73
|
+
if filename.endswith(".jac"):
|
|
74
|
+
out = jac_file_to_pass(file_path=filename, schedule=py_code_gen_typed)
|
|
75
|
+
errs = len(out.errors_had)
|
|
76
|
+
warnings = len(out.warnings_had)
|
|
77
|
+
print(f"Errors: {errs}, Warnings: {warnings}")
|
|
78
|
+
for i in out.ir.flatten():
|
|
79
|
+
i.gen.mypy_ast = []
|
|
80
|
+
i.gen.py = ""
|
|
81
|
+
with open(filename[:-4] + ".jir", "wb") as f:
|
|
82
|
+
pickle.dump(out.ir, f)
|
|
83
|
+
else:
|
|
84
|
+
print("Not a .jac file.")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@cmd_registry.register
|
|
88
|
+
def check(filename: str) -> None:
|
|
89
|
+
"""Run type checker for a specified .jac file.
|
|
90
|
+
|
|
91
|
+
:param filename: The path to the .jac file.
|
|
92
|
+
"""
|
|
93
|
+
if filename.endswith(".jac"):
|
|
94
|
+
out = jac_file_to_pass(
|
|
95
|
+
file_path=filename,
|
|
96
|
+
schedule=py_code_gen_typed,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
errs = len(out.errors_had)
|
|
100
|
+
warnings = len(out.warnings_had)
|
|
101
|
+
|
|
102
|
+
print(f"Errors: {errs}, Warnings: {warnings}")
|
|
55
103
|
else:
|
|
56
104
|
print("Not a .jac file.")
|
|
57
105
|
|
|
@@ -68,7 +116,7 @@ def enter(filename: str, entrypoint: str, args: list) -> None:
|
|
|
68
116
|
base, mod_name = os.path.split(filename)
|
|
69
117
|
base = base if base else "./"
|
|
70
118
|
mod_name = mod_name[:-4]
|
|
71
|
-
mod =
|
|
119
|
+
mod = jac_import(target=mod_name, base_path=base)
|
|
72
120
|
if not mod:
|
|
73
121
|
print("Errors occurred while importing the module.")
|
|
74
122
|
return
|
jaclang/cli/cmdreg.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Common code for command line interface tool for the Jac language."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
import argparse
|
|
@@ -81,18 +82,22 @@ class CommandRegistry:
|
|
|
81
82
|
first = False
|
|
82
83
|
cmd_parser.add_argument(
|
|
83
84
|
f"{param_name}",
|
|
84
|
-
type=
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
type=(
|
|
86
|
+
eval(param.annotation)
|
|
87
|
+
if isinstance(param.annotation, str)
|
|
88
|
+
else param.annotation
|
|
89
|
+
),
|
|
87
90
|
)
|
|
88
91
|
else:
|
|
89
92
|
cmd_parser.add_argument(
|
|
90
93
|
f"-{param_name[:1]}",
|
|
91
94
|
f"--{param_name}",
|
|
92
95
|
required=True,
|
|
93
|
-
type=
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
type=(
|
|
97
|
+
eval(param.annotation)
|
|
98
|
+
if isinstance(param.annotation, str)
|
|
99
|
+
else param.annotation
|
|
100
|
+
),
|
|
96
101
|
)
|
|
97
102
|
elif first:
|
|
98
103
|
first = False
|
|
@@ -104,9 +109,11 @@ class CommandRegistry:
|
|
|
104
109
|
f"-{param_name[:1]}",
|
|
105
110
|
f"--{param_name}",
|
|
106
111
|
default=param.default,
|
|
107
|
-
type=
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
type=(
|
|
113
|
+
eval(param.annotation)
|
|
114
|
+
if isinstance(param.annotation, str)
|
|
115
|
+
else param.annotation
|
|
116
|
+
),
|
|
110
117
|
)
|
|
111
118
|
return func
|
|
112
119
|
|