jaclang 0.0.5__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/cli.jac +2 -2
- jaclang/cli/cmds.jac +8 -2
- 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/cli_impl.jac +25 -8
- jaclang/cli/impl/cmds_impl.jac +35 -6
- 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 +3 -3
- jaclang/core/impl/exec_ctx_impl.jac +3 -6
- jaclang/core/primitives.jac +4 -3
- jaclang/jac/absyntree.py +555 -180
- jaclang/jac/constant.py +6 -0
- jaclang/jac/importer.py +34 -56
- jaclang/jac/langserve.py +26 -0
- jaclang/jac/lexer.py +35 -3
- jaclang/jac/parser.py +146 -115
- jaclang/jac/passes/blue/__init__.py +8 -3
- jaclang/jac/passes/blue/ast_build_pass.py +454 -305
- jaclang/jac/passes/blue/blue_pygen_pass.py +112 -74
- jaclang/jac/passes/blue/decl_def_match_pass.py +49 -277
- jaclang/jac/passes/blue/import_pass.py +1 -1
- jaclang/jac/passes/blue/pyout_pass.py +74 -0
- jaclang/jac/passes/blue/semantic_check_pass.py +37 -0
- jaclang/jac/passes/blue/sym_tab_build_pass.py +1045 -0
- jaclang/jac/passes/blue/tests/test_ast_build_pass.py +2 -2
- jaclang/jac/passes/blue/tests/test_blue_pygen_pass.py +9 -28
- jaclang/jac/passes/blue/tests/test_decl_def_match_pass.py +13 -22
- jaclang/jac/passes/blue/tests/test_sym_tab_build_pass.py +22 -0
- jaclang/jac/passes/ir_pass.py +8 -6
- 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/passes/purple/impl/purple_pygen_pass_impl.jac +2 -5
- jaclang/jac/symtable.py +154 -0
- 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/tests/fixtures/mod_doc_test.jac +1 -0
- jaclang/jac/tests/test_parser.py +8 -0
- jaclang/jac/transform.py +41 -14
- jaclang/jac/transpiler.py +18 -9
- jaclang/utils/fstring_parser.py +2 -2
- jaclang/utils/helpers.py +41 -0
- jaclang/utils/lang_tools.py +12 -2
- jaclang/utils/test.py +41 -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.5.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/jac/passes/blue/tests/test_type_analyze_pass.py +0 -53
- jaclang/jac/passes/blue/type_analyze_pass.py +0 -728
- jaclang/jac/sym_table.py +0 -127
- jaclang-0.0.5.dist-info/RECORD +0 -73
- /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.5.dist-info → jaclang-0.0.8.dist-info}/WHEEL +0 -0
- {jaclang-0.0.5.dist-info → jaclang-0.0.8.dist-info}/entry_points.txt +0 -0
- {jaclang-0.0.5.dist-info → jaclang-0.0.8.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Connect Decls and Defs in AST."""
|
|
2
|
+
import marshal
|
|
3
|
+
import os
|
|
4
|
+
import traceback
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import jaclang.jac.absyntree as ast
|
|
8
|
+
from jaclang.jac.constant import Constants as Con
|
|
9
|
+
from jaclang.jac.passes import Pass
|
|
10
|
+
from jaclang.utils.helpers import handle_jac_error
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PyOutPass(Pass):
|
|
14
|
+
"""Python and bytecode file printing pass."""
|
|
15
|
+
|
|
16
|
+
def before_pass(self) -> None:
|
|
17
|
+
"""Before pass."""
|
|
18
|
+
return super().before_pass()
|
|
19
|
+
|
|
20
|
+
def enter_module(self, node: ast.Module) -> None:
|
|
21
|
+
"""Sub objects.
|
|
22
|
+
|
|
23
|
+
name: str,
|
|
24
|
+
doc: Token,
|
|
25
|
+
body: Optional['Elements'],
|
|
26
|
+
mod_path: str,
|
|
27
|
+
rel_mod_path: str,
|
|
28
|
+
is_imported: bool,
|
|
29
|
+
sym_tab: Optional[SymbolTable],
|
|
30
|
+
"""
|
|
31
|
+
if not (os.path.exists(node.mod_path) and node.meta.get("py_code")):
|
|
32
|
+
return
|
|
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."""
|
|
46
|
+
with open(out_path, "w") as f:
|
|
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
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Ast build pass for Jaseci Ast."""
|
|
2
|
+
import jaclang.jac.absyntree as ast
|
|
3
|
+
from jaclang.jac.passes import Pass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SemanticCheckPass(Pass):
|
|
7
|
+
"""Jac Ast build pass."""
|
|
8
|
+
|
|
9
|
+
def before_pass(self) -> None:
|
|
10
|
+
"""Before pass."""
|
|
11
|
+
self.has_var_init_conflict_check()
|
|
12
|
+
self.terminate()
|
|
13
|
+
|
|
14
|
+
def has_var_init_conflict_check(self) -> None:
|
|
15
|
+
"""Check if there is a conflict in variable initialization."""
|
|
16
|
+
for i in self.get_all_sub_nodes(self.ir, ast.ArchBlock):
|
|
17
|
+
init_vars = []
|
|
18
|
+
init_node = None
|
|
19
|
+
for j in i.members:
|
|
20
|
+
if isinstance(j, ast.Ability) and j.py_resolve_name() == "__init__":
|
|
21
|
+
init_node = j
|
|
22
|
+
if isinstance(j.signature, ast.FuncSignature) and isinstance(
|
|
23
|
+
j.signature.params, ast.FuncParams
|
|
24
|
+
):
|
|
25
|
+
for k in j.signature.params.params:
|
|
26
|
+
init_vars.append(k.name.value)
|
|
27
|
+
break
|
|
28
|
+
if not init_vars:
|
|
29
|
+
continue
|
|
30
|
+
for j in i.members:
|
|
31
|
+
if isinstance(j, ast.ArchHas):
|
|
32
|
+
for k in j.vars.vars:
|
|
33
|
+
if k.name.value in init_vars:
|
|
34
|
+
self.error(
|
|
35
|
+
f"Has variable {k.name.value} is implicitly initialized through this init",
|
|
36
|
+
init_node,
|
|
37
|
+
)
|