jaclang 0.7.2__py3-none-any.whl → 0.7.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 (95) hide show
  1. jaclang/cli/cli.py +2 -2
  2. jaclang/compiler/__init__.py +11 -12
  3. jaclang/compiler/absyntree.py +499 -294
  4. jaclang/compiler/codeloc.py +2 -2
  5. jaclang/compiler/constant.py +100 -2
  6. jaclang/compiler/jac.lark +27 -19
  7. jaclang/compiler/parser.py +119 -92
  8. jaclang/compiler/passes/main/access_modifier_pass.py +20 -12
  9. jaclang/compiler/passes/main/def_impl_match_pass.py +28 -14
  10. jaclang/compiler/passes/main/def_use_pass.py +59 -40
  11. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +65 -43
  12. jaclang/compiler/passes/main/import_pass.py +8 -6
  13. jaclang/compiler/passes/main/pyast_gen_pass.py +97 -42
  14. jaclang/compiler/passes/main/pyast_load_pass.py +47 -12
  15. jaclang/compiler/passes/main/pyjac_ast_link_pass.py +19 -10
  16. jaclang/compiler/passes/main/registry_pass.py +6 -6
  17. jaclang/compiler/passes/main/sub_node_tab_pass.py +0 -5
  18. jaclang/compiler/passes/main/sym_tab_build_pass.py +43 -235
  19. jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +21 -4
  20. jaclang/compiler/passes/main/tests/test_def_use_pass.py +5 -10
  21. jaclang/compiler/passes/main/type_check_pass.py +2 -1
  22. jaclang/compiler/passes/tool/jac_formatter_pass.py +30 -9
  23. jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +16 -0
  24. jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +16 -0
  25. jaclang/compiler/passes/tool/tests/fixtures/genai/essay_review.jac +1 -1
  26. jaclang/compiler/passes/tool/tests/fixtures/genai/expert_answer.jac +1 -1
  27. jaclang/compiler/passes/tool/tests/fixtures/genai/joke_gen.jac +1 -1
  28. jaclang/compiler/passes/tool/tests/fixtures/genai/odd_word_out.jac +1 -1
  29. jaclang/compiler/passes/tool/tests/fixtures/genai/personality_finder.jac +1 -1
  30. jaclang/compiler/passes/tool/tests/fixtures/genai/text_to_type.jac +1 -1
  31. jaclang/compiler/passes/tool/tests/fixtures/genai/translator.jac +1 -1
  32. jaclang/compiler/passes/tool/tests/fixtures/genai/wikipedia.jac +1 -1
  33. jaclang/compiler/passes/transform.py +2 -4
  34. jaclang/compiler/passes/utils/mypy_ast_build.py +1 -8
  35. jaclang/{core/registry.py → compiler/semtable.py} +1 -3
  36. jaclang/compiler/symtable.py +142 -101
  37. jaclang/compiler/tests/test_parser.py +2 -2
  38. jaclang/core/{construct.py → architype.py} +25 -240
  39. jaclang/core/constructs.py +44 -0
  40. jaclang/core/context.py +157 -0
  41. jaclang/core/importer.py +18 -9
  42. jaclang/core/memory.py +99 -0
  43. jaclang/core/test.py +90 -0
  44. jaclang/core/utils.py +2 -2
  45. jaclang/langserve/engine.py +127 -50
  46. jaclang/langserve/server.py +34 -61
  47. jaclang/langserve/tests/fixtures/base_module_structure.jac +28 -0
  48. jaclang/langserve/tests/fixtures/circle.jac +16 -12
  49. jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
  50. jaclang/langserve/tests/fixtures/circle_pure.test.jac +15 -0
  51. jaclang/langserve/tests/fixtures/import_include_statements.jac +6 -0
  52. jaclang/langserve/tests/fixtures/py_import.py +26 -0
  53. jaclang/langserve/tests/test_server.py +93 -18
  54. jaclang/langserve/utils.py +124 -10
  55. jaclang/plugin/builtin.py +1 -1
  56. jaclang/plugin/default.py +25 -77
  57. jaclang/plugin/feature.py +25 -7
  58. jaclang/plugin/spec.py +18 -20
  59. jaclang/settings.py +3 -0
  60. jaclang/tests/fixtures/abc.jac +16 -12
  61. jaclang/tests/fixtures/aott_raise.jac +1 -1
  62. jaclang/tests/fixtures/byllmissue.jac +9 -0
  63. jaclang/tests/fixtures/edgetypeissue.jac +10 -0
  64. jaclang/tests/fixtures/hello.jac +1 -1
  65. jaclang/tests/fixtures/impl_match_confused.impl.jac +1 -0
  66. jaclang/tests/fixtures/impl_match_confused.jac +5 -0
  67. jaclang/tests/fixtures/maxfail_run_test.jac +17 -5
  68. jaclang/tests/fixtures/run_test.jac +17 -5
  69. jaclang/tests/test_bugs.py +19 -0
  70. jaclang/tests/test_cli.py +1 -1
  71. jaclang/tests/test_language.py +65 -100
  72. jaclang/tests/test_reference.py +1 -1
  73. jaclang/utils/lang_tools.py +5 -4
  74. jaclang/utils/test.py +2 -1
  75. jaclang/utils/treeprinter.py +22 -8
  76. {jaclang-0.7.2.dist-info → jaclang-0.7.8.dist-info}/METADATA +1 -1
  77. {jaclang-0.7.2.dist-info → jaclang-0.7.8.dist-info}/RECORD +79 -83
  78. jaclang/core/aott.py +0 -310
  79. jaclang/core/llms/__init__.py +0 -20
  80. jaclang/core/llms/anthropic.py +0 -90
  81. jaclang/core/llms/base.py +0 -206
  82. jaclang/core/llms/groq.py +0 -70
  83. jaclang/core/llms/huggingface.py +0 -76
  84. jaclang/core/llms/ollama.py +0 -81
  85. jaclang/core/llms/openai.py +0 -65
  86. jaclang/core/llms/togetherai.py +0 -63
  87. jaclang/core/llms/utils.py +0 -9
  88. jaclang/tests/fixtures/math_question.jpg +0 -0
  89. jaclang/tests/fixtures/with_llm_function.jac +0 -33
  90. jaclang/tests/fixtures/with_llm_lower.jac +0 -45
  91. jaclang/tests/fixtures/with_llm_method.jac +0 -51
  92. jaclang/tests/fixtures/with_llm_type.jac +0 -52
  93. jaclang/tests/fixtures/with_llm_vision.jac +0 -25
  94. {jaclang-0.7.2.dist-info → jaclang-0.7.8.dist-info}/WHEEL +0 -0
  95. {jaclang-0.7.2.dist-info → jaclang-0.7.8.dist-info}/entry_points.txt +0 -0
