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.

Files changed (152) hide show
  1. jaclang/__init__.py +5 -2
  2. jaclang/cli/cli.py +56 -8
  3. jaclang/cli/cmdreg.py +16 -9
  4. jaclang/compiler/__jac_gen__/jac_parser.py +11 -15
  5. jaclang/compiler/absyntree.py +53 -19
  6. jaclang/compiler/codeloc.py +3 -1
  7. jaclang/compiler/{transpiler.py → compile.py} +3 -2
  8. jaclang/compiler/constant.py +4 -0
  9. jaclang/compiler/parser.py +156 -108
  10. jaclang/compiler/passes/ir_pass.py +1 -0
  11. jaclang/compiler/passes/main/__init__.py +2 -1
  12. jaclang/compiler/passes/main/def_impl_match_pass.py +1 -0
  13. jaclang/compiler/passes/main/def_use_pass.py +1 -0
  14. jaclang/compiler/passes/main/import_pass.py +18 -18
  15. jaclang/compiler/passes/main/pyast_gen_pass.py +1228 -853
  16. jaclang/compiler/passes/main/pyast_load_pass.py +3 -1
  17. jaclang/compiler/passes/main/pybc_gen_pass.py +46 -0
  18. jaclang/compiler/passes/main/pyout_pass.py +6 -7
  19. jaclang/compiler/passes/main/schedules.py +5 -9
  20. jaclang/compiler/passes/main/sub_node_tab_pass.py +1 -0
  21. jaclang/compiler/passes/main/sym_tab_build_pass.py +21 -9
  22. jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +2 -1
  23. jaclang/compiler/passes/main/tests/test_def_use_pass.py +2 -1
  24. jaclang/compiler/passes/main/tests/test_import_pass.py +2 -1
  25. jaclang/compiler/passes/main/tests/test_pyast_build_pass.py +1 -0
  26. jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +15 -38
  27. jaclang/compiler/passes/main/tests/test_pybc_gen_pass.py +25 -0
  28. jaclang/compiler/passes/main/tests/test_sub_node_pass.py +1 -1
  29. jaclang/compiler/passes/main/tests/test_sym_tab_build_pass.py +2 -1
  30. jaclang/compiler/passes/main/tests/test_type_check_pass.py +17 -1
  31. jaclang/compiler/passes/main/type_check_pass.py +9 -6
  32. jaclang/compiler/passes/tool/__init__.py +1 -0
  33. jaclang/compiler/passes/tool/ast_printer_pass.py +1 -0
  34. jaclang/compiler/passes/tool/fuse_comments_pass.py +1 -1
  35. jaclang/compiler/passes/tool/jac_formatter_pass.py +69 -32
  36. jaclang/compiler/passes/tool/schedules.py +1 -0
  37. jaclang/compiler/passes/tool/sym_tab_printer_pass.py +1 -0
  38. jaclang/compiler/passes/tool/tests/test_ast_print_pass.py +2 -1
  39. jaclang/compiler/passes/tool/tests/test_fuse_comments_pass.py +1 -0
  40. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +4 -3
  41. jaclang/compiler/passes/tool/tests/test_symtab_print_pass.py +2 -1
  42. jaclang/compiler/passes/transform.py +1 -0
  43. jaclang/compiler/passes/utils/mypy_ast_build.py +203 -17
  44. jaclang/compiler/symtable.py +1 -0
  45. jaclang/compiler/tests/test_importer.py +3 -2
  46. jaclang/compiler/tests/test_parser.py +1 -0
  47. jaclang/compiler/tests/test_workspace.py +1 -0
  48. jaclang/compiler/workspace.py +18 -5
  49. jaclang/core/construct.py +9 -32
  50. jaclang/{compiler → core}/importer.py +95 -85
  51. jaclang/core/utils.py +17 -12
  52. jaclang/plugin/__init__.py +1 -0
  53. jaclang/plugin/default.py +145 -43
  54. jaclang/plugin/feature.py +65 -19
  55. jaclang/plugin/spec.py +56 -34
  56. jaclang/plugin/tests/test_features.py +9 -0
  57. jaclang/utils/helpers.py +1 -0
  58. jaclang/utils/lang_tools.py +13 -19
  59. jaclang/utils/tests/test_lang_tools.py +2 -1
  60. jaclang/utils/treeprinter.py +2 -1
  61. jaclang/vendor/lark/common.py +3 -1
  62. jaclang/vendor/lark/lexer.py +6 -12
  63. jaclang/vendor/lark/parsers/lalr_parser.py +1 -0
  64. jaclang/vendor/mypy/applytype.py +2 -1
  65. jaclang/vendor/mypy/binder.py +1 -1
  66. jaclang/vendor/mypy/build.py +7 -9
  67. jaclang/vendor/mypy/checker.py +57 -33
  68. jaclang/vendor/mypy/checkexpr.py +42 -29
  69. jaclang/vendor/mypy/checkmember.py +13 -1
  70. jaclang/vendor/mypy/checkpattern.py +1 -1
  71. jaclang/vendor/mypy/checkstrformat.py +2 -4
  72. jaclang/vendor/mypy/constraints.py +10 -5
  73. jaclang/vendor/mypy/dmypy_server.py +3 -3
  74. jaclang/vendor/mypy/dmypy_util.py +62 -3
  75. jaclang/vendor/mypy/errors.py +1 -1
  76. jaclang/vendor/mypy/evalexpr.py +1 -0
  77. jaclang/vendor/mypy/expandtype.py +29 -29
  78. jaclang/vendor/mypy/fastparse.py +51 -31
  79. jaclang/vendor/mypy/inspections.py +5 -3
  80. jaclang/vendor/mypy/join.py +4 -4
  81. jaclang/vendor/mypy/main.py +6 -6
  82. jaclang/vendor/mypy/message_registry.py +1 -2
  83. jaclang/vendor/mypy/messages.py +31 -23
  84. jaclang/vendor/mypy/metastore.py +1 -2
  85. jaclang/vendor/mypy/modulefinder.py +2 -22
  86. jaclang/vendor/mypy/nodes.py +22 -20
  87. jaclang/vendor/mypy/options.py +4 -0
  88. jaclang/vendor/mypy/parse.py +6 -2
  89. jaclang/vendor/mypy/patterns.py +6 -6
  90. jaclang/vendor/mypy/plugin.py +3 -1
  91. jaclang/vendor/mypy/plugins/attrs.py +52 -10
  92. jaclang/vendor/mypy/plugins/common.py +2 -1
  93. jaclang/vendor/mypy/plugins/enums.py +3 -2
  94. jaclang/vendor/mypy/plugins/functools.py +1 -0
  95. jaclang/vendor/mypy/renaming.py +1 -1
  96. jaclang/vendor/mypy/report.py +15 -15
  97. jaclang/vendor/mypy/semanal.py +22 -13
  98. jaclang/vendor/mypy/semanal_enum.py +1 -1
  99. jaclang/vendor/mypy/semanal_namedtuple.py +1 -2
  100. jaclang/vendor/mypy/semanal_shared.py +3 -6
  101. jaclang/vendor/mypy/semanal_typeddict.py +16 -5
  102. jaclang/vendor/mypy/server/astdiff.py +15 -9
  103. jaclang/vendor/mypy/server/astmerge.py +5 -5
  104. jaclang/vendor/mypy/stats.py +0 -5
  105. jaclang/vendor/mypy/stubdoc.py +1 -1
  106. jaclang/vendor/mypy/stubgen.py +12 -21
  107. jaclang/vendor/mypy/stubgenc.py +16 -8
  108. jaclang/vendor/mypy/stubtest.py +57 -48
  109. jaclang/vendor/mypy/stubutil.py +28 -15
  110. jaclang/vendor/mypy/subtypes.py +4 -4
  111. jaclang/vendor/mypy/test/helpers.py +2 -2
  112. jaclang/vendor/mypy/test/meta/test_parse_data.py +1 -0
  113. jaclang/vendor/mypy/test/meta/test_update_data.py +1 -0
  114. jaclang/vendor/mypy/test/testargs.py +1 -0
  115. jaclang/vendor/mypy/test/testcheck.py +4 -1
  116. jaclang/vendor/mypy/test/testconstraints.py +25 -7
  117. jaclang/vendor/mypy/test/testerrorstream.py +1 -0
  118. jaclang/vendor/mypy/test/testformatter.py +2 -2
  119. jaclang/vendor/mypy/test/testparse.py +6 -4
  120. jaclang/vendor/mypy/test/testpythoneval.py +1 -0
  121. jaclang/vendor/mypy/test/testreports.py +1 -0
  122. jaclang/vendor/mypy/test/teststubgen.py +1 -2
  123. jaclang/vendor/mypy/test/teststubtest.py +98 -4
  124. jaclang/vendor/mypy/test/testtypes.py +1 -1
  125. jaclang/vendor/mypy/test/testutil.py +22 -0
  126. jaclang/vendor/mypy/typeanal.py +302 -158
  127. jaclang/vendor/mypy/typeops.py +22 -13
  128. jaclang/vendor/mypy/types.py +33 -34
  129. jaclang/vendor/mypy/typestate.py +2 -2
  130. jaclang/vendor/mypy/util.py +7 -6
  131. jaclang/vendor/mypy/version.py +1 -1
  132. jaclang/vendor/mypyc/analysis/ircheck.py +1 -0
  133. jaclang/vendor/mypyc/codegen/emitfunc.py +5 -3
  134. jaclang/vendor/mypyc/codegen/emitmodule.py +12 -12
  135. jaclang/vendor/mypyc/codegen/emitwrapper.py +2 -2
  136. jaclang/vendor/mypyc/ir/class_ir.py +10 -6
  137. jaclang/vendor/mypyc/irbuild/builder.py +3 -4
  138. jaclang/vendor/mypyc/irbuild/function.py +5 -3
  139. jaclang/vendor/mypyc/irbuild/nonlocalcontrol.py +1 -2
  140. jaclang/vendor/mypyc/irbuild/prepare.py +6 -6
  141. jaclang/vendor/mypyc/primitives/registry.py +15 -5
  142. jaclang/vendor/mypyc/test/test_run.py +1 -2
  143. jaclang/vendor/mypyc/transform/uninit.py +3 -3
  144. jaclang/vendor/pluggy/_callers.py +1 -0
  145. jaclang/vendor/pluggy/_hooks.py +6 -10
  146. jaclang/vendor/pluggy/_result.py +1 -0
  147. jaclang/vendor/pluggy/_tracing.py +1 -0
  148. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/METADATA +1 -1
  149. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/RECORD +152 -150
  150. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/WHEEL +0 -0
  151. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/entry_points.txt +0 -0
  152. {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.compiler.importer import jac_import # noqa: E402
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 as __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
- base, mod = os.path.split(filename)
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 = __jac_import__(target=mod_name, base_path=base)
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=eval(param.annotation)
85
- if isinstance(param.annotation, str)
86
- else param.annotation,
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=eval(param.annotation)
94
- if isinstance(param.annotation, str)
95
- else param.annotation,
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=eval(param.annotation)
108
- if isinstance(param.annotation, str)
109
- else param.annotation,
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