jaclang 0.7.13__py3-none-any.whl → 0.7.16__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 (96) hide show
  1. jaclang/cli/cli.py +15 -10
  2. jaclang/cli/cmdreg.py +9 -12
  3. jaclang/compiler/__init__.py +19 -53
  4. jaclang/compiler/absyntree.py +95 -17
  5. jaclang/compiler/jac.lark +4 -3
  6. jaclang/compiler/parser.py +35 -23
  7. jaclang/compiler/passes/ir_pass.py +4 -13
  8. jaclang/compiler/passes/main/access_modifier_pass.py +1 -1
  9. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +4 -5
  10. jaclang/compiler/passes/main/import_pass.py +19 -23
  11. jaclang/compiler/passes/main/pyast_gen_pass.py +308 -567
  12. jaclang/compiler/passes/main/pyast_load_pass.py +33 -6
  13. jaclang/compiler/passes/main/registry_pass.py +37 -3
  14. jaclang/compiler/passes/main/sym_tab_build_pass.py +1 -1
  15. jaclang/compiler/passes/main/tests/__init__.py +1 -1
  16. jaclang/compiler/passes/main/tests/test_import_pass.py +5 -1
  17. jaclang/compiler/passes/main/type_check_pass.py +7 -0
  18. jaclang/compiler/passes/tool/fuse_comments_pass.py +14 -2
  19. jaclang/compiler/passes/tool/jac_formatter_pass.py +144 -94
  20. jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +0 -1
  21. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/architype_test.jac +13 -0
  22. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/comment_alignment.jac +11 -0
  23. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/comments.jac +13 -0
  24. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/decorator_stack.jac +37 -0
  25. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/esc_keywords.jac +5 -0
  26. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/long_names.jac +19 -0
  27. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +6 -0
  28. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +11 -0
  29. jaclang/compiler/passes/tool/tests/test_unparse_validate.py +33 -39
  30. jaclang/compiler/passes/transform.py +4 -0
  31. jaclang/compiler/semtable.py +31 -7
  32. jaclang/compiler/tests/test_importer.py +12 -5
  33. jaclang/langserve/engine.py +82 -143
  34. jaclang/langserve/sem_manager.py +379 -0
  35. jaclang/langserve/server.py +8 -10
  36. jaclang/langserve/tests/fixtures/base_module_structure.jac +27 -6
  37. jaclang/langserve/tests/fixtures/circle.jac +3 -3
  38. jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
  39. jaclang/langserve/tests/fixtures/circle_pure.test.jac +3 -3
  40. jaclang/langserve/tests/fixtures/import_include_statements.jac +1 -1
  41. jaclang/langserve/tests/test_sem_tokens.py +277 -0
  42. jaclang/langserve/tests/test_server.py +96 -16
  43. jaclang/langserve/utils.py +163 -96
  44. jaclang/plugin/builtin.py +1 -1
  45. jaclang/plugin/default.py +214 -24
  46. jaclang/plugin/feature.py +59 -11
  47. jaclang/plugin/spec.py +58 -6
  48. jaclang/{core → runtimelib}/architype.py +1 -1
  49. jaclang/{core → runtimelib}/context.py +8 -1
  50. jaclang/runtimelib/importer.py +361 -0
  51. jaclang/runtimelib/machine.py +94 -0
  52. jaclang/{core → runtimelib}/utils.py +13 -5
  53. jaclang/settings.py +4 -1
  54. jaclang/tests/fixtures/abc.jac +3 -3
  55. jaclang/tests/fixtures/blankwithentry.jac +3 -0
  56. jaclang/tests/fixtures/byllmissue.jac +1 -5
  57. jaclang/tests/fixtures/chandra_bugs2.jac +11 -10
  58. jaclang/tests/fixtures/cls_method.jac +41 -0
  59. jaclang/tests/fixtures/dblhello.jac +6 -0
  60. jaclang/tests/fixtures/deep/one_lev.jac +3 -3
  61. jaclang/tests/fixtures/deep/one_lev_dup.jac +2 -3
  62. jaclang/tests/fixtures/deep_import_mods.jac +13 -0
  63. jaclang/tests/fixtures/err.impl.jac +3 -0
  64. jaclang/tests/fixtures/err.jac +4 -2
  65. jaclang/tests/fixtures/err.test.jac +3 -0
  66. jaclang/tests/fixtures/err_runtime.jac +15 -0
  67. jaclang/tests/fixtures/game1.jac +1 -1
  68. jaclang/tests/fixtures/hello.jac +4 -0
  69. jaclang/tests/fixtures/impl_grab.impl.jac +2 -1
  70. jaclang/tests/fixtures/impl_grab.jac +4 -1
  71. jaclang/tests/fixtures/jp_importer_auto.jac +14 -0
  72. jaclang/tests/fixtures/maxfail_run_test.jac +4 -4
  73. jaclang/tests/fixtures/needs_import.jac +2 -2
  74. jaclang/tests/fixtures/pyfunc_2.py +3 -0
  75. jaclang/tests/fixtures/registry.jac +9 -0
  76. jaclang/tests/fixtures/run_test.jac +4 -4
  77. jaclang/tests/fixtures/semstr.jac +1 -4
  78. jaclang/tests/fixtures/simple_archs.jac +1 -1
  79. jaclang/tests/test_cli.py +65 -2
  80. jaclang/tests/test_language.py +83 -7
  81. jaclang/tests/test_man_code.py +17 -0
  82. jaclang/tests/test_reference.py +6 -0
  83. jaclang/utils/helpers.py +45 -21
  84. jaclang/utils/test.py +9 -0
  85. jaclang/utils/treeprinter.py +0 -4
  86. {jaclang-0.7.13.dist-info → jaclang-0.7.16.dist-info}/METADATA +3 -2
  87. {jaclang-0.7.13.dist-info → jaclang-0.7.16.dist-info}/RECORD +93 -77
  88. jaclang/core/importer.py +0 -344
  89. jaclang/tests/fixtures/aott_raise.jac +0 -25
  90. jaclang/tests/fixtures/package_import.jac +0 -6
  91. /jaclang/{core → runtimelib}/__init__.py +0 -0
  92. /jaclang/{core → runtimelib}/constructs.py +0 -0
  93. /jaclang/{core → runtimelib}/memory.py +0 -0
  94. /jaclang/{core → runtimelib}/test.py +0 -0
  95. {jaclang-0.7.13.dist-info → jaclang-0.7.16.dist-info}/WHEEL +0 -0
  96. {jaclang-0.7.13.dist-info → jaclang-0.7.16.dist-info}/entry_points.txt +0 -0
