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/plugin/feature.py
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"""Jac Language Features."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
import types
|
|
6
|
+
from typing import Any, Callable, Optional, Type, TypeAlias
|
|
5
7
|
|
|
6
|
-
from jaclang.
|
|
7
|
-
from jaclang.
|
|
8
|
+
from jaclang.compiler.absyntree import Module
|
|
9
|
+
from jaclang.core.construct import (
|
|
8
10
|
Architype,
|
|
9
11
|
EdgeArchitype,
|
|
10
|
-
EdgeDir,
|
|
11
|
-
JacFeatureSpec,
|
|
12
12
|
NodeArchitype,
|
|
13
13
|
Root,
|
|
14
|
-
T,
|
|
15
14
|
WalkerArchitype,
|
|
16
15
|
)
|
|
17
|
-
|
|
16
|
+
from jaclang.plugin.spec import JacFeatureSpec, T
|
|
18
17
|
|
|
19
18
|
import pluggy
|
|
20
19
|
|
|
@@ -22,22 +21,69 @@ import pluggy
|
|
|
22
21
|
class JacFeature:
|
|
23
22
|
"""Jac Feature."""
|
|
24
23
|
|
|
25
|
-
from jaclang.plugin.spec import DSFunc
|
|
26
|
-
|
|
27
24
|
pm = pluggy.PluginManager("jac")
|
|
28
25
|
pm.add_hookspecs(JacFeatureSpec)
|
|
29
|
-
|
|
26
|
+
import abc
|
|
27
|
+
from jaclang.plugin.spec import DSFunc
|
|
28
|
+
from jaclang.compiler.constant import EdgeDir
|
|
30
29
|
|
|
31
|
-
RootType:
|
|
32
|
-
EdgeDir: Type[EdgeDir] = EdgeDir
|
|
30
|
+
RootType: TypeAlias = Root
|
|
33
31
|
|
|
34
32
|
@staticmethod
|
|
35
33
|
def make_architype(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
cls: type,
|
|
35
|
+
arch_base: Type[Architype],
|
|
36
|
+
on_entry: list[DSFunc],
|
|
37
|
+
on_exit: list[DSFunc],
|
|
38
|
+
) -> Type[Architype]:
|
|
39
|
+
"""Create a obj architype."""
|
|
39
40
|
return JacFeature.pm.hook.make_architype(
|
|
40
|
-
|
|
41
|
+
cls=cls, on_entry=on_entry, on_exit=on_exit, arch_base=arch_base
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def make_obj(
|
|
46
|
+
on_entry: list[DSFunc], on_exit: list[DSFunc]
|
|
47
|
+
) -> Callable[[type], type]:
|
|
48
|
+
"""Create a obj architype."""
|
|
49
|
+
return JacFeature.pm.hook.make_obj(on_entry=on_entry, on_exit=on_exit)
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def make_node(
|
|
53
|
+
on_entry: list[DSFunc], on_exit: list[DSFunc]
|
|
54
|
+
) -> Callable[[type], type]:
|
|
55
|
+
"""Create a node architype."""
|
|
56
|
+
return JacFeature.pm.hook.make_node(on_entry=on_entry, on_exit=on_exit)
|
|
57
|
+
|
|
58
|
+
@staticmethod
|
|
59
|
+
def make_edge(
|
|
60
|
+
on_entry: list[DSFunc], on_exit: list[DSFunc]
|
|
61
|
+
) -> Callable[[type], type]:
|
|
62
|
+
"""Create a edge architype."""
|
|
63
|
+
return JacFeature.pm.hook.make_edge(on_entry=on_entry, on_exit=on_exit)
|
|
64
|
+
|
|
65
|
+
@staticmethod
|
|
66
|
+
def make_walker(
|
|
67
|
+
on_entry: list[DSFunc], on_exit: list[DSFunc]
|
|
68
|
+
) -> Callable[[type], type]:
|
|
69
|
+
"""Create a walker architype."""
|
|
70
|
+
return JacFeature.pm.hook.make_walker(on_entry=on_entry, on_exit=on_exit)
|
|
71
|
+
|
|
72
|
+
@staticmethod
|
|
73
|
+
def jac_import(
|
|
74
|
+
target: str,
|
|
75
|
+
base_path: str,
|
|
76
|
+
cachable: bool = True,
|
|
77
|
+
override_name: Optional[str] = None,
|
|
78
|
+
mod_bundle: Optional[Module] = None,
|
|
79
|
+
) -> Optional[types.ModuleType]:
|
|
80
|
+
"""Core Import Process."""
|
|
81
|
+
return JacFeature.pm.hook.jac_import(
|
|
82
|
+
target=target,
|
|
83
|
+
base_path=base_path,
|
|
84
|
+
cachable=cachable,
|
|
85
|
+
override_name=override_name,
|
|
86
|
+
mod_bundle=mod_bundle,
|
|
41
87
|
)
|
|
42
88
|
|
|
43
89
|
@staticmethod
|
|
@@ -46,7 +92,7 @@ class JacFeature:
|
|
|
46
92
|
return JacFeature.pm.hook.create_test(test_fun=test_fun)
|
|
47
93
|
|
|
48
94
|
@staticmethod
|
|
49
|
-
def run_test(filename: str) ->
|
|
95
|
+
def run_test(filename: str) -> bool:
|
|
50
96
|
"""Run the test suite in the specified .jac file."""
|
|
51
97
|
return JacFeature.pm.hook.run_test(filename=filename)
|
|
52
98
|
|
|
@@ -56,12 +102,12 @@ class JacFeature:
|
|
|
56
102
|
return JacFeature.pm.hook.elvis(op1=op1, op2=op2)
|
|
57
103
|
|
|
58
104
|
@staticmethod
|
|
59
|
-
def has_instance_default(gen_func: Callable
|
|
105
|
+
def has_instance_default(gen_func: Callable[[], T]) -> T:
|
|
60
106
|
"""Jac's has container default feature."""
|
|
61
107
|
return JacFeature.pm.hook.has_instance_default(gen_func=gen_func)
|
|
62
108
|
|
|
63
109
|
@staticmethod
|
|
64
|
-
def spawn_call(op1: Architype, op2: Architype) ->
|
|
110
|
+
def spawn_call(op1: Architype, op2: Architype) -> bool:
|
|
65
111
|
"""Jac's spawn operator feature."""
|
|
66
112
|
return JacFeature.pm.hook.spawn_call(op1=op1, op2=op2)
|
|
67
113
|
|
jaclang/plugin/spec.py
CHANGED
|
@@ -1,50 +1,25 @@
|
|
|
1
1
|
"""Jac Language Features."""
|
|
2
|
-
from __future__ import annotations
|
|
3
2
|
|
|
3
|
+
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import types
|
|
5
6
|
from typing import Any, Callable, Optional, Type, TypeVar
|
|
6
7
|
|
|
7
|
-
from jaclang.
|
|
8
|
+
from jaclang.compiler.absyntree import Module
|
|
9
|
+
from jaclang.plugin.default import (
|
|
8
10
|
Architype,
|
|
9
11
|
DSFunc,
|
|
10
|
-
EdgeAnchor,
|
|
11
12
|
EdgeArchitype,
|
|
12
13
|
EdgeDir,
|
|
13
|
-
GenericEdge,
|
|
14
|
-
JacTestCheck,
|
|
15
|
-
NodeAnchor,
|
|
16
14
|
NodeArchitype,
|
|
17
|
-
ObjectAnchor,
|
|
18
|
-
Root,
|
|
19
|
-
WalkerAnchor,
|
|
20
15
|
WalkerArchitype,
|
|
21
|
-
root,
|
|
22
16
|
)
|
|
23
17
|
|
|
24
|
-
__all__ = [
|
|
25
|
-
"EdgeAnchor",
|
|
26
|
-
"GenericEdge",
|
|
27
|
-
"JacTestCheck",
|
|
28
|
-
"NodeAnchor",
|
|
29
|
-
"ObjectAnchor",
|
|
30
|
-
"WalkerAnchor",
|
|
31
|
-
"NodeArchitype",
|
|
32
|
-
"EdgeArchitype",
|
|
33
|
-
"WalkerArchitype",
|
|
34
|
-
"Architype",
|
|
35
|
-
"DSFunc",
|
|
36
|
-
"EdgeDir",
|
|
37
|
-
"root",
|
|
38
|
-
"Root",
|
|
39
|
-
]
|
|
40
|
-
|
|
41
18
|
import pluggy
|
|
42
19
|
|
|
43
20
|
hookspec = pluggy.HookspecMarker("jac")
|
|
44
21
|
|
|
45
|
-
|
|
46
22
|
T = TypeVar("T")
|
|
47
|
-
ArchBound = TypeVar("ArchBound", bound=Architype)
|
|
48
23
|
|
|
49
24
|
|
|
50
25
|
class JacFeatureSpec:
|
|
@@ -53,9 +28,56 @@ class JacFeatureSpec:
|
|
|
53
28
|
@staticmethod
|
|
54
29
|
@hookspec(firstresult=True)
|
|
55
30
|
def make_architype(
|
|
56
|
-
|
|
31
|
+
cls: type,
|
|
32
|
+
arch_base: Type[Architype],
|
|
33
|
+
on_entry: list[DSFunc],
|
|
34
|
+
on_exit: list[DSFunc],
|
|
35
|
+
) -> Type[Architype]:
|
|
36
|
+
"""Create a obj architype."""
|
|
37
|
+
raise NotImplementedError
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
@hookspec(firstresult=True)
|
|
41
|
+
def make_obj(
|
|
42
|
+
on_entry: list[DSFunc], on_exit: list[DSFunc]
|
|
57
43
|
) -> Callable[[type], type]:
|
|
58
|
-
"""Create a
|
|
44
|
+
"""Create a obj architype."""
|
|
45
|
+
raise NotImplementedError
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
@hookspec(firstresult=True)
|
|
49
|
+
def make_node(
|
|
50
|
+
on_entry: list[DSFunc], on_exit: list[DSFunc]
|
|
51
|
+
) -> Callable[[type], type]:
|
|
52
|
+
"""Create a node architype."""
|
|
53
|
+
raise NotImplementedError
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
@hookspec(firstresult=True)
|
|
57
|
+
def make_edge(
|
|
58
|
+
on_entry: list[DSFunc], on_exit: list[DSFunc]
|
|
59
|
+
) -> Callable[[type], type]:
|
|
60
|
+
"""Create a edge architype."""
|
|
61
|
+
raise NotImplementedError
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
@hookspec(firstresult=True)
|
|
65
|
+
def make_walker(
|
|
66
|
+
on_entry: list[DSFunc], on_exit: list[DSFunc]
|
|
67
|
+
) -> Callable[[type], type]:
|
|
68
|
+
"""Create a walker architype."""
|
|
69
|
+
raise NotImplementedError
|
|
70
|
+
|
|
71
|
+
@staticmethod
|
|
72
|
+
@hookspec(firstresult=True)
|
|
73
|
+
def jac_import(
|
|
74
|
+
target: str,
|
|
75
|
+
base_path: str,
|
|
76
|
+
cachable: bool,
|
|
77
|
+
override_name: Optional[str],
|
|
78
|
+
mod_bundle: Optional[Module],
|
|
79
|
+
) -> Optional[types.ModuleType]:
|
|
80
|
+
"""Core Import Process."""
|
|
59
81
|
raise NotImplementedError
|
|
60
82
|
|
|
61
83
|
@staticmethod
|
|
@@ -66,7 +88,7 @@ class JacFeatureSpec:
|
|
|
66
88
|
|
|
67
89
|
@staticmethod
|
|
68
90
|
@hookspec(firstresult=True)
|
|
69
|
-
def run_test(filename: str) ->
|
|
91
|
+
def run_test(filename: str) -> bool:
|
|
70
92
|
"""Run the test suite in the specified .jac file.
|
|
71
93
|
|
|
72
94
|
:param filename: The path to the .jac file.
|
|
@@ -81,13 +103,13 @@ class JacFeatureSpec:
|
|
|
81
103
|
|
|
82
104
|
@staticmethod
|
|
83
105
|
@hookspec(firstresult=True)
|
|
84
|
-
def has_instance_default(gen_func: Callable
|
|
106
|
+
def has_instance_default(gen_func: Callable[[], T]) -> T:
|
|
85
107
|
"""Jac's has container default feature."""
|
|
86
108
|
raise NotImplementedError
|
|
87
109
|
|
|
88
110
|
@staticmethod
|
|
89
111
|
@hookspec(firstresult=True)
|
|
90
|
-
def spawn_call(op1: Architype, op2: Architype) ->
|
|
112
|
+
def spawn_call(op1: Architype, op2: Architype) -> bool:
|
|
91
113
|
"""Jac's spawn operator feature."""
|
|
92
114
|
raise NotImplementedError
|
|
93
115
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Tests for Jac parser."""
|
|
2
|
+
|
|
2
3
|
import inspect
|
|
3
4
|
import io
|
|
4
5
|
import sys
|
|
@@ -31,6 +32,14 @@ class TestFeatures(TestCase):
|
|
|
31
32
|
|
|
32
33
|
# Get the signature using inspect
|
|
33
34
|
signature = inspect.signature(value)
|
|
35
|
+
new_parameters = []
|
|
36
|
+
for (
|
|
37
|
+
_,
|
|
38
|
+
param,
|
|
39
|
+
) in signature.parameters.items(): # to strip defaults
|
|
40
|
+
new_param = param.replace(default=inspect.Parameter.empty)
|
|
41
|
+
new_parameters.append(new_param)
|
|
42
|
+
signature = signature.replace(parameters=new_parameters)
|
|
34
43
|
methods.append(f"{name}{signature}")
|
|
35
44
|
except ValueError:
|
|
36
45
|
# This can happen if the method is not a Python function (e.g., built-in function)
|
jaclang/utils/helpers.py
CHANGED
jaclang/utils/lang_tools.py
CHANGED
|
@@ -7,6 +7,7 @@ import sys
|
|
|
7
7
|
from typing import List, Optional, Type
|
|
8
8
|
|
|
9
9
|
import jaclang.compiler.absyntree as ast
|
|
10
|
+
from jaclang.compiler.compile import jac_file_to_pass
|
|
10
11
|
from jaclang.compiler.passes.main.schedules import DeclDefMatchPass
|
|
11
12
|
from jaclang.compiler.passes.tool.schedules import (
|
|
12
13
|
SymbolTableDotGraphPass,
|
|
@@ -14,7 +15,6 @@ from jaclang.compiler.passes.tool.schedules import (
|
|
|
14
15
|
sym_tab_dot_gen,
|
|
15
16
|
sym_tab_print,
|
|
16
17
|
)
|
|
17
|
-
from jaclang.compiler.transpiler import jac_file_to_pass
|
|
18
18
|
from jaclang.utils.helpers import extract_headings, heading_to_snake, pascal_to_snake
|
|
19
19
|
from jaclang.utils.treeprinter import print_ast_tree
|
|
20
20
|
|
|
@@ -252,13 +252,13 @@ class AstTool:
|
|
|
252
252
|
with open(file_name, "r") as file:
|
|
253
253
|
code = file.read()
|
|
254
254
|
parsed_ast = py_ast.parse(code)
|
|
255
|
-
return print_ast_tree(parsed_ast)
|
|
255
|
+
return f"{print_ast_tree(parsed_ast)}\n---\n{py_ast.dump(parsed_ast, indent=2)}"
|
|
256
256
|
elif file_name.endswith(".jac"):
|
|
257
257
|
[base, mod] = os.path.split(file_name)
|
|
258
258
|
base = base if base else "./"
|
|
259
|
-
pyast = jac_file_to_pass(file_name).ir.gen.py_ast
|
|
259
|
+
pyast = jac_file_to_pass(file_name).ir.gen.py_ast[0]
|
|
260
260
|
return (
|
|
261
|
-
print_ast_tree(pyast)
|
|
261
|
+
f"{print_ast_tree(pyast)}\n---\n{py_ast.dump(pyast, indent=2)}"
|
|
262
262
|
if isinstance(pyast, py_ast.AST)
|
|
263
263
|
else "Compile failed."
|
|
264
264
|
)
|
|
@@ -310,7 +310,6 @@ class AstTool:
|
|
|
310
310
|
|
|
311
311
|
def automate_ref(self) -> str:
|
|
312
312
|
"""Automate the reference guide generation."""
|
|
313
|
-
# Jac lark path
|
|
314
313
|
file_path = os.path.join(
|
|
315
314
|
os.path.split(os.path.dirname(__file__))[0], "../jaclang/compiler/jac.lark"
|
|
316
315
|
)
|
|
@@ -323,31 +322,26 @@ class AstTool:
|
|
|
323
322
|
os.path.split(os.path.dirname(__file__))[0], "../examples/reference/"
|
|
324
323
|
)
|
|
325
324
|
with open(created_file_path, "w") as md_file:
|
|
326
|
-
# Write the content to the destination file
|
|
327
325
|
md_file.write("# Jac Language Reference\n\n## Introduction\n\n")
|
|
328
326
|
for heading, lines in result.items():
|
|
329
327
|
heading = heading.strip()
|
|
330
328
|
heading_snakecase = heading_to_snake(heading)
|
|
331
329
|
content = (
|
|
332
330
|
f'## {heading}\n```yaml linenums="{lines[0]}"\n--8<-- '
|
|
333
|
-
f'"jaclang/compiler/jac.lark:{lines[0]}:{lines[1]}"\n```\n
|
|
331
|
+
f'"jaclang/compiler/jac.lark:{lines[0]}:{lines[1]}"\n```\n'
|
|
332
|
+
f'=== "Jac"\n ```jac linenums="1"\n --8<-- "examples/reference/'
|
|
333
|
+
f'{heading_snakecase}.jac"\n'
|
|
334
|
+
f' ```\n=== "Python"\n ```python linenums="1"\n --8<-- "examples/reference/'
|
|
335
|
+
f'{heading_snakecase}.py"\n ```\n'
|
|
336
|
+
"--8<-- "
|
|
334
337
|
f'"examples/reference/'
|
|
335
338
|
f'{heading_snakecase}.md"\n'
|
|
336
339
|
)
|
|
337
340
|
with open(created_file_path, "a") as md_file:
|
|
338
|
-
# Write the content to the destination file
|
|
339
341
|
md_file.write(f"{content}\n")
|
|
340
|
-
# Generate a Markdown file name based on the heading
|
|
341
342
|
md_file_name = f"{heading_snakecase}.md"
|
|
342
|
-
# Full path for the new Markdown file
|
|
343
343
|
md_file_path = os.path.join(destination_folder, md_file_name)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
f' ```\n=== "Python"\n ```python linenums="1"\n --8<-- "examples/reference/'
|
|
348
|
-
f'{heading_snakecase}.py"\n ```\n'
|
|
349
|
-
)
|
|
350
|
-
with open(md_file_path, "w") as md_file:
|
|
351
|
-
# Write the content to the destination file
|
|
352
|
-
md_file.write(content)
|
|
344
|
+
if not os.path.exists(md_file_path):
|
|
345
|
+
with open(md_file_path, "w") as md_file:
|
|
346
|
+
md_file.write("")
|
|
353
347
|
return "References generated."
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Test ast build pass module."""
|
|
2
|
+
|
|
2
3
|
import os
|
|
3
4
|
|
|
4
5
|
import jaclang
|
|
@@ -68,7 +69,7 @@ class JacFormatPassTests(TestCase):
|
|
|
68
69
|
self.assertIn("+-- ", out, msg)
|
|
69
70
|
self.assertIsNotNone(out, msg=msg)
|
|
70
71
|
elif file.endswith(".py"):
|
|
71
|
-
if len(out.splitlines())
|
|
72
|
+
if len(out.splitlines()) <= 4:
|
|
72
73
|
continue
|
|
73
74
|
self.assertIn("+-- ", out, msg)
|
|
74
75
|
self.assertIsNotNone(out, msg=msg)
|
jaclang/utils/treeprinter.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Tree Printing Helpers for Jac."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
import ast as ast3
|
|
@@ -122,7 +123,7 @@ def print_ast_tree(
|
|
|
122
123
|
def get_location_info(node: ast3.AST) -> str:
|
|
123
124
|
if hasattr(node, "lineno"):
|
|
124
125
|
start_pos = f"{node.lineno}:{node.col_offset + 1}"
|
|
125
|
-
end_pos = f"{node.end_lineno}:{node.end_col_offset + 1}"
|
|
126
|
+
end_pos = f"{node.end_lineno}:{node.end_col_offset + 1 if node.end_col_offset else node.col_offset}"
|
|
126
127
|
prefix = f"{start_pos} - {end_pos}"
|
|
127
128
|
return prefix
|
|
128
129
|
return "-:- - -:-"
|
jaclang/vendor/lark/common.py
CHANGED
|
@@ -24,7 +24,9 @@ from .lexer import TerminalDef, Token
|
|
|
24
24
|
###{standalone
|
|
25
25
|
|
|
26
26
|
_ParserArgType: "TypeAlias" = 'Literal["earley", "lalr", "cyk", "auto"]'
|
|
27
|
-
_LexerArgType: "TypeAlias" =
|
|
27
|
+
_LexerArgType: "TypeAlias" = (
|
|
28
|
+
'Union[Literal["auto", "basic", "contextual", "dynamic", "dynamic_complete"], Type[Lexer]]'
|
|
29
|
+
)
|
|
28
30
|
_LexerCallback = Callable[[Token], Token]
|
|
29
31
|
ParserCallbacks = Dict[str, Callable]
|
|
30
32
|
|
jaclang/vendor/lark/lexer.py
CHANGED
|
@@ -215,8 +215,7 @@ class Token(str):
|
|
|
215
215
|
end_line: Optional[int] = None,
|
|
216
216
|
end_column: Optional[int] = None,
|
|
217
217
|
end_pos: Optional[int] = None,
|
|
218
|
-
) -> "Token":
|
|
219
|
-
...
|
|
218
|
+
) -> "Token": ...
|
|
220
219
|
|
|
221
220
|
@overload
|
|
222
221
|
def __new__(
|
|
@@ -229,8 +228,7 @@ class Token(str):
|
|
|
229
228
|
end_line: Optional[int] = None,
|
|
230
229
|
end_column: Optional[int] = None,
|
|
231
230
|
end_pos: Optional[int] = None,
|
|
232
|
-
) -> "Token":
|
|
233
|
-
...
|
|
231
|
+
) -> "Token": ...
|
|
234
232
|
|
|
235
233
|
def __new__(cls, *args, **kwargs):
|
|
236
234
|
if "type_" in kwargs:
|
|
@@ -273,14 +271,12 @@ class Token(str):
|
|
|
273
271
|
@overload
|
|
274
272
|
def update(
|
|
275
273
|
self, type: Optional[str] = None, value: Optional[Any] = None
|
|
276
|
-
) -> "Token":
|
|
277
|
-
...
|
|
274
|
+
) -> "Token": ...
|
|
278
275
|
|
|
279
276
|
@overload
|
|
280
277
|
def update(
|
|
281
278
|
self, type_: Optional[str] = None, value: Optional[Any] = None
|
|
282
|
-
) -> "Token":
|
|
283
|
-
...
|
|
279
|
+
) -> "Token": ...
|
|
284
280
|
|
|
285
281
|
def update(self, *args, **kwargs):
|
|
286
282
|
if "type_" in kwargs:
|
|
@@ -607,12 +603,10 @@ class AbstractBasicLexer(Lexer):
|
|
|
607
603
|
terminals_by_name: Dict[str, TerminalDef]
|
|
608
604
|
|
|
609
605
|
@abstractmethod
|
|
610
|
-
def __init__(self, conf: "LexerConf", comparator=None) -> None:
|
|
611
|
-
...
|
|
606
|
+
def __init__(self, conf: "LexerConf", comparator=None) -> None: ...
|
|
612
607
|
|
|
613
608
|
@abstractmethod
|
|
614
|
-
def next_token(self, lex_state: LexerState, parser_state: Any = None) -> Token:
|
|
615
|
-
...
|
|
609
|
+
def next_token(self, lex_state: LexerState, parser_state: Any = None) -> Token: ...
|
|
616
610
|
|
|
617
611
|
def lex(self, state: LexerState, parser_state: Any) -> Iterator[Token]:
|
|
618
612
|
with suppress(EOFError):
|
jaclang/vendor/mypy/applytype.py
CHANGED
|
@@ -100,7 +100,8 @@ def apply_generic_arguments(
|
|
|
100
100
|
bound or constraints, instead of giving an error.
|
|
101
101
|
"""
|
|
102
102
|
tvars = callable.variables
|
|
103
|
-
|
|
103
|
+
min_arg_count = sum(not tv.has_default() for tv in tvars)
|
|
104
|
+
assert min_arg_count <= len(orig_types) <= len(tvars)
|
|
104
105
|
# Check that inferred type variable values are compatible with allowed
|
|
105
106
|
# values and bounds. Also, promote subtype values to allowed values.
|
|
106
107
|
# Create a map from type variable id to target type.
|
jaclang/vendor/mypy/binder.py
CHANGED
|
@@ -311,7 +311,7 @@ class ConditionalTypeBinder:
|
|
|
311
311
|
self.type_assignments[expr].append((type, declared_type))
|
|
312
312
|
return
|
|
313
313
|
if not isinstance(expr, (IndexExpr, MemberExpr, NameExpr)):
|
|
314
|
-
return
|
|
314
|
+
return
|
|
315
315
|
if not literal(expr):
|
|
316
316
|
return
|
|
317
317
|
self.invalidate_dependencies(expr)
|
jaclang/vendor/mypy/build.py
CHANGED
|
@@ -8,6 +8,7 @@ file. The individual passes are implemented in separate modules.
|
|
|
8
8
|
|
|
9
9
|
The function build() is the main interface to this module.
|
|
10
10
|
"""
|
|
11
|
+
|
|
11
12
|
# TODO: More consistent terminology, e.g. path/fnam, module/id, state/file
|
|
12
13
|
|
|
13
14
|
from __future__ import annotations
|
|
@@ -713,10 +714,7 @@ class BuildManager:
|
|
|
713
714
|
# for efficient lookup
|
|
714
715
|
self.shadow_map: dict[str, str] = {}
|
|
715
716
|
if self.options.shadow_file is not None:
|
|
716
|
-
self.shadow_map =
|
|
717
|
-
source_file: shadow_file
|
|
718
|
-
for (source_file, shadow_file) in self.options.shadow_file
|
|
719
|
-
}
|
|
717
|
+
self.shadow_map = dict(self.options.shadow_file)
|
|
720
718
|
# a mapping from each file being typechecked to its possible shadow file
|
|
721
719
|
self.shadow_equivalence_map: dict[str, str | None] = {}
|
|
722
720
|
self.plugin = plugin
|
|
@@ -1175,7 +1173,7 @@ def read_deps_cache(manager: BuildManager, graph: Graph) -> dict[str, FgDepMeta]
|
|
|
1175
1173
|
module_deps_metas = deps_meta["deps_meta"]
|
|
1176
1174
|
assert isinstance(module_deps_metas, dict)
|
|
1177
1175
|
if not manager.options.skip_cache_mtime_checks:
|
|
1178
|
-
for
|
|
1176
|
+
for meta in module_deps_metas.values():
|
|
1179
1177
|
try:
|
|
1180
1178
|
matched = manager.getmtime(meta["path"]) == meta["mtime"]
|
|
1181
1179
|
except FileNotFoundError:
|
|
@@ -2189,7 +2187,7 @@ class State:
|
|
|
2189
2187
|
self.meta.data_json, self.manager, "Load tree ", "Could not load tree: "
|
|
2190
2188
|
)
|
|
2191
2189
|
if data is None:
|
|
2192
|
-
return
|
|
2190
|
+
return
|
|
2193
2191
|
|
|
2194
2192
|
t0 = time.time()
|
|
2195
2193
|
# TODO: Assert data file wasn't changed.
|
|
@@ -2278,8 +2276,8 @@ class State:
|
|
|
2278
2276
|
self.id,
|
|
2279
2277
|
self.xpath,
|
|
2280
2278
|
source,
|
|
2281
|
-
self.ignore_all or self.options.ignore_errors,
|
|
2282
|
-
self.options,
|
|
2279
|
+
ignore_errors=self.ignore_all or self.options.ignore_errors,
|
|
2280
|
+
options=self.options,
|
|
2283
2281
|
)
|
|
2284
2282
|
|
|
2285
2283
|
else:
|
|
@@ -3556,7 +3554,7 @@ def order_ascc(
|
|
|
3556
3554
|
strongly_connected_components() below for a reference.
|
|
3557
3555
|
"""
|
|
3558
3556
|
if len(ascc) == 1:
|
|
3559
|
-
return
|
|
3557
|
+
return list(ascc)
|
|
3560
3558
|
pri_spread = set()
|
|
3561
3559
|
for id in ascc:
|
|
3562
3560
|
state = graph[id]
|