jaclang/plugin/spec.py CHANGED
@@ -3,19 +3,19 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import types
6
- from dataclasses import dataclass
7
6
  from typing import Any, Callable, Optional, TYPE_CHECKING, Type, TypeVar, Union
8
7
 
9
8
  from jaclang.compiler.absyntree import Module
10
9
 
11
10
  if TYPE_CHECKING:
12
- from jaclang.core.construct import EdgeArchitype, NodeArchitype
11
+ from jaclang.core.constructs import EdgeArchitype, NodeArchitype
13
12
  from jaclang.plugin.default import (
14
13
  Architype,
15
14
  EdgeDir,
16
15
  ExecutionContext,
17
16
  WalkerArchitype,
18
17
  Root,
18
+ DSFunc,
19
19
  )
20
20
  from jaclang.core.memory import Memory
21
21
 
@@ -26,20 +26,6 @@ hookspec = pluggy.HookspecMarker("jac")
26
26
  T = TypeVar("T")
27
27
 
28
28
 
29
- # TODO: DSFunc should be moved into jaclang/core
30
- @dataclass(eq=False)
31
- class DSFunc:
32
- """Data Spatial Function."""
33
-
34
- name: str
35
- trigger: type | types.UnionType | tuple[type | types.UnionType, ...] | None
36
- func: Callable[[Any, Any], Any] | None = None
37
-
38
- def resolve(self, cls: type) -> None:
39
- """Resolve the function."""
40
- self.func = getattr(cls, self.name)
41
-
42
-
43
29
  class JacFeatureSpec:
