jaclang 0.0.6__py3-none-any.whl → 0.0.8__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 +2 -1
- jaclang/cli/__jac_gen__/__init__.py +0 -0
- jaclang/cli/__jac_gen__/cli.py +175 -0
- jaclang/cli/__jac_gen__/cmds.py +132 -0
- jaclang/cli/cmds.jac +3 -0
- jaclang/cli/impl/__jac_gen__/__init__.py +0 -0
- jaclang/cli/impl/__jac_gen__/cli_impl.py +16 -0
- jaclang/cli/impl/__jac_gen__/cmds_impl.py +26 -0
- jaclang/cli/impl/cmds_impl.jac +17 -3
- jaclang/core/__jac_gen__/__init__.py +0 -0
- jaclang/core/__jac_gen__/primitives.py +567 -0
- jaclang/core/impl/__jac_gen__/__init__.py +0 -0
- jaclang/core/impl/__jac_gen__/arch_impl.py +24 -0
- jaclang/core/impl/__jac_gen__/element_impl.py +26 -0
- jaclang/core/impl/__jac_gen__/exec_ctx_impl.py +12 -0
- jaclang/core/impl/__jac_gen__/memory_impl.py +14 -0
- jaclang/core/impl/element_impl.jac +2 -2
- jaclang/core/primitives.jac +1 -0
- jaclang/jac/absyntree.py +65 -42
- jaclang/jac/constant.py +4 -0
- jaclang/jac/importer.py +18 -60
- jaclang/jac/langserve.py +26 -0
- jaclang/jac/lexer.py +9 -1
- jaclang/jac/parser.py +135 -123
- jaclang/jac/passes/blue/ast_build_pass.py +410 -353
- jaclang/jac/passes/blue/blue_pygen_pass.py +15 -0
- jaclang/jac/passes/blue/decl_def_match_pass.py +33 -21
- jaclang/jac/passes/blue/import_pass.py +1 -1
- jaclang/jac/passes/blue/pyout_pass.py +47 -12
- jaclang/jac/passes/blue/sym_tab_build_pass.py +38 -127
- jaclang/jac/passes/blue/tests/test_ast_build_pass.py +2 -2
- jaclang/jac/passes/blue/tests/test_blue_pygen_pass.py +9 -30
- jaclang/jac/passes/blue/tests/test_decl_def_match_pass.py +13 -13
- jaclang/jac/passes/blue/tests/test_sym_tab_build_pass.py +6 -4
- jaclang/jac/passes/ir_pass.py +1 -1
- jaclang/jac/passes/purple/__jac_gen__/__init__.py +0 -0
- jaclang/jac/passes/purple/__jac_gen__/analyze_pass.py +37 -0
- jaclang/jac/passes/purple/__jac_gen__/purple_pygen_pass.py +305 -0
- jaclang/jac/passes/purple/impl/__jac_gen__/__init__.py +0 -0
- jaclang/jac/passes/purple/impl/__jac_gen__/purple_pygen_pass_impl.py +23 -0
- jaclang/jac/symtable.py +12 -4
- jaclang/jac/tests/fixtures/__jac_gen__/__init__.py +0 -0
- jaclang/jac/tests/fixtures/__jac_gen__/hello_world.py +16 -0
- jaclang/jac/tests/fixtures/fam.jac +7 -8
- jaclang/jac/transform.py +4 -3
- jaclang/jac/transpiler.py +13 -9
- jaclang/utils/fstring_parser.py +2 -2
- jaclang/utils/helpers.py +41 -0
- jaclang/utils/test.py +30 -0
- jaclang/vendor/__init__.py +1 -0
- jaclang/vendor/pygls/__init__.py +25 -0
- jaclang/vendor/pygls/capabilities.py +502 -0
- jaclang/vendor/pygls/client.py +176 -0
- jaclang/vendor/pygls/constants.py +26 -0
- jaclang/vendor/pygls/exceptions.py +220 -0
- jaclang/vendor/pygls/feature_manager.py +241 -0
- jaclang/vendor/pygls/lsp/__init__.py +139 -0
- jaclang/vendor/pygls/lsp/client.py +2224 -0
- jaclang/vendor/pygls/lsprotocol/__init__.py +2 -0
- jaclang/vendor/pygls/lsprotocol/_hooks.py +1233 -0
- jaclang/vendor/pygls/lsprotocol/converters.py +17 -0
- jaclang/vendor/pygls/lsprotocol/types.py +12820 -0
- jaclang/vendor/pygls/lsprotocol/validators.py +47 -0
- jaclang/vendor/pygls/progress.py +79 -0
- jaclang/vendor/pygls/protocol.py +1184 -0
- jaclang/vendor/pygls/server.py +620 -0
- jaclang/vendor/pygls/uris.py +184 -0
- jaclang/vendor/pygls/workspace/__init__.py +81 -0
- jaclang/vendor/pygls/workspace/position.py +204 -0
- jaclang/vendor/pygls/workspace/text_document.py +234 -0
- jaclang/vendor/pygls/workspace/workspace.py +311 -0
- {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/METADATA +1 -1
- jaclang-0.0.8.dist-info/RECORD +118 -0
- jaclang/core/jaclang.jac +0 -62
- jaclang-0.0.6.dist-info/RECORD +0 -76
- /jaclang/{utils → vendor}/sly/__init__.py +0 -0
- /jaclang/{utils → vendor}/sly/docparse.py +0 -0
- /jaclang/{utils → vendor}/sly/lex.py +0 -0
- /jaclang/{utils → vendor}/sly/yacc.py +0 -0
- {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/WHEEL +0 -0
- {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/entry_points.txt +0 -0
- {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/top_level.txt +0 -0
|
@@ -224,6 +224,13 @@ class BluePygenPass(Pass):
|
|
|
224
224
|
else:
|
|
225
225
|
self.emit(node, node.body.meta["py_code"])
|
|
226
226
|
|
|
227
|
+
def exit_py_inline_code(self, node: ast.PyInlineCode) -> None:
|
|
228
|
+
"""Sub objects.
|
|
229
|
+
|
|
230
|
+
code: Token,
|
|
231
|
+
"""
|
|
232
|
+
self.emit_ln(node, node.code.value)
|
|
233
|
+
|
|
227
234
|
def exit_import(self, node: ast.Import) -> None:
|
|
228
235
|
"""Sub objects.
|
|
229
236
|
|
|
@@ -249,6 +256,7 @@ class BluePygenPass(Pass):
|
|
|
249
256
|
self.warning(
|
|
250
257
|
"Includes import * in target module into current namespace."
|
|
251
258
|
)
|
|
259
|
+
return
|
|
252
260
|
if not node.items:
|
|
253
261
|
if not node.alias:
|
|
254
262
|
self.emit_ln(node, f"import {node.path.meta['py_code']}")
|
|
@@ -537,6 +545,13 @@ class BluePygenPass(Pass):
|
|
|
537
545
|
"""
|
|
538
546
|
self.emit(node, ".".join([i.meta["py_code"] for i in node.names]))
|
|
539
547
|
|
|
548
|
+
def exit_arch_ref_chain(self, node: ast.ArchRefChain) -> None:
|
|
549
|
+
"""Sub objects.
|
|
550
|
+
|
|
551
|
+
archs: list[ArchRef],
|
|
552
|
+
"""
|
|
553
|
+
self.emit(node, ".".join([i.meta["py_code"] for i in node.archs]))
|
|
554
|
+
|
|
540
555
|
def exit_func_signature(self, node: ast.FuncSignature) -> None:
|
|
541
556
|
"""Sub objects.
|
|
542
557
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import jaclang.jac.absyntree as ast
|
|
3
3
|
from jaclang.jac.passes import Pass
|
|
4
4
|
from jaclang.jac.passes.blue import SubNodeTabPass
|
|
5
|
-
from jaclang.jac.symtable import SymbolTable, SymbolType
|
|
5
|
+
from jaclang.jac.symtable import SymbolHitType, SymbolTable, SymbolType
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class DeclDefMatchPass(Pass):
|
|
@@ -14,38 +14,50 @@ class DeclDefMatchPass(Pass):
|
|
|
14
14
|
if not self.ir.sym_tab:
|
|
15
15
|
return self.ice("Expected symbol table on node.")
|
|
16
16
|
self.connect_decl_def(self.ir.sym_tab)
|
|
17
|
-
|
|
18
|
-
# self.terminate()
|
|
17
|
+
self.terminate()
|
|
19
18
|
|
|
20
19
|
def after_pass(self) -> None:
|
|
21
20
|
"""Rebuild sub node table."""
|
|
22
|
-
self.ir = SubNodeTabPass(
|
|
21
|
+
self.ir = SubNodeTabPass(
|
|
22
|
+
prior=self, mod_path=self.mod_path, input_ir=self.ir
|
|
23
|
+
).ir
|
|
23
24
|
|
|
24
25
|
def connect_decl_def(self, sym_tab: SymbolTable) -> None:
|
|
25
26
|
"""Connect Decls and Defs."""
|
|
26
|
-
# print(sym_tab)
|
|
27
27
|
for sym in sym_tab.tab.values():
|
|
28
|
-
if sym.sym_type
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
if sym.sym_type == SymbolType.IMPL:
|
|
29
|
+
# currently strips the type info from impls
|
|
30
|
+
arch_refs = [x[3:] for x in sym.name.split(".")]
|
|
31
|
+
lookup = sym_tab.lookup(arch_refs[0], sym_hit=SymbolHitType.DECL_DEFN)
|
|
32
|
+
decl_node = lookup.decl if lookup else None
|
|
33
|
+
for name in arch_refs[1:]:
|
|
34
|
+
if decl_node:
|
|
35
|
+
lookup = (
|
|
36
|
+
decl_node.sym_tab.lookup(
|
|
37
|
+
name, sym_hit=SymbolHitType.DECL_DEFN
|
|
38
|
+
)
|
|
39
|
+
if decl_node.sym_tab
|
|
40
|
+
else None
|
|
34
41
|
)
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
decl_node = lookup.decl if lookup else None
|
|
43
|
+
else:
|
|
44
|
+
break
|
|
45
|
+
if not decl_node:
|
|
37
46
|
self.error(
|
|
38
|
-
f"Unable to match implementation {sym.name} to
|
|
47
|
+
f"Unable to match implementation {sym.name} to a declaration.",
|
|
39
48
|
sym.defn[-1],
|
|
40
49
|
)
|
|
41
|
-
|
|
50
|
+
continue
|
|
51
|
+
elif isinstance(decl_node, ast.Ability) and decl_node.is_abstract:
|
|
42
52
|
self.error(
|
|
43
|
-
f"
|
|
44
|
-
|
|
53
|
+
f"Abstract ability {decl_node.py_resolve_name()} should not have a definition.",
|
|
54
|
+
decl_node,
|
|
45
55
|
)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
continue
|
|
57
|
+
ast.append_node(decl_node, sym.defn[-1].body) # type: ignore
|
|
58
|
+
decl_node.body = sym.defn[-1].body # type: ignore
|
|
59
|
+
decl_node.sym_tab.tab = sym.defn[-1].sym_tab.tab # type: ignore
|
|
60
|
+
sym.decl = decl_node
|
|
61
|
+
|
|
50
62
|
for i in sym_tab.kid:
|
|
51
63
|
self.connect_decl_def(i)
|
|
@@ -26,7 +26,7 @@ class ImportPass(Pass):
|
|
|
26
26
|
ast.append_node(i, self.import_module(i, node.mod_path))
|
|
27
27
|
i.sub_module = i.kid[-1]
|
|
28
28
|
self.enter_import(i)
|
|
29
|
-
SubNodeTabPass(mod_path=node.mod_path, input_ir=node)
|
|
29
|
+
SubNodeTabPass(prior=self, mod_path=node.mod_path, input_ir=node)
|
|
30
30
|
|
|
31
31
|
def enter_import(self, node: ast.Import) -> None:
|
|
32
32
|
"""Sub objects.
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
"""Connect Decls and Defs in AST."""
|
|
2
|
+
import marshal
|
|
2
3
|
import os
|
|
4
|
+
import traceback
|
|
5
|
+
|
|
3
6
|
|
|
4
7
|
import jaclang.jac.absyntree as ast
|
|
8
|
+
from jaclang.jac.constant import Constants as Con
|
|
5
9
|
from jaclang.jac.passes import Pass
|
|
10
|
+
from jaclang.utils.helpers import handle_jac_error
|
|
6
11
|
|
|
7
12
|
|
|
8
13
|
class PyOutPass(Pass):
|
|
9
|
-
"""
|
|
14
|
+
"""Python and bytecode file printing pass."""
|
|
10
15
|
|
|
11
16
|
def before_pass(self) -> None:
|
|
12
17
|
"""Before pass."""
|
|
13
|
-
self.gen_dir = "__jac_gen__"
|
|
14
18
|
return super().before_pass()
|
|
15
19
|
|
|
16
20
|
def enter_module(self, node: ast.Module) -> None:
|
|
@@ -24,16 +28,47 @@ class PyOutPass(Pass):
|
|
|
24
28
|
is_imported: bool,
|
|
25
29
|
sym_tab: Optional[SymbolTable],
|
|
26
30
|
"""
|
|
27
|
-
if (
|
|
28
|
-
not os.path.exists(node.mod_path)
|
|
29
|
-
or "py_code" not in node.meta
|
|
30
|
-
or not node.meta["py_code"]
|
|
31
|
-
):
|
|
31
|
+
if not (os.path.exists(node.mod_path) and node.meta.get("py_code")):
|
|
32
32
|
return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
mods = [node] + self.get_all_sub_nodes(node, ast.Module)
|
|
34
|
+
for mod in mods:
|
|
35
|
+
mod_path, out_path_py, out_path_pyc = self.get_output_targets(mod)
|
|
36
|
+
if os.path.exists(out_path_py) and os.path.getmtime(
|
|
37
|
+
out_path_py
|
|
38
|
+
) > os.path.getmtime(mod_path):
|
|
39
|
+
continue
|
|
40
|
+
self.gen_python(mod, out_path=out_path_py)
|
|
41
|
+
self.compile_bytecode(mod, mod_path=mod_path, out_path=out_path_pyc)
|
|
42
|
+
self.terminate()
|
|
43
|
+
|
|
44
|
+
def gen_python(self, node: ast.Module, out_path: str) -> None:
|
|
45
|
+
"""Generate Python."""
|
|
38
46
|
with open(out_path, "w") as f:
|
|
39
47
|
f.write(node.meta["py_code"])
|
|
48
|
+
|
|
49
|
+
def compile_bytecode(self, node: ast.Module, mod_path: str, out_path: str) -> None:
|
|
50
|
+
"""Generate Python."""
|
|
51
|
+
try:
|
|
52
|
+
codeobj = compile(node.meta["py_code"], f"_jac_py_gen ({mod_path})", "exec")
|
|
53
|
+
except Exception as e:
|
|
54
|
+
tb = traceback.extract_tb(e.__traceback__)
|
|
55
|
+
err = handle_jac_error(node.meta["py_code"], e, tb)
|
|
56
|
+
raise type(e)(str(e) + "\n" + err)
|
|
57
|
+
with open(out_path, "wb") as f:
|
|
58
|
+
marshal.dump(codeobj, f)
|
|
59
|
+
|
|
60
|
+
def get_output_targets(self, node: ast.Module) -> tuple[str, str, str]:
|
|
61
|
+
"""Get output targets."""
|
|
62
|
+
base_path, file_name = os.path.split(node.mod_path)
|
|
63
|
+
gen_path = os.path.join(base_path, Con.JAC_GEN_DIR)
|
|
64
|
+
os.makedirs(gen_path, exist_ok=True)
|
|
65
|
+
with open(os.path.join(gen_path, "__init__.py"), "w"):
|
|
66
|
+
pass
|
|
67
|
+
mod_dir, file_name = os.path.split(node.mod_path)
|
|
68
|
+
mod_dir = mod_dir.replace(base_path, "").lstrip(os.sep)
|
|
69
|
+
base_name, _ = os.path.splitext(file_name)
|
|
70
|
+
out_dir = os.path.join(gen_path, mod_dir)
|
|
71
|
+
os.makedirs(out_dir, exist_ok=True)
|
|
72
|
+
out_path_py = os.path.join(out_dir, f"{base_name}.py")
|
|
73
|
+
out_path_pyc = os.path.join(out_dir, f"{base_name}.pyc")
|
|
74
|
+
return node.mod_path, out_path_py, out_path_pyc
|