jaclang 0.8.0__py3-none-any.whl → 0.8.2__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 (124) hide show
  1. jaclang/__init__.py +6 -0
  2. jaclang/cli/cli.py +23 -50
  3. jaclang/compiler/codeinfo.py +0 -1
  4. jaclang/compiler/jac.lark +14 -22
  5. jaclang/compiler/larkparse/jac_parser.py +2 -2
  6. jaclang/compiler/parser.py +378 -531
  7. jaclang/compiler/passes/main/__init__.py +0 -14
  8. jaclang/compiler/passes/main/annex_pass.py +2 -8
  9. jaclang/compiler/passes/main/cfg_build_pass.py +39 -13
  10. jaclang/compiler/passes/main/def_impl_match_pass.py +14 -13
  11. jaclang/compiler/passes/main/def_use_pass.py +4 -7
  12. jaclang/compiler/passes/main/import_pass.py +6 -14
  13. jaclang/compiler/passes/main/inheritance_pass.py +2 -2
  14. jaclang/compiler/passes/main/pyast_gen_pass.py +428 -799
  15. jaclang/compiler/passes/main/pyast_load_pass.py +115 -311
  16. jaclang/compiler/passes/main/pyjac_ast_link_pass.py +8 -7
  17. jaclang/compiler/passes/main/sym_tab_build_pass.py +3 -3
  18. jaclang/compiler/passes/main/sym_tab_link_pass.py +6 -9
  19. jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/action/actions.jac +1 -5
  20. jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/main.jac +1 -8
  21. jaclang/compiler/passes/main/tests/test_cfg_build_pass.py +5 -9
  22. jaclang/compiler/passes/main/tests/test_decl_impl_match_pass.py +7 -8
  23. jaclang/compiler/passes/main/tests/test_import_pass.py +5 -18
  24. jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +2 -6
  25. jaclang/compiler/passes/main/tests/test_sub_node_pass.py +1 -3
  26. jaclang/compiler/passes/main/tests/test_sym_tab_link_pass.py +20 -17
  27. jaclang/compiler/passes/tool/doc_ir_gen_pass.py +425 -216
  28. jaclang/compiler/passes/tool/jac_formatter_pass.py +2 -0
  29. jaclang/compiler/passes/tool/tests/fixtures/archetype_frmt.jac +14 -0
  30. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +5 -4
  31. jaclang/compiler/passes/tool/tests/fixtures/import_fmt.jac +6 -0
  32. jaclang/compiler/passes/tool/tests/fixtures/simple_walk_fmt.jac +3 -3
  33. jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +9 -0
  34. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +18 -3
  35. jaclang/compiler/passes/tool/tests/test_unparse_validate.py +2 -2
  36. jaclang/compiler/program.py +22 -66
  37. jaclang/compiler/tests/fixtures/fam.jac +2 -2
  38. jaclang/compiler/tests/fixtures/pkg_import_lib/__init__.jac +1 -0
  39. jaclang/compiler/tests/fixtures/pkg_import_lib/sub/__init__.jac +1 -0
  40. jaclang/compiler/tests/fixtures/pkg_import_lib/sub/helper.jac +3 -0
  41. jaclang/compiler/tests/fixtures/pkg_import_lib/tools.jac +3 -0
  42. jaclang/compiler/tests/fixtures/pkg_import_lib_py/__init__.py +5 -0
  43. jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/__init__.py +3 -0
  44. jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/helper.jac +3 -0
  45. jaclang/compiler/tests/fixtures/pkg_import_lib_py/tools.jac +3 -0
  46. jaclang/compiler/tests/fixtures/pkg_import_main.jac +10 -0
  47. jaclang/compiler/tests/fixtures/pkg_import_main_py.jac +11 -0
  48. jaclang/compiler/tests/test_importer.py +30 -13
  49. jaclang/compiler/tests/test_parser.py +1 -0
  50. jaclang/compiler/unitree.py +488 -320
  51. jaclang/langserve/__init__.jac +1 -0
  52. jaclang/langserve/engine.jac +503 -0
  53. jaclang/langserve/sem_manager.jac +309 -0
  54. jaclang/langserve/server.jac +201 -0
  55. jaclang/langserve/tests/server_test/test_lang_serve.py +139 -48
  56. jaclang/langserve/tests/server_test/utils.py +35 -6
  57. jaclang/langserve/tests/session.jac +294 -0
  58. jaclang/langserve/tests/test_sem_tokens.py +2 -2
  59. jaclang/langserve/tests/test_server.py +8 -7
  60. jaclang/langserve/utils.jac +51 -30
  61. jaclang/runtimelib/archetype.py +128 -6
  62. jaclang/runtimelib/builtin.py +17 -14
  63. jaclang/runtimelib/importer.py +51 -76
  64. jaclang/runtimelib/machine.py +469 -305
  65. jaclang/runtimelib/meta_importer.py +86 -0
  66. jaclang/runtimelib/tests/fixtures/graph_purger.jac +24 -26
  67. jaclang/runtimelib/tests/fixtures/other_root_access.jac +25 -16
  68. jaclang/runtimelib/tests/fixtures/traversing_save.jac +7 -5
  69. jaclang/runtimelib/tests/test_jaseci.py +3 -1
  70. jaclang/runtimelib/utils.py +3 -3
  71. jaclang/tests/fixtures/arch_rel_import_creation.jac +23 -23
  72. jaclang/tests/fixtures/async_ability.jac +43 -10
  73. jaclang/tests/fixtures/async_function.jac +18 -0
  74. jaclang/tests/fixtures/async_walker.jac +17 -12
  75. jaclang/tests/fixtures/backward_edge_visit.jac +31 -0
  76. jaclang/tests/fixtures/builtin_printgraph.jac +85 -0
  77. jaclang/tests/fixtures/builtin_printgraph_json.jac +21 -0
  78. jaclang/tests/fixtures/builtin_printgraph_mermaid.jac +16 -0
  79. jaclang/tests/fixtures/chandra_bugs2.jac +20 -13
  80. jaclang/tests/fixtures/concurrency.jac +1 -1
  81. jaclang/tests/fixtures/create_dynamic_archetype.jac +25 -28
  82. jaclang/tests/fixtures/deep/deeper/deep_outer_import.jac +7 -4
  83. jaclang/tests/fixtures/deep/deeper/snd_lev.jac +2 -2
  84. jaclang/tests/fixtures/deep/deeper/snd_lev_dup.jac +6 -0
  85. jaclang/tests/fixtures/deep/one_lev.jac +2 -2
  86. jaclang/tests/fixtures/deep/one_lev_dup.jac +4 -3
  87. jaclang/tests/fixtures/dynamic_archetype.jac +19 -12
  88. jaclang/tests/fixtures/edge_ability.jac +49 -0
  89. jaclang/tests/fixtures/foo.jac +14 -22
  90. jaclang/tests/fixtures/guess_game.jac +1 -1
  91. jaclang/tests/fixtures/here_usage_error.jac +21 -0
  92. jaclang/tests/fixtures/here_visitor_usage.jac +21 -0
  93. jaclang/tests/fixtures/jac_from_py.py +1 -1
  94. jaclang/tests/fixtures/jp_importer.jac +6 -6
  95. jaclang/tests/fixtures/jp_importer_auto.jac +5 -3
  96. jaclang/tests/fixtures/node_del.jac +30 -36
  97. jaclang/tests/fixtures/unicode_strings.jac +24 -0
  98. jaclang/tests/fixtures/visit_traversal.jac +47 -0
  99. jaclang/tests/fixtures/walker_update.jac +5 -7
  100. jaclang/tests/test_cli.py +12 -7
  101. jaclang/tests/test_language.py +218 -145
  102. jaclang/tests/test_reference.py +9 -4
  103. jaclang/tests/test_typecheck.py +13 -26
  104. jaclang/utils/helpers.py +14 -6
  105. jaclang/utils/lang_tools.py +9 -8
  106. jaclang/utils/module_resolver.py +23 -0
  107. jaclang/utils/tests/test_lang_tools.py +2 -1
  108. jaclang/utils/treeprinter.py +3 -4
  109. {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/METADATA +4 -3
  110. {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/RECORD +112 -94
  111. {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/WHEEL +1 -1
  112. jaclang/compiler/passes/main/tests/fixtures/main_err.jac +0 -6
  113. jaclang/compiler/passes/main/tests/fixtures/second_err.jac +0 -4
  114. jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +0 -644
  115. jaclang/compiler/passes/tool/tests/test_doc_ir_gen_pass.py +0 -29
  116. jaclang/langserve/__init__.py +0 -1
  117. jaclang/langserve/engine.py +0 -553
  118. jaclang/langserve/sem_manager.py +0 -383
  119. jaclang/langserve/server.py +0 -167
  120. jaclang/langserve/tests/session.py +0 -255
  121. jaclang/tests/fixtures/builtin_dotgen.jac +0 -42
  122. jaclang/tests/fixtures/builtin_dotgen_json.jac +0 -21
  123. jaclang/tests/fixtures/deep/deeper/__init__.jac +0 -1
  124. {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/entry_points.txt +0 -0
@@ -14,6 +14,7 @@ relationships between the two AST representations throughout the compilation pro
14
14
  """
15
15
 
16
16
  import ast as ast3
17
+ from typing import Sequence
17
18
 
18
19
  import jaclang.compiler.unitree as uni
19
20
  from jaclang.compiler.passes import UniPass
@@ -50,7 +51,7 @@ class PyJacAstLinkPass(UniPass):
50
51
  self.link_jac_py_nodes(jac_node=node.body, py_nodes=node.gen.py_ast)
51
52
 
52
53
  def exit_impl_def(self, node: uni.ImplDef) -> None:
53
- for i in node.target.items:
54
+ for i in node.target:
54
55
  if i.name_spec.name_of.sym:
55
56
  self.link_jac_py_nodes(
56
57
  jac_node=i, py_nodes=i.name_spec.name_of.sym.decl.gen.py_ast
@@ -62,12 +63,12 @@ class PyJacAstLinkPass(UniPass):
62
63
 
63
64
  if isinstance(node.decl_link, uni.Ability) and node.decl_link.signature:
64
65
  if isinstance(node.spec, uni.FuncSignature) and node.spec.params:
65
- for src_prm in node.spec.params.items:
66
+ for src_prm in node.spec.params:
66
67
  if (
67
68
  isinstance(node.decl_link.signature, uni.FuncSignature)
68
69
  and node.decl_link.signature.params
69
70
  ):
70
- for trg_prm in node.decl_link.signature.params.items:
71
+ for trg_prm in node.decl_link.signature.params:
71
72
  if src_prm.name.sym_name == trg_prm.name.sym_name:
72
73
  self.link_jac_py_nodes(
73
74
  jac_node=src_prm, py_nodes=trg_prm.gen.py_ast
@@ -88,9 +89,9 @@ class PyJacAstLinkPass(UniPass):
88
89
  )
89
90
 
90
91
  if isinstance(node.decl_link, uni.Ability) and isinstance(
91
- node.target, uni.SubNodeList
92
+ node.target, Sequence
92
93
  ):
93
- for arch in node.target.items:
94
+ for arch in node.target:
94
95
  if arch.name_spec.name_of.sym:
95
96
  arch.name_spec.name_of.sym.add_use(arch.name_spec)
96
97
 
@@ -107,11 +108,11 @@ class PyJacAstLinkPass(UniPass):
107
108
  self.link_jac_py_nodes(jac_node=node.alias, py_nodes=node.gen.py_ast)
108
109
 
109
110
  def exit_global_stmt(self, node: uni.GlobalStmt) -> None:
110
- for x, y in enumerate(node.target.items):
111
+ for x, y in enumerate(node.target):
111
112
  self.link_jac_py_nodes(jac_node=y, py_nodes=[node.gen.py_ast[x]])
112
113
 
113
114
  def exit_non_local_stmt(self, node: uni.NonLocalStmt) -> None:
114
- for x, y in enumerate(node.target.items):
115
+ for x, y in enumerate(node.target):
115
116
  self.link_jac_py_nodes(jac_node=y, py_nodes=[node.gen.py_ast[x]])
116
117
 
117
118
  def exit_k_w_pair(self, node: uni.KWPair) -> None:
@@ -54,7 +54,7 @@ class SymTabBuildPass(UniPass):
54
54
 
55
55
  def exit_global_vars(self, node: uni.GlobalVars) -> None:
56
56
  for i in self.get_all_sub_nodes(node, uni.Assignment):
57
- for j in i.target.items:
57
+ for j in i.target:
58
58
  if isinstance(j, uni.AstSymbolNode):
59
59
  j.sym_tab.def_insert(j, access_spec=node, single_decl="global var")
60
60
  else:
@@ -75,12 +75,12 @@ class SymTabBuildPass(UniPass):
75
75
  def exit_module_path(self, node: uni.ModulePath) -> None:
76
76
  if node.alias:
77
77
  node.alias.sym_tab.def_insert(node.alias, single_decl="import")
78
- elif node.path and isinstance(node.path.items[0], uni.Name):
78
+ elif node.path and isinstance(node.path[0], uni.Name):
79
79
  if node.parent_of_type(uni.Import) and not (
80
80
  node.parent_of_type(uni.Import).from_loc
81
81
  and node.parent_of_type(uni.Import).is_jac
82
82
  ):
83
- node.path.items[0].sym_tab.def_insert(node.path.items[0])
83
+ node.path[0].sym_tab.def_insert(node.path[0])
84
84
  else:
85
85
  pass # Need to support pythonic import symbols with dots in it
86
86
 
@@ -32,11 +32,8 @@ class SymTabLinkPass(Transform[uni.Module, uni.Module]):
32
32
  def transform(self, ir_in: uni.Module) -> uni.Module:
33
33
  """Link the symbol tables for all modules in the program."""
34
34
  # Process all modules in the program hub
35
- for mod in self.prog.mod.hub.values():
36
- module_paths = mod.get_all_sub_nodes(uni.ModulePath)
37
- for node in module_paths:
38
- self.process_module_path(mod, node)
39
-
35
+ for node in ir_in.get_all_sub_nodes(uni.ModulePath):
36
+ self.process_module_path(ir_in, node)
40
37
  return ir_in
41
38
 
42
39
  def process_module_path(self, mod: uni.Module, node: uni.ModulePath) -> None:
@@ -97,15 +94,15 @@ class SymTabLinkPass(Transform[uni.Module, uni.Module]):
97
94
 
98
95
  def _is_all_import(self, imp_node: uni.Import, node: uni.ModulePath) -> bool:
99
96
  """Determine if this is an all import (import everything from module)."""
100
- return (
101
- imp_node.is_jac and node.parent and isinstance(node.parent, uni.SubNodeList)
102
- ) or (imp_node.is_py and imp_node.from_loc is None and not imp_node.is_absorb)
97
+ return (imp_node.is_jac and node in imp_node.items) or (
98
+ imp_node.is_py and imp_node.from_loc is None and not imp_node.is_absorb
99
+ )
103
100
 
104
101
  def _get_imported_symbols(self, node: uni.ModulePath) -> list[str]:
105
102
  """Get list of specific symbols being imported."""
106
103
  symbols = []
107
104
  if node.parent and isinstance(node.parent, uni.Import):
108
- for mod_items in node.parent.items.items:
105
+ for mod_items in node.parent.items:
109
106
  if isinstance(mod_items, uni.ModuleItem):
110
107
  symbols.append(mod_items.name.value)
111
108
  return symbols
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  node LLM{
4
2
 
5
3
  can infer with AgentNode entry{
@@ -9,15 +7,13 @@ node LLM{
9
7
  def testing_infer {
10
8
  return "LLM's response";
11
9
  }
12
-
13
10
  }
14
11
 
15
12
 
16
- obj AgentNode{
13
+ walker Agent{
17
14
  has describ :str = "AgentNode";
18
15
 
19
16
  can connect with LLM entry{
20
17
  return "AgentNode's response";
21
-
22
18
  }
23
19
  }
@@ -1,14 +1,7 @@
1
-
2
-
3
-
4
1
  import from action {actions}
5
2
 
6
-
7
3
  with entry{
8
-
9
4
  openai = actions.LLM();
10
- agent = actions.AgentNode();
5
+ agent = actions.Agent();
11
6
  print("openai: response: ", openai.testing_infer());
12
-
13
-
14
7
  }
@@ -1,8 +1,8 @@
1
1
  """Test pass module."""
2
2
 
3
- from jaclang.compiler.passes.main import CompilerMode as CMode
4
3
  from jaclang.compiler.program import JacProgram
5
4
  from jaclang.utils.test import TestCase
5
+ import unittest
6
6
 
7
7
 
8
8
  class TestCFGBuildPass(TestCase):
@@ -21,16 +21,14 @@ class TestCFGBuildPass(TestCase):
21
21
  with open(file_name, "r") as f:
22
22
  file_source = f.read()
23
23
 
24
- ir = (prog := JacProgram()).compile_from_str(
25
- source_str=file_source, file_path=file_name, mode=CMode.COMPILE
26
- )
24
+ ir = (prog := JacProgram()).compile(use_str=file_source, file_path=file_name)
27
25
 
28
26
  cfg_pass = CoalesceBBPass(
29
27
  ir_in=ir,
30
28
  prog=prog,
31
29
  )
32
30
 
33
- dot = cfg_pass.dotgen_cfg()
31
+ dot = cfg_pass.printgraph_cfg()
34
32
 
35
33
  expected_dot = (
36
34
  "digraph G {\n"
@@ -69,16 +67,14 @@ class TestCFGBuildPass(TestCase):
69
67
  with open(file_name, "r") as f:
70
68
  file_source = f.read()
71
69
 
72
- ir = (prog := JacProgram()).compile_from_str(
73
- source_str=file_source, file_path=file_name, mode=CMode.COMPILE
74
- )
70
+ ir = (prog := JacProgram()).compile(use_str=file_source, file_path=file_name)
75
71
 
76
72
  cfg_pass = CoalesceBBPass(
77
73
  ir_in=ir,
78
74
  prog=prog,
79
75
  )
80
76
 
81
- dot = cfg_pass.dotgen_cfg()
77
+ dot = cfg_pass.printgraph_cfg()
82
78
 
83
79
  expected_dot = (
84
80
  "digraph G {\n"
@@ -4,7 +4,7 @@ import io
4
4
  import sys
5
5
 
6
6
  import jaclang.compiler.unitree as uni
7
- from jaclang import JacMachineInterface as Jac, JacMachine
7
+ from jaclang import JacMachine as Jac
8
8
  from jaclang.cli import cli
9
9
  from jaclang.compiler.program import JacProgram
10
10
  from jaclang.utils.test import TestCase
@@ -15,9 +15,8 @@ class DeclImplMatchPassTests(TestCase):
15
15
 
16
16
  def setUp(self) -> None:
17
17
  """Set up test."""
18
- self.mach = JacMachine(self.fixture_abs_path("./"))
18
+ Jac.set_base_path(self.fixture_abs_path("./"))
19
19
  Jac.attach_program(
20
- self.mach,
21
20
  JacProgram(),
22
21
  )
23
22
  return super().setUp()
@@ -110,7 +109,7 @@ class DeclImplMatchPassTests(TestCase):
110
109
  """Test walking through edges and nodes."""
111
110
  captured_output = io.StringIO()
112
111
  sys.stdout = captured_output
113
- Jac.jac_import(self.mach, "mtest", base_path=self.fixture_abs_path("./"))
112
+ Jac.jac_import("mtest", base_path=self.fixture_abs_path("./"))
114
113
  sys.stdout = sys.__stdout__
115
114
  stdout_value = captured_output.getvalue()
116
115
  self.assertIn("2.0\n", stdout_value)
@@ -119,7 +118,7 @@ class DeclImplMatchPassTests(TestCase):
119
118
  """Test walking through edges."""
120
119
  captured_output = io.StringIO()
121
120
  sys.stdout = captured_output
122
- Jac.jac_import(self.mach, "impl_grab", base_path=self.fixture_abs_path("./"))
121
+ Jac.jac_import("impl_grab", base_path=self.fixture_abs_path("./"))
123
122
  sys.stdout = sys.__stdout__
124
123
  stdout_value = captured_output.getvalue()
125
124
  self.assertIn("1.414", stdout_value)
@@ -128,7 +127,7 @@ class DeclImplMatchPassTests(TestCase):
128
127
  """Test complex nested impls."""
129
128
  captured_output = io.StringIO()
130
129
  sys.stdout = captured_output
131
- Jac.jac_import(self.mach, "nested_impls", base_path=self.fixture_abs_path("./"))
130
+ Jac.jac_import("nested_impls", base_path=self.fixture_abs_path("./"))
132
131
  sys.stdout = sys.__stdout__
133
132
  stdout_value = captured_output.getvalue().split("\n")
134
133
  self.assertIn("Hello,from bar in kk", stdout_value[0])
@@ -142,7 +141,7 @@ class DeclImplMatchPassTests(TestCase):
142
141
  """Parse micro jac file."""
143
142
  captured_output = io.StringIO()
144
143
  sys.stdout = captured_output
145
- Jac.jac_import(self.mach, "atest", base_path=self.fixture_abs_path("./"))
144
+ Jac.jac_import("atest", base_path=self.fixture_abs_path("./"))
146
145
  sys.stdout = sys.__stdout__
147
146
  stdout_value = captured_output.getvalue()
148
147
  self.assertEqual(stdout_value, "42\n")
@@ -151,7 +150,7 @@ class DeclImplMatchPassTests(TestCase):
151
150
  """Parse micro jac file."""
152
151
  captured_output = io.StringIO()
153
152
  sys.stdout = captured_output
154
- Jac.jac_import(self.mach, "enumerations", base_path=self.fixture_abs_path("./"))
153
+ Jac.jac_import("enumerations", base_path=self.fixture_abs_path("./"))
155
154
  sys.stdout = sys.__stdout__
156
155
  stdout_value = captured_output.getvalue()
157
156
  self.assertEqual(stdout_value, "1\n")
@@ -7,7 +7,6 @@ import unittest
7
7
 
8
8
  import jaclang.compiler.unitree as uni
9
9
  from jaclang.cli import cli
10
- from jaclang.compiler.passes.main import CompilerMode as CMode
11
10
  from jaclang.compiler.program import JacProgram
12
11
  from jaclang.utils.test import TestCase
13
12
 
@@ -21,7 +20,7 @@ class ImportPassPassTests(TestCase):
21
20
 
22
21
  def test_pygen_jac_cli(self) -> None:
23
22
  """Basic test for pass."""
24
- (out := JacProgram()).compile(self.fixture_abs_path("base.jac"))
23
+ (out := JacProgram()).build(self.fixture_abs_path("base.jac"))
25
24
  self.assertFalse(out.errors_had)
26
25
  mod = out.mod.hub[self.fixture_abs_path("impl/imps.jac")]
27
26
  self.assertIn("56", str(mod.to_dict()))
@@ -38,7 +37,7 @@ class ImportPassPassTests(TestCase):
38
37
 
39
38
  def test_import_include_auto_impl(self) -> None:
40
39
  """Basic test for pass."""
41
- (prog := JacProgram()).compile(self.fixture_abs_path("incautoimpl.jac"))
40
+ (prog := JacProgram()).build(self.fixture_abs_path("incautoimpl.jac"))
42
41
  num_modules = len(list(prog.mod.hub.values())[1].impl_mod) + 1
43
42
  mod_names = [i.name for i in list(prog.mod.hub.values())[1].impl_mod]
44
43
  self.assertEqual(num_modules, 5)
@@ -50,7 +49,7 @@ class ImportPassPassTests(TestCase):
50
49
 
51
50
  def test_annexalbe_by_discovery(self) -> None:
52
51
  """Basic test for pass."""
53
- (prog := JacProgram()).compile(self.fixture_abs_path("incautoimpl.jac"))
52
+ (prog := JacProgram()).build(self.fixture_abs_path("incautoimpl.jac"))
54
53
  count = 0
55
54
  all_mods = prog.mod.hub.values()
56
55
  self.assertEqual(len(all_mods), 6)
@@ -66,10 +65,7 @@ class ImportPassPassTests(TestCase):
66
65
  @unittest.skip("TODO: Fix when we have the type checker")
67
66
  def test_py_raise_map(self) -> None:
68
67
  """Basic test for pass."""
69
- (build := JacProgram()).compile(
70
- self.fixture_abs_path("py_imp_test.jac"),
71
- mode=CMode.TYPECHECK,
72
- )
68
+ (build := JacProgram()).build(self.fixture_abs_path("py_imp_test.jac"))
73
69
  p = {
74
70
  "math": r"jaclang/vendor/mypy/typeshed/stdlib/math.pyi$",
75
71
  "pygame_mock": r"pygame_mock/__init__.pyi$",
@@ -91,9 +87,7 @@ class ImportPassPassTests(TestCase):
91
87
  @unittest.skip("TODO: Fix when we have the type checker")
92
88
  def test_py_raised_mods(self) -> None:
93
89
  """Basic test for pass."""
94
- (prog := JacProgram()).compile(
95
- self.fixture_abs_path("py_imp_test.jac"), mode=CMode.TYPECHECK
96
- )
90
+ (prog := JacProgram()).build(self.fixture_abs_path("py_imp_test.jac"))
97
91
  for i in list(
98
92
  filter(
99
93
  lambda x: x.is_raised_from_py,
@@ -125,13 +119,6 @@ class ImportPassPassTests(TestCase):
125
119
  self.assertIn("bar", stdout_value)
126
120
  self.assertIn("baz", stdout_value)
127
121
 
128
- def test_raise_syntax_error(self) -> None:
129
- """Test raise error on the parser , dont go to the next pass."""
130
- (state := JacProgram()).compile(self.fixture_abs_path("main_err.jac"))
131
- self.assertTrue(state.errors_had)
132
- self.assertEqual(len(state.errors_had), 1)
133
- self.assertIn("Syntax Error", state.errors_had[0].msg)
134
-
135
122
  def test_circular_import(self) -> None:
136
123
  """Test circular import."""
137
124
  (state := JacProgram()).compile(self.fixture_abs_path("circular_import.jac"))
@@ -6,9 +6,8 @@ import sys
6
6
  import types
7
7
 
8
8
  import jaclang.compiler.unitree as uni
9
- from jaclang.compiler.passes.main import CompilerMode as CMode, PyastGenPass
9
+ from jaclang.compiler.passes.main import PyastGenPass
10
10
  from jaclang.compiler.program import JacProgram
11
- from jaclang.runtimelib.machine import JacMachine
12
11
  from jaclang.utils.test import AstSyncTestMixin, TestCaseMicroSuite
13
12
 
14
13
 
@@ -53,7 +52,6 @@ class PyastGenPassTests(TestCaseMicroSuite, AstSyncTestMixin):
53
52
  sys.stdout = captured_output
54
53
  module = types.ModuleType("__main__")
55
54
  module.__dict__["__file__"] = code_gen.loc.mod_path
56
- module.__dict__["__jac_mach__"] = JacMachine()
57
55
  exec(prog, module.__dict__)
58
56
  sys.stdout = sys.__stdout__
59
57
  stdout_value = captured_output.getvalue()
@@ -123,9 +121,7 @@ class ValidateTreeParentTest(TestCaseMicroSuite):
123
121
 
124
122
  def micro_suite_test(self, filename: str) -> None:
125
123
  """Parse micro jac file."""
126
- code_gen = JacProgram().compile(
127
- self.fixture_abs_path(filename), mode=CMode.PARSE
128
- )
124
+ code_gen = JacProgram().compile(self.fixture_abs_path(filename))
129
125
  self.assertTrue(self.parent_scrub(code_gen))
130
126
  code_gen = JacProgram().compile(self.fixture_abs_path(filename))
131
127
  self.assertTrue(self.parent_scrub(code_gen))
@@ -1,7 +1,6 @@
1
1
  """Test sub node pass module."""
2
2
 
3
3
  from jaclang.compiler.passes import UniPass
4
- from jaclang.compiler.passes.main import CompilerMode as CMode
5
4
  from jaclang.compiler.program import JacProgram
6
5
  from jaclang.utils.test import TestCase
7
6
 
@@ -16,8 +15,7 @@ class SubNodePassTests(TestCase):
16
15
  def test_sub_node_pass(self) -> None:
17
16
  """Basic test for pass."""
18
17
  code_gen = (out := JacProgram()).compile(
19
- file_path=self.examples_abs_path("manual_code/circle.jac"),
20
- mode=CMode.PARSE,
18
+ file_path=self.examples_abs_path("manual_code/circle.jac")
21
19
  )
22
20
  for i in code_gen.kid[1].kid:
23
21
  for k, v in i._sub_node_tab.items():
@@ -2,7 +2,6 @@
2
2
 
3
3
  import os
4
4
 
5
- from jaclang.compiler.passes.main import CompilerMode as CMode
6
5
  from jaclang.compiler.program import JacProgram
7
6
  from jaclang.utils.test import TestCase
8
7
 
@@ -23,7 +22,7 @@ class SymTabLinkPassTests(TestCase):
23
22
  "symtab_link_tests",
24
23
  "no_dupls.jac",
25
24
  )
26
- mod = JacProgram().compile(file_path, mode=CMode.TYPECHECK)
25
+ mod = JacProgram().build(file_path)
27
26
  self.assertEqual(
28
27
  len(mod.sym_tab.names_in_scope.values()),
29
28
  3,
@@ -33,20 +32,24 @@ class SymTabLinkPassTests(TestCase):
33
32
  i,
34
33
  str(mod.sym_tab.names_in_scope.values()),
35
34
  )
36
- self.assertEqual(len(mod.sym_tab.names_in_scope["a"].uses), 2)
37
- self.assertEqual(
38
- len(
39
- list(
40
- mod.sym_tab.kid_scope[0]
41
- .kid_scope[0]
42
- .kid_scope[0]
43
- .kid_scope[0]
44
- .inherited_scope[0]
45
- .base_symbol_table.names_in_scope.values()
46
- )[0].uses,
47
- ),
48
- 3,
49
- )
35
+ # TODO: def use is called on single file so this breaks
36
+ # Def Use pass will go away with full type checking
37
+ # self.assertEqual(
38
+ # len(mod.sym_tab.names_in_scope["a"].uses), 4
39
+ # )
40
+ # self.assertEqual(
41
+ # len(
42
+ # list(
43
+ # mod.sym_tab.kid_scope[0]
44
+ # .kid_scope[0]
45
+ # .kid_scope[0]
46
+ # .kid_scope[0]
47
+ # .inherited_scope[0]
48
+ # .base_symbol_table.names_in_scope.values()
49
+ # )[0].uses,
50
+ # ),
51
+ # 3,
52
+ # )
50
53
 
51
54
  def test_package(self) -> None:
52
55
  """Test package."""
@@ -57,6 +60,6 @@ class SymTabLinkPassTests(TestCase):
57
60
  "main.jac",
58
61
  )
59
62
  prog = JacProgram()
60
- prog.compile(file_path, mode=CMode.COMPILE)
63
+ prog.compile(file_path)
61
64
  self.assertEqual(prog.errors_had, [])
62
65
  self.assertEqual(prog.warnings_had, [])