44
30
  """Jac Feature."""
45
31
 
@@ -113,7 +99,7 @@ class JacFeatureSpec:
113
99
  cachable: bool,
114
100
  mdl_alias: Optional[str],
115
101
  override_name: Optional[str],
116
- mod_bundle: Optional[Module],
102
+ mod_bundle: Optional[Module | str],
117
103
  lng: Optional[str],
118
104
  items: Optional[dict[str, Union[str, bool]]],
119
105
  ) -> Optional[types.ModuleType]:
@@ -167,7 +153,13 @@ class JacFeatureSpec:
167
153
  @hookspec(firstresult=True)
168
154
  def ignore(
169
155
  walker: WalkerArchitype,
170
- expr: list[NodeArchitype | EdgeArchitype] | NodeArchitype | EdgeArchitype,
156
+ expr: (
157
+ list[NodeArchitype | EdgeArchitype]
158
+ | list[NodeArchitype]
159
+ | list[EdgeArchitype]
160
+ | NodeArchitype
161
+ | EdgeArchitype
162
+ ),
171
163
  ) -> bool:
172
164
  """Jac's ignore stmt feature."""
173
165
  raise NotImplementedError
@@ -176,7 +168,13 @@ class JacFeatureSpec:
176
168
  @hookspec(firstresult=True)
177
169
  def visit_node(
178
170
  walker: WalkerArchitype,
179
- expr: list[NodeArchitype | EdgeArchitype] | NodeArchitype | EdgeArchitype,
171
+ expr: (
172
+ list[NodeArchitype | EdgeArchitype]
173
+ | list[NodeArchitype]
174
+ | list[EdgeArchitype]
175
+ | NodeArchitype
176
+ | EdgeArchitype
177
+ ),
180
178
  ) -> bool: # noqa: ANN401
181
179
  """Jac's visit stmt feature."""
182
180
  raise NotImplementedError
@@ -248,7 +246,7 @@ class JacFeatureSpec:
248
246
  @hookspec(firstresult=True)
249
247
  def build_edge(
250
248
  is_undirected: bool,
251
- conn_type: Optional[Type[EdgeArchitype]],
249
+ conn_type: Optional[Type[EdgeArchitype] | EdgeArchitype],
252
250
  conn_assign: Optional[tuple[tuple, tuple]],
253
251
  ) -> Callable[[], EdgeArchitype]:
254
252
  """Jac's root getter."""
jaclang/settings.py CHANGED
@@ -18,6 +18,9 @@ class Settings:
18
18
  py_raise: bool = False
19
19
  py_raise_deep: bool = False
20
20
 
21
+ # LSP configuration
22
+ lsp_debug: bool = False
23
+
21
24
  def __post_init__(self) -> None:
22
25
  """Initialize settings."""
23
26
  home_dir = os.path.expanduser("~")
@@ -18,9 +18,9 @@ Below we have the demonstration of a class to calculate the area of a circle.
18
18
  *#
19
19
 
20
20
  """Enum for shape types"""
