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.

Files changed (94) hide show
  1. jaclang/__init__.py +2 -1
  2. jaclang/cli/__jac_gen__/__init__.py +0 -0
  3. jaclang/cli/__jac_gen__/cli.py +175 -0
  4. jaclang/cli/__jac_gen__/cmds.py +132 -0
  5. jaclang/cli/cli.jac +2 -2
  6. jaclang/cli/cmds.jac +8 -2
  7. jaclang/cli/impl/__jac_gen__/__init__.py +0 -0
  8. jaclang/cli/impl/__jac_gen__/cli_impl.py +16 -0
  9. jaclang/cli/impl/__jac_gen__/cmds_impl.py +26 -0
  10. jaclang/cli/impl/cli_impl.jac +25 -8
  11. jaclang/cli/impl/cmds_impl.jac +35 -6
  12. jaclang/core/__jac_gen__/__init__.py +0 -0
  13. jaclang/core/__jac_gen__/primitives.py +567 -0
  14. jaclang/core/impl/__jac_gen__/__init__.py +0 -0
  15. jaclang/core/impl/__jac_gen__/arch_impl.py +24 -0
  16. jaclang/core/impl/__jac_gen__/element_impl.py +26 -0
  17. jaclang/core/impl/__jac_gen__/exec_ctx_impl.py +12 -0
  18. jaclang/core/impl/__jac_gen__/memory_impl.py +14 -0
  19. jaclang/core/impl/element_impl.jac +3 -3
  20. jaclang/core/impl/exec_ctx_impl.jac +3 -6
  21. jaclang/core/primitives.jac +4 -3
  22. jaclang/jac/absyntree.py +555 -180
  23. jaclang/jac/constant.py +6 -0
  24. jaclang/jac/importer.py +34 -56
  25. jaclang/jac/langserve.py +26 -0
  26. jaclang/jac/lexer.py +35 -3
  27. jaclang/jac/parser.py +146 -115
  28. jaclang/jac/passes/blue/__init__.py +8 -3
  29. jaclang/jac/passes/blue/ast_build_pass.py +454 -305
  30. jaclang/jac/passes/blue/blue_pygen_pass.py +112 -74
  31. jaclang/jac/passes/blue/decl_def_match_pass.py +49 -277
  32. jaclang/jac/passes/blue/import_pass.py +1 -1
  33. jaclang/jac/passes/blue/pyout_pass.py +74 -0
  34. jaclang/jac/passes/blue/semantic_check_pass.py +37 -0
  35. jaclang/jac/passes/blue/sym_tab_build_pass.py +1045 -0
  36. jaclang/jac/passes/blue/tests/test_ast_build_pass.py +2 -2
  37. jaclang/jac/passes/blue/tests/test_blue_pygen_pass.py +9 -28
  38. jaclang/jac/passes/blue/tests/test_decl_def_match_pass.py +13 -22
  39. jaclang/jac/passes/blue/tests/test_sym_tab_build_pass.py +22 -0
  40. jaclang/jac/passes/ir_pass.py +8 -6
  41. jaclang/jac/passes/purple/__jac_gen__/__init__.py +0 -0
  42. jaclang/jac/passes/purple/__jac_gen__/analyze_pass.py +37 -0
  43. jaclang/jac/passes/purple/__jac_gen__/purple_pygen_pass.py +305 -0
  44. jaclang/jac/passes/purple/impl/__jac_gen__/__init__.py +0 -0
  45. jaclang/jac/passes/purple/impl/__jac_gen__/purple_pygen_pass_impl.py +23 -0
  46. jaclang/jac/passes/purple/impl/purple_pygen_pass_impl.jac +2 -5
  47. jaclang/jac/symtable.py +154 -0
  48. jaclang/jac/tests/fixtures/__jac_gen__/__init__.py +0 -0
  49. jaclang/jac/tests/fixtures/__jac_gen__/hello_world.py +16 -0
  50. jaclang/jac/tests/fixtures/fam.jac +7 -8
  51. jaclang/jac/tests/fixtures/mod_doc_test.jac +1 -0
  52. jaclang/jac/tests/test_parser.py +8 -0
  53. jaclang/jac/transform.py +41 -14
  54. jaclang/jac/transpiler.py +18 -9
  55. jaclang/utils/fstring_parser.py +2 -2
  56. jaclang/utils/helpers.py +41 -0
  57. jaclang/utils/lang_tools.py +12 -2
  58. jaclang/utils/test.py +41 -0
  59. jaclang/vendor/__init__.py +1 -0
  60. jaclang/vendor/pygls/__init__.py +25 -0
  61. jaclang/vendor/pygls/capabilities.py +502 -0
  62. jaclang/vendor/pygls/client.py +176 -0
  63. jaclang/vendor/pygls/constants.py +26 -0
  64. jaclang/vendor/pygls/exceptions.py +220 -0
  65. jaclang/vendor/pygls/feature_manager.py +241 -0
  66. jaclang/vendor/pygls/lsp/__init__.py +139 -0
  67. jaclang/vendor/pygls/lsp/client.py +2224 -0
  68. jaclang/vendor/pygls/lsprotocol/__init__.py +2 -0
  69. jaclang/vendor/pygls/lsprotocol/_hooks.py +1233 -0
  70. jaclang/vendor/pygls/lsprotocol/converters.py +17 -0
  71. jaclang/vendor/pygls/lsprotocol/types.py +12820 -0
  72. jaclang/vendor/pygls/lsprotocol/validators.py +47 -0
  73. jaclang/vendor/pygls/progress.py +79 -0
  74. jaclang/vendor/pygls/protocol.py +1184 -0
  75. jaclang/vendor/pygls/server.py +620 -0
  76. jaclang/vendor/pygls/uris.py +184 -0
  77. jaclang/vendor/pygls/workspace/__init__.py +81 -0
  78. jaclang/vendor/pygls/workspace/position.py +204 -0
  79. jaclang/vendor/pygls/workspace/text_document.py +234 -0
  80. jaclang/vendor/pygls/workspace/workspace.py +311 -0
  81. {jaclang-0.0.5.dist-info → jaclang-0.0.8.dist-info}/METADATA +1 -1
  82. jaclang-0.0.8.dist-info/RECORD +118 -0
  83. jaclang/core/jaclang.jac +0 -62
  84. jaclang/jac/passes/blue/tests/test_type_analyze_pass.py +0 -53
  85. jaclang/jac/passes/blue/type_analyze_pass.py +0 -728
  86. jaclang/jac/sym_table.py +0 -127
  87. jaclang-0.0.5.dist-info/RECORD +0 -73
  88. /jaclang/{utils → vendor}/sly/__init__.py +0 -0
  89. /jaclang/{utils → vendor}/sly/docparse.py +0 -0
  90. /jaclang/{utils → vendor}/sly/lex.py +0 -0
  91. /jaclang/{utils → vendor}/sly/yacc.py +0 -0
  92. {jaclang-0.0.5.dist-info → jaclang-0.0.8.dist-info}/WHEEL +0 -0
  93. {jaclang-0.0.5.dist-info → jaclang-0.0.8.dist-info}/entry_points.txt +0 -0
  94. {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
+ )