@@ -16,7 +16,10 @@ import jaclang.compiler.absyntree as ast
16
16
  from jaclang.compiler.passes import Pass
17
17
  from jaclang.compiler.passes.main import SubNodeTabPass
18
18
  from jaclang.settings import settings
19
- from jaclang.utils.helpers import import_target_to_relative_path, is_standard_lib_module
19
+ from jaclang.utils.helpers import is_standard_lib_module
20
+ from jaclang.utils.log import logging
21
+
22
+ logger = logging.getLogger(__name__)
20
23
 
21
24
 
22
25
  class JacImportPass(Pass):
@@ -51,13 +54,10 @@ class JacImportPass(Pass):
51
54
 
52
55
  def process_import(self, node: ast.Module, i: ast.ModulePath) -> None:
53
56
  """Process an import."""
54
- lang = i.parent_of_type(ast.Import).hint.tag.value
55
- if lang == "jac" and not i.sub_module:
56
- self.import_jac_module(
57
- node=i,
58
- mod_path=node.loc.mod_path,
59
- )
60
- elif lang == "py":
57
+ imp_node = i.parent_of_type(ast.Import)
58
+ if imp_node.is_jac and not i.sub_module:
59
+ self.import_jac_module(node=i)
60
+ elif imp_node.is_py:
61
61
  self.__py_imports.add(i.path_str)
62
62
 
63
63
  def attach_mod_to_node(
@@ -136,14 +136,10 @@ class JacImportPass(Pass):
136
136
  if node.as_attr_list[0].sym_name in self.__py_imports:
137
137
  self.py_resolve_list.add(".".join([i.sym_name for i in node.as_attr_list]))
138
138
 
139
- def import_jac_module(self, node: ast.ModulePath, mod_path: str) -> None:
139
+ def import_jac_module(self, node: ast.ModulePath) -> None:
140
140
  """Import a module."""
141
141
  self.cur_node = node # impacts error reporting
142
- target = import_target_to_relative_path(
143
- level=node.level,
144
- target=node.path_str,
145
- base_path=os.path.dirname(node.loc.mod_path),
146
- )
142
+ target = node.resolve_relative_path()
147
143
  # If the module is a package (dir)
148
144
  if os.path.isdir(target):
149
145
  self.attach_mod_to_node(node, self.import_jac_mod_from_dir(target))
@@ -153,11 +149,7 @@ class JacImportPass(Pass):
153
149
  # Import all from items as modules or packages
154
150
  for i in import_node.items.items:
155
151
  if isinstance(i, ast.ModuleItem):
156
- from_mod_target = import_target_to_relative_path(
157
- level=node.level,
158
- target=node.path_str + "." + i.name.value,
159
- base_path=os.path.dirname(node.loc.mod_path),
160
- )
152
+ from_mod_target = node.resolve_relative_path(i.name.value)
161
153
  # If package
162
154
  if os.path.isdir(from_mod_target):
163
155
  self.attach_mod_to_node(
@@ -182,6 +174,7 @@ class JacImportPass(Pass):
182
174
  source=ast.JacSource("", mod_path=target),
183
175
  doc=None,
184
176
  body=[],
177
+ terminals=[],
185
178
  is_imported=False,
186
179
  stub_only=True,
187
180
  kid=[ast.EmptyToken()],
@@ -203,7 +196,7 @@ class JacImportPass(Pass):
203
196
  self.warnings_had += mod_pass.warnings_had
204
197
  mod = mod_pass.ir
205
198
  except Exception as e:
206
- print(e)
199
+ logger.info(e)
207
200
  mod = None
208
201
  if isinstance(mod, ast.Module):
209
202
  self.import_table[target] = mod
@@ -226,8 +219,12 @@ class PyImportPass(JacImportPass):
226
219
 
227
220
  def process_import(self, node: ast.Module, i: ast.ModulePath) -> None:
228
221
  """Process an import."""
229
- lang = i.parent_of_type(ast.Import).hint.tag.value
230
- if lang == "py" and not i.sub_module and not is_standard_lib_module(i.path_str):
222
+ imp_node = i.parent_of_type(ast.Import)
223
+ if (
224
+ imp_node.is_py
225
+ and not i.sub_module
226
+ and not is_standard_lib_module(i.path_str)
227
+ ):
231
228
  mod = self.import_py_module(node=i, mod_path=node.loc.mod_path)
232
229
  if mod:
233
230
  i.sub_module = mod
@@ -251,7 +248,6 @@ class PyImportPass(JacImportPass):
251
248
  if spec.origin in self.import_table:
252
249
  return self.import_table[spec.origin]
253
250
  with open(spec.origin, "r", encoding="utf-8") as f:
254
- # print(f"\nImporting python module {node.path_str}")
255
251
  mod = PyastBuildPass(
256
252
  input_ir=ast.PythonModuleAst(
257
253
  py_ast.parse(f.read()), mod_path=spec.origin