21
- enum ShapeType {
22
- CIRCLE="Circle",
23
- UNKNOWN="Unknown"
21
+ enum ShapeType {
22
+ CIRCLE = "Circle",
23
+ UNKNOWN = "Unknown"
24
24
  }
25
25
 
26
26
  """Base class for a shape."""
@@ -50,24 +50,28 @@ with entry {
50
50
  # Global also works here
51
51
 
52
52
  with entry:__main__ {
53
- # To run the program functionality
54
- print(f"Area of a circle with radius {RAD} using function: {calculate_area(RAD)}");
55
- print(f"Area of a {c.shape_type.value} with radius {RAD} using class: {c.area()}");
53
+ # To run the program functionality
54
+ print(
55
+ f"Area of a circle with radius {RAD} using function: {calculate_area(RAD)}"
56
+ );
57
+ print(
58
+ f"Area of a {c.shape_type.value} with radius {RAD} using class: {c.area()}"
59
+ );
56
60
  }
57
61
  # Unit Tests!
58
62
 
59
63
  glob expected_area = 78.53981633974483;
60
64
 
61
- test calc_area {
62
- check.assertAlmostEqual(calculate_area(RAD), expected_area);
65
+ test calc_area {
66
+ check assertAlmostEqual(calculate_area(RAD), expected_area);
63
67
  }
64
68
 
65
- test circle_area {
69
+ test circle_area {
66
70
  c = Circle(RAD);
67
- check.assertAlmostEqual(c.area(), expected_area);
71
+ check assertAlmostEqual(c.area(), expected_area);
68
72
  }
69
73
 
70
- test circle_type {
74
+ test circle_type {
71
75
  c = Circle(RAD);
72
- check.assertEqual(c.shape_type, ShapeType.CIRCLE);
76
+ check assertEqual(c.shape_type, ShapeType.CIRCLE);
73
77
  }
@@ -1,4 +1,4 @@
1
- import:py from jaclang.core.llms, BaseLLM;
1
+ import:py from mtllm.llms.base, BaseLLM;
2
2
 
3
3
  obj model:BaseLLM: {
4
4
  can __infer__(meaning_in: str, **kwargs: dict) {
@@ -1,3 +1,12 @@
1
+ class Foo {
2
+ '''
3
+ a doc string
4
+ '''
5
+ can bar() {
6
+ return 1;
7
+ }
8
+ }
9
+
1
10
  with entry {
2
11
  my_thing = YourThing(level=thingy by llm());
3
12
  }
@@ -0,0 +1,10 @@
1
+ node x {}
2
+
3
+ edge e {
4
+ has name: str;
5
+ }
6
+
7
+ with entry {
8
+ nodes = root +:e(name="hello"):+> x();
9
+ print(nodes);
10
+ }
@@ -2,4 +2,4 @@
2
2
 
3
3
  with entry {
4
4
  "Hello World!" |> print;
5
- }
5
+ }
@@ -0,0 +1 @@
1
+ :walker:gen_outline:can:get_highlights {}
@@ -0,0 +1,5 @@
1
+ walker get_highlights {}
2
+
3
+ walker gen_outline {
4
+ can get_highlights_and_documents with project entry;
5
+ }
@@ -1,5 +1,17 @@
1
- glob x = 5,y=2;
2
- test a{ check.assertAlmostEqual(5,x); }
3
- test b{check.assertIn("l","llm");}
4
- test c{ check.assertEqual(x-y, 3); }
5
- test d{ check.assertEqual(1, 2); }
1
+ glob x = 5, y = 2;
2
+
3
+ test a {
4
+ check assertAlmostEqual(5, x);
5
+ }
6
+
7
+ test b {
8
+ check assertIn("l", "llm");
9
+ }
10
+
11
+ test c {
12
+ check assertEqual(x - y, 3);
13
+ }
14
+
15
+ test d {
16
+ check assertEqual(1, 2);
17
+ }
@@ -1,5 +1,17 @@
1
- glob a = 5,b=2;
2
- test t1{ check.assertAlmostEqual(a, 6); }
3
- test t2{ check.assertTrue(a!=b); }
4
- test t3{check.assertIn("d","abc");}
5
- test t4{ check.assertEqual(a-b, 3); }
1
+ glob a = 5, b = 2;
2
+
3
+ test t1 {
4
+ check assertAlmostEqual(a, 6);
5
+ }
6
+
7
+ test t2 {
8
+ check assertTrue(a != b);
9
+ }
10
+
11
+ test t3 {
12
+ check assertIn("d", "abc");
13
+ }
14
+
15
+ test t4 {
16
+ check assertEqual(a - b, 3);
17
+ }
@@ -0,0 +1,19 @@
1
+ """Test Jac language generally."""
2
+
3
+ from jaclang.compiler.compile import jac_file_to_pass
4
+ from jaclang.utils.test import TestCase
5
+
6
+
7
+ class JacBugTests(TestCase):
8
+ """Test pass module."""
9
+
10
+ def setUp(self) -> None:
11
+ """Set up test."""
12
+ return super().setUp()
13
+
14
+ def test_impl_match_confusion_issue(self) -> None:
15
+ """Basic test for symtable support for inheritance."""
16
+ mypass = jac_file_to_pass(
17
+ self.fixture_abs_path("impl_match_confused.jac"),
18
+ )
19
+ self.assertEqual(len(mypass.errors_had), 1)
jaclang/tests/test_cli.py CHANGED
@@ -112,7 +112,7 @@ class JacCliTests(TestCase):
112
112
  cli.tool("ir", ["ast", f"{self.fixture_abs_path('type_info.jac')}"])
113
113
  sys.stdout = sys.__stdout__
114
114
  stdout_value = captured_output.getvalue()
115
- self.assertEqual(stdout_value.count("type_info.ServerWrapper"), 6)
115
+ self.assertEqual(stdout_value.count("type_info.ServerWrapper"), 7)
116
116
  self.assertEqual(stdout_value.count("builtins.int"), 2)
117
117
  self.assertEqual(stdout_value.count("builtins.str"), 7)
118
118
 
@@ -7,9 +7,11 @@ import sys
7
7
  import sysconfig
8
8
 
9
9
 
10
+ import jaclang.compiler.passes.main as passes
10
11
  from jaclang import jac_import
11
12
  from jaclang.cli import cli
12
13
  from jaclang.compiler.compile import jac_file_to_pass, jac_pass_to_pass, jac_str_to_pass
14
+ from jaclang.compiler.passes.main.schedules import py_code_gen_typed
13
15
  from jaclang.plugin.feature import JacFeature as Jac
14
16
  from jaclang.settings import settings
15
17
  from jaclang.utils.test import TestCase
@@ -110,105 +112,6 @@ class JacLanguageTests(TestCase):
110
112
  "{'a': 'apple', 'b': 'ball', 'c': 'cat', 'd': 'dog', 'e': 'elephant'}\n",
111
113
  )
112
114
 
113
- def test_with_llm_function(self) -> None:
114
- """Parse micro jac file."""
115
- captured_output = io.StringIO()
116
- sys.stdout = captured_output
117
- jac_import("with_llm_function", base_path=self.fixture_abs_path("./"))
118
- sys.stdout = sys.__stdout__
119
- stdout_value = captured_output.getvalue()
120
- self.assertIn("{'temperature': 0.7}", stdout_value)
121
- self.assertIn("Emoji Representation (str)", stdout_value)
122
- self.assertIn('Text Input (input) (str) = "Lets move to paris"', stdout_value)
123
- self.assertIn(
124
- ' = [{"input": "I love tp drink pina coladas"',
125
- stdout_value,
126
- )
127
-
128
- def test_with_llm_method(self) -> None:
129
- """Parse micro jac file."""
130
- captured_output = io.StringIO()
131
- sys.stdout = captured_output
132
- jac_import("with_llm_method", base_path=self.fixture_abs_path("./"))
133
- sys.stdout = sys.__stdout__
134
- stdout_value = captured_output.getvalue()
135
- self.assertIn("[Reasoning] <Reason>", stdout_value)
136
- self.assertIn("(Enum) eg:- Personality.EXTROVERT ->", stdout_value)
137
- self.assertIn(
138
- "Personality Index of a Person (PersonalityIndex) (class) eg:- "
139
- "PersonalityIndex(index=int) -> Personality Index (index) (int)",
140
- stdout_value,
141
- )
142
- self.assertIn(
143
- "Personality of the Person (dict[Personality,PersonalityIndex])",
144
- stdout_value,
145
- )
146
- self.assertIn(
147
- 'Diary Entries (diary_entries) (list[str]) = ["I won noble prize in '
148
- 'Physics", "I am popular for my theory of relativity"]',
149
- stdout_value,
150
- )
151
-
152
- def test_with_llm_lower(self) -> None:
153
- """Parse micro jac file."""
154
- captured_output = io.StringIO()
155
- sys.stdout = captured_output
156
- jac_import("with_llm_lower", base_path=self.fixture_abs_path("./"))
157
- sys.stdout = sys.__stdout__
158
- stdout_value = captured_output.getvalue()
159
- self.assertIn("[Reasoning] <Reason>", stdout_value)
160
- self.assertIn(
161
- 'Name of the Person (name) (str) = "Oppenheimer"',
162
- stdout_value,
163
- )
164
- self.assertIn(
165
- "Person (Person) (obj) eg:- Person(full_name=str, yod=int, personality"
166
- "=Personality) -> Fullname of the Person (full_name) (str), Year of Death"
167
- " (yod) (int), Personality of the Person (personality) (Personality)",
168
- stdout_value,
169
- )
170
- self.assertIn(
171
- "J. Robert Oppenheimer was a Introvert person who died in 1967",
172
- stdout_value,
173
- )
174
-
175
- def test_with_llm_type(self) -> None:
176
- """Parse micro jac file."""
177
- captured_output = io.StringIO()
178
- sys.stdout = captured_output
179
- jac_import("with_llm_type", base_path=self.fixture_abs_path("./"))
180
- sys.stdout = sys.__stdout__
181
- stdout_value = captured_output.getvalue()
182
- self.assertIn("14/03/1879", stdout_value)
183
- self.assertNotIn(
184
- 'University (University) (obj) = type(__module__="with_llm_type", __doc__=None, '
185
- "_jac_entry_funcs_`=[`], _jac_exit_funcs_=[], __init__=function(__wrapped__=function()))",
186
- stdout_value,
187
- )
188
- desired_output_count = stdout_value.count(
189
- "Person(name='Jason Mars', dob='1994-01-01', age=30)"
190
- )
191
- self.assertEqual(desired_output_count, 2)
192
-
193
- def test_with_llm_vision(self) -> None:
194
- """Test MTLLLM Vision Implementation."""
195
- try:
196
- captured_output = io.StringIO()
197
- sys.stdout = captured_output
198
- jac_import("with_llm_vision", base_path=self.fixture_abs_path("./"))
199
- sys.stdout = sys.__stdout__
200
- stdout_value = captured_output.getvalue()
201
- self.assertIn(
202
- "{'type': 'text', 'text': '\\n[System Prompt]\\n", stdout_value[:500]
203
- )
204
- self.assertNotIn(
205
- " {'type': 'text', 'text': 'Image of the Question (question_img) (Image) = '}, "
206
- "{'type': 'image_url', 'image_url': {'url': 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQAB",
207
- stdout_value[:500],
208
- )
209
- except Exception:
210
- self.skipTest("This test requires Pillow to be installed.")
211
-
212
115
  def test_ignore(self) -> None:
213
116
  """Parse micro jac file."""
214
117
  Jac.get_root()._jac_.edges.clear()
@@ -857,7 +760,18 @@ class JacLanguageTests(TestCase):
857
760
  """Test conn assign on edges."""
858
761
  Jac.get_root()._jac_.edges.clear()
859
762
  mypass = jac_file_to_pass(
860
- self.fixture_abs_path("../../../examples/micro/simple_walk.jac")
763
+ self.fixture_abs_path("../../../examples/micro/simple_walk.jac"),
764
+ schedule=py_code_gen_typed,
765
+ )
766
+ self.assertEqual(len(mypass.errors_had), 0)
767
+ self.assertEqual(len(mypass.warnings_had), 0)
768
+
769
+ def test_ds_type_check_pass2(self) -> None:
770
+ """Test conn assign on edges."""
771
+ Jac.get_root()._jac_.edges.clear()
772
+ mypass = jac_file_to_pass(
773
+ self.fixture_abs_path("../../../examples/guess_game/guess_game5.jac"),
774
+ schedule=py_code_gen_typed,
861
775
  )
862
776
  self.assertEqual(len(mypass.errors_had), 0)
863
777
  self.assertEqual(len(mypass.warnings_had), 0)
@@ -879,3 +793,54 @@ class JacLanguageTests(TestCase):
879
793
  sys.stdout = sys.__stdout__
880
794
  stdout_value = captured_output.getvalue()
881
795
  self.assertIn("Test Passed", stdout_value)
796
+
797
+ def test_multiline_single_tok(self) -> None:
798
+ """Test conn assign on edges."""
799
+ Jac.get_root()._jac_.edges.clear()
800
+ mypass = jac_file_to_pass(self.fixture_abs_path("byllmissue.jac"))
801
+ self.assertIn("2:5 - 4:8", mypass.ir.pp())
802
+
803
+ def test_single_impl_annex(self) -> None:
804
+ """Basic test for pass."""
805
+ mypass = jac_file_to_pass(
806
+ self.fixture_abs_path("../../../examples/manual_code/circle_pure.jac"),
807
+ target=passes.JacImportPass,
808
+ )
809
+
810
+ self.assertEqual(mypass.ir.pp().count("AbilityDef - (o)Circle.(c)area"), 1)
811
+ self.assertIsNone(mypass.ir._sym_tab)
812
+ mypass = jac_file_to_pass(
813
+ self.fixture_abs_path("../../../examples/manual_code/circle_pure.jac"),
814
+ target=passes.SymTabBuildPass,
815
+ )
816
+ self.assertEqual(
817
+ len([i for i in mypass.ir.sym_tab.kid if i.name == "circle_pure.impl"]),
818
+ 1,
819
+ )
820
+
821
+ def test_inherit_baseclass_sym(self) -> None:
822
+ """Basic test for symtable support for inheritance."""
823
+ mypass = jac_file_to_pass(
824
+ self.fixture_abs_path("../../../examples/guess_game/guess_game4.jac"),
825
+ target=passes.DefUsePass,
826
+ )
827
+ table = None
828
+ for i in mypass.ir.sym_tab.kid:
829
+ print(i.name)
830
+ if i.name == "GuessTheNumberGame":
831
+ for j in i.kid:
832
+ if j.name == "play":
833
+ table = j
834
+ break
835
+ break
836
+ self.assertIsNotNone(table)
837
+ self.assertIsNotNone(table.lookup("attempts"))
838
+
839
+ def test_edge_expr_not_type(self) -> None:
840
+ """Test importing python."""
841
+ captured_output = io.StringIO()
842
+ sys.stdout = captured_output
843
+ jac_import("edgetypeissue", base_path=self.fixture_abs_path("./"))
844
+ sys.stdout = sys.__stdout__
845
+ stdout_value = captured_output.getvalue()
846
+ self.assertIn("[x()]", stdout_value)
@@ -66,7 +66,7 @@ class JacReferenceTests(TestCase):
66
66
  return f.getvalue()
67
67
 
68
68
  try:
69
- if "tests.jac" in filename:
69
+ if "tests.jac" in filename or "check_statements.jac" in filename:
70
70
  return
71
71
  jacast = jac_file_to_pass(filename).ir
72
72
  code_content = compile(
@@ -9,6 +9,7 @@ from typing import List, Optional, Type
9
9
  import jaclang.compiler.absyntree as ast
10
10
  from jaclang.compiler.compile import jac_file_to_pass
11
11
  from jaclang.compiler.passes.main.pyast_load_pass import PyastBuildPass
12
+ from jaclang.compiler.passes.main.schedules import py_code_gen, type_checker_sched
12
13
  from jaclang.compiler.passes.main.schedules import py_code_gen_typed
13
14
  from jaclang.compiler.symtable import SymbolTable
14
15
  from jaclang.utils.helpers import auto_generate_refs, pascal_to_snake
@@ -81,8 +82,8 @@ class AstTool:
81
82
  "JacSource",
82
83
  "EmptyToken",
83
84
  "AstSymbolNode",
85
+ "AstSymbolStubNode",
84
86
  "AstAccessNode",
85
- "TokenSymbol",
86
87
  "Literal",
87
88
  "AstDocNode",
88
89
  "AstSemStrNode",
@@ -97,7 +98,7 @@ class AstTool:
97
98
  "ArchBlockStmt",
98
99
  "EnumBlockStmt",
99
100
  "CodeBlockStmt",
100
- "NameSpec",
101
+ "NameAtom",
101
102
  "ArchSpec",
102
103
  "MatchPattern",
103
104
  ]
@@ -234,8 +235,8 @@ class AstTool:
234
235
  return f"Error While Jac to Py AST conversion: {e}"
235
236
  else:
236
237
  ir = jac_file_to_pass(
237
- file_name, schedule=py_code_gen_typed
238
- ).ir # Assuming jac_file_to_pass is defined elsewhere
238
+ file_name, schedule=[*(py_code_gen[:-1]), *type_checker_sched]
239
+ ).ir
239
240
 
240
241
  match output:
241
242
  case "sym":
jaclang/utils/test.py CHANGED
@@ -107,6 +107,7 @@ class AstSyncTestMixin:
107
107
  "jac_source",
108
108
  "empty_token",
109
109
  "ast_symbol_node",
110
+ "ast_symbol_stub_node",
110
111
  "ast_impl_needing_node",
111
112
  "ast_access_node",
112
113
  "token_symbol",
@@ -124,7 +125,7 @@ class AstSyncTestMixin:
124
125
  "arch_block_stmt",
125
126
  "enum_block_stmt",
126
127
  "code_block_stmt",
127
- "name_spec",
128
+ "name_atom",
128
129
  "arch_spec",
129
130
  "match_pattern",
130
131
  ]
@@ -96,17 +96,20 @@ def print_ast_tree(
96
96
  else ""
97
97
  )
98
98
  sym_table_link = (
99
- f"SymbolTable: {node.sym_info.typ_sym_table.name}"
100
- if isinstance(node, AstSymbolNode) and node.sym_info.typ_sym_table
99
+ f"SymbolTable: {node.type_sym_tab.name}"
100
+ if isinstance(node, AstSymbolNode) and node.type_sym_tab
101
101
  else "SymbolTable: None" if isinstance(node, AstSymbolNode) else ""
102
102
  )
103
103
 
104
104
  if isinstance(node, Token) and isinstance(node, AstSymbolNode):
105
- out = f"{node.__class__.__name__} - {node.value} - Type: {node.sym_info.typ}, {access} {sym_table_link}"
105
+ out = (
106
+ f"{node.__class__.__name__} - {node.value} - "
107
+ f"Type: {node.sym_type}, {access} {sym_table_link}"
108
+ )
106
109
  if settings.ast_symbol_info_detailed:
107
110
  symbol = (
108
- node.sym_link.sym_path_str
109
- if node.sym_link
111
+ node.sym.sym_dotted_name
112
+ if node.sym
110
113
  else "<No Symbol is associated with this node>"
111
114
  )
112
115
  out += f" SymbolPath: {symbol}"
@@ -114,11 +117,14 @@ def print_ast_tree(
114
117
  elif isinstance(node, Token):
115
118
  return f"{node.__class__.__name__} - {node.value}, {access}"
116
119
  elif isinstance(node, AstSymbolNode):
117
- out = f"{node.__class__.__name__} - {node.sym_name} - Type: {node.sym_info.typ}, {access} {sym_table_link}"
120
+ out = (
121
+ f"{node.__class__.__name__} - {node.sym_name} - "
122
+ f"Type: {node.sym_type}, {access} {sym_table_link}"
123
+ )
118
124
  if settings.ast_symbol_info_detailed:
119
125
  symbol = (
120
- node.sym_link.sym_path_str
121
- if node.sym_link
126
+ node.sym.sym_dotted_name
127
+ if node.sym
122
128
  else "<No Symbol is associated with this node>"
123
129
  )
124
130
  out += f" SymbolPath: {symbol}"
@@ -259,6 +265,14 @@ def _build_symbol_tree_common(
259
265
  )
260
266
  for n in sym.defn
261
267
  ]
268
+ uses = SymbolTree(node_name="uses", parent=symbol_node)
269
+ [
270
+ SymbolTree(
271
+ node_name=f"line {n.loc.first_line}, col {n.loc.col_start}",
272
+ parent=uses,
273
+ )
274
+ for n in sym.uses
275
+ ]
262
276
 
263
277
  for k in node.kid:
264
278
  _build_symbol_tree_common(k, children)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaclang
3
- Version: 0.7.2
3
+ Version: 0.7.8
4
4
  Summary: Jac is a unique and powerful programming language that runs on top of Python, offering an unprecedented level of intelligence and intuitive understanding.
5
5
  Home-page: https://jaseci.org
6
6
  License: MIT