jaclang 0.7.2__py3-none-any.whl → 0.7.6__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 (92) hide show
  1. jaclang/cli/cli.py +2 -2
  2. jaclang/compiler/absyntree.py +499 -294
  3. jaclang/compiler/codeloc.py +2 -2
  4. jaclang/compiler/constant.py +100 -2
  5. jaclang/compiler/jac.lark +27 -19
  6. jaclang/compiler/parser.py +119 -92
  7. jaclang/compiler/passes/main/access_modifier_pass.py +20 -12
  8. jaclang/compiler/passes/main/def_impl_match_pass.py +28 -14
  9. jaclang/compiler/passes/main/def_use_pass.py +59 -40
  10. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +65 -43
  11. jaclang/compiler/passes/main/import_pass.py +8 -6
  12. jaclang/compiler/passes/main/pyast_gen_pass.py +97 -42
  13. jaclang/compiler/passes/main/pyast_load_pass.py +47 -12
  14. jaclang/compiler/passes/main/pyjac_ast_link_pass.py +19 -10
  15. jaclang/compiler/passes/main/registry_pass.py +6 -6
  16. jaclang/compiler/passes/main/sub_node_tab_pass.py +0 -5
  17. jaclang/compiler/passes/main/sym_tab_build_pass.py +43 -235
  18. jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +21 -4
  19. jaclang/compiler/passes/main/tests/test_def_use_pass.py +5 -10
  20. jaclang/compiler/passes/main/type_check_pass.py +2 -1
  21. jaclang/compiler/passes/tool/jac_formatter_pass.py +30 -9
  22. jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +16 -0
  23. jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +16 -0
  24. jaclang/compiler/passes/tool/tests/fixtures/genai/essay_review.jac +1 -1
  25. jaclang/compiler/passes/tool/tests/fixtures/genai/expert_answer.jac +1 -1
  26. jaclang/compiler/passes/tool/tests/fixtures/genai/joke_gen.jac +1 -1
  27. jaclang/compiler/passes/tool/tests/fixtures/genai/odd_word_out.jac +1 -1
  28. jaclang/compiler/passes/tool/tests/fixtures/genai/personality_finder.jac +1 -1
  29. jaclang/compiler/passes/tool/tests/fixtures/genai/text_to_type.jac +1 -1
  30. jaclang/compiler/passes/tool/tests/fixtures/genai/translator.jac +1 -1
  31. jaclang/compiler/passes/tool/tests/fixtures/genai/wikipedia.jac +1 -1
  32. jaclang/compiler/passes/transform.py +2 -4
  33. jaclang/{core/registry.py → compiler/semtable.py} +1 -3
  34. jaclang/compiler/symtable.py +142 -101
  35. jaclang/compiler/tests/test_parser.py +2 -2
  36. jaclang/core/aott.py +15 -11
  37. jaclang/core/{construct.py → architype.py} +25 -240
  38. jaclang/core/constructs.py +44 -0
  39. jaclang/core/context.py +157 -0
  40. jaclang/core/importer.py +18 -9
  41. jaclang/core/memory.py +99 -0
  42. jaclang/core/test.py +90 -0
  43. jaclang/core/utils.py +2 -2
  44. jaclang/langserve/engine.py +127 -50
  45. jaclang/langserve/server.py +34 -61
  46. jaclang/langserve/tests/fixtures/base_module_structure.jac +28 -0
  47. jaclang/langserve/tests/fixtures/circle.jac +16 -12
  48. jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
  49. jaclang/langserve/tests/fixtures/circle_pure.test.jac +15 -0
  50. jaclang/langserve/tests/fixtures/import_include_statements.jac +6 -0
  51. jaclang/langserve/tests/fixtures/py_import.py +26 -0
  52. jaclang/langserve/tests/test_server.py +93 -18
  53. jaclang/langserve/utils.py +124 -10
  54. jaclang/plugin/builtin.py +1 -1
  55. jaclang/plugin/default.py +23 -9
  56. jaclang/plugin/feature.py +25 -7
  57. jaclang/plugin/spec.py +18 -20
  58. jaclang/settings.py +3 -0
  59. jaclang/tests/fixtures/abc.jac +16 -12
  60. jaclang/tests/fixtures/aott_raise.jac +1 -1
  61. jaclang/tests/fixtures/byllmissue.jac +9 -0
  62. jaclang/tests/fixtures/edgetypeissue.jac +10 -0
  63. jaclang/tests/fixtures/hello.jac +1 -1
  64. jaclang/tests/fixtures/impl_match_confused.impl.jac +1 -0
  65. jaclang/tests/fixtures/impl_match_confused.jac +5 -0
  66. jaclang/tests/fixtures/maxfail_run_test.jac +17 -5
  67. jaclang/tests/fixtures/run_test.jac +17 -5
  68. jaclang/tests/fixtures/with_llm_function.jac +1 -1
  69. jaclang/tests/fixtures/with_llm_lower.jac +1 -1
  70. jaclang/tests/fixtures/with_llm_method.jac +1 -1
  71. jaclang/tests/fixtures/with_llm_type.jac +1 -1
  72. jaclang/tests/fixtures/with_llm_vision.jac +1 -1
  73. jaclang/tests/test_bugs.py +19 -0
  74. jaclang/tests/test_cli.py +1 -1
  75. jaclang/tests/test_language.py +161 -96
  76. jaclang/tests/test_reference.py +1 -1
  77. jaclang/utils/lang_tools.py +5 -4
  78. jaclang/utils/test.py +2 -1
  79. jaclang/utils/treeprinter.py +22 -8
  80. {jaclang-0.7.2.dist-info → jaclang-0.7.6.dist-info}/METADATA +1 -1
  81. {jaclang-0.7.2.dist-info → jaclang-0.7.6.dist-info}/RECORD +83 -80
  82. jaclang/core/llms/__init__.py +0 -20
  83. jaclang/core/llms/anthropic.py +0 -90
  84. jaclang/core/llms/base.py +0 -206
  85. jaclang/core/llms/groq.py +0 -70
  86. jaclang/core/llms/huggingface.py +0 -76
  87. jaclang/core/llms/ollama.py +0 -81
  88. jaclang/core/llms/openai.py +0 -65
  89. jaclang/core/llms/togetherai.py +0 -63
  90. jaclang/core/llms/utils.py +0 -9
  91. {jaclang-0.7.2.dist-info → jaclang-0.7.6.dist-info}/WHEEL +0 -0
  92. {jaclang-0.7.2.dist-info → jaclang-0.7.6.dist-info}/entry_points.txt +0 -0
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
+ }
@@ -1,4 +1,4 @@
1
- import:py from jaclang.core.llms, BaseLLM;
1
+ import:py from mtllm.llms, BaseLLM;
2
2
 
3
3
  obj model:BaseLLM: {
4
4
  can init {
@@ -1,4 +1,4 @@
1
- import:py from jaclang.core.llms, BaseLLM;
1
+ import:py from mtllm.llms, BaseLLM;
2
2
 
3
3
  obj model:BaseLLM: {
4
4
  can init {
@@ -1,4 +1,4 @@
1
- import:py from jaclang.core.llms, BaseLLM;
1
+ import:py from mtllm.llms, BaseLLM;
2
2
 
3
3
  obj model:BaseLLM: {
4
4
  can init {
@@ -1,4 +1,4 @@
1
- import:py from jaclang.core.llms, BaseLLM;
1
+ import:py from mtllm.llms, BaseLLM;
2
2
 
3
3
  obj model:BaseLLM: {
4
4
  can init(output_str: str) {
@@ -1,4 +1,4 @@
1
- import:py from jaclang.core.llms, BaseLLM;
1
+ import:py from mtllm.llms, BaseLLM;
2
2
  import:py from PIL, Image;
3
3
  import:py os;
4
4
 
@@ -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,104 +112,105 @@ 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
- )
115
+ # TODO: Move these tests to mtllm repo
116
+ # def test_with_llm_function(self) -> None:
117
+ # """Parse micro jac file."""
118
+ # captured_output = io.StringIO()
119
+ # sys.stdout = captured_output
120
+ # jac_import("with_llm_function", base_path=self.fixture_abs_path("./"))
121
+ # sys.stdout = sys.__stdout__
122
+ # stdout_value = captured_output.getvalue()
123
+ # self.assertIn("{'temperature': 0.7}", stdout_value)
124
+ # self.assertIn("Emoji Representation (str)", stdout_value)
125
+ # self.assertIn('Text Input (input) (str) = "Lets move to paris"', stdout_value)
126
+ # self.assertIn(
127
+ # ' = [{"input": "I love tp drink pina coladas"',
128
+ # stdout_value,
129
+ # )
127
130
 
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
- )
131
+ # def test_with_llm_method(self) -> None:
132
+ # """Parse micro jac file."""
133
+ # captured_output = io.StringIO()
134
+ # sys.stdout = captured_output
135
+ # jac_import("with_llm_method", base_path=self.fixture_abs_path("./"))
136
+ # sys.stdout = sys.__stdout__
137
+ # stdout_value = captured_output.getvalue()
138
+ # self.assertIn("[Reasoning] <Reason>", stdout_value)
139
+ # self.assertIn("(Enum) eg:- Personality.EXTROVERT ->", stdout_value)
140
+ # self.assertIn(
141
+ # "Personality Index of a Person (PersonalityIndex) (class) eg:- "
142
+ # "PersonalityIndex(index=int) -> Personality Index (index) (int)",
143
+ # stdout_value,
144
+ # )
145
+ # self.assertIn(
146
+ # "Personality of the Person (dict[Personality,PersonalityIndex])",
147
+ # stdout_value,
148
+ # )
149
+ # self.assertIn(
150
+ # 'Diary Entries (diary_entries) (list[str]) = ["I won noble prize in '
151
+ # 'Physics", "I am popular for my theory of relativity"]',
152
+ # stdout_value,
153
+ # )
151
154
 
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
- )
155
+ # def test_with_llm_lower(self) -> None:
156
+ # """Parse micro jac file."""
157
+ # captured_output = io.StringIO()
158
+ # sys.stdout = captured_output
159
+ # jac_import("with_llm_lower", base_path=self.fixture_abs_path("./"))
160
+ # sys.stdout = sys.__stdout__
161
+ # stdout_value = captured_output.getvalue()
162
+ # self.assertIn("[Reasoning] <Reason>", stdout_value)
163
+ # self.assertIn(
164
+ # 'Name of the Person (name) (str) = "Oppenheimer"',
165
+ # stdout_value,
166
+ # )
167
+ # self.assertIn(
168
+ # "Person (Person) (obj) eg:- Person(full_name=str, yod=int, personality"
169
+ # "=Personality) -> Fullname of the Person (full_name) (str), Year of Death"
170
+ # " (yod) (int), Personality of the Person (personality) (Personality)",
171
+ # stdout_value,
172
+ # )
173
+ # self.assertIn(
174
+ # "J. Robert Oppenheimer was a Introvert person who died in 1967",
175
+ # stdout_value,
176
+ # )
174
177
 
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.")
178
+ # def test_with_llm_type(self) -> None:
179
+ # """Parse micro jac file."""
180
+ # captured_output = io.StringIO()
181
+ # sys.stdout = captured_output
182
+ # jac_import("with_llm_type", base_path=self.fixture_abs_path("./"))
183
+ # sys.stdout = sys.__stdout__
184
+ # stdout_value = captured_output.getvalue()
185
+ # self.assertIn("14/03/1879", stdout_value)
186
+ # self.assertNotIn(
187
+ # 'University (University) (obj) = type(__module__="with_llm_type", __doc__=None, '
188
+ # "_jac_entry_funcs_`=[`], _jac_exit_funcs_=[], __init__=function(__wrapped__=function()))",
189
+ # stdout_value,
190
+ # )
191
+ # desired_output_count = stdout_value.count(
192
+ # "Person(name='Jason Mars', dob='1994-01-01', age=30)"
193
+ # )
194
+ # self.assertEqual(desired_output_count, 2)
195
+
196
+ # def test_with_llm_vision(self) -> None:
197
+ # """Test MTLLLM Vision Implementation."""
198
+ # try:
199
+ # captured_output = io.StringIO()
200
+ # sys.stdout = captured_output
201
+ # jac_import("with_llm_vision", base_path=self.fixture_abs_path("./"))
202
+ # sys.stdout = sys.__stdout__
203
+ # stdout_value = captured_output.getvalue()
204
+ # self.assertIn(
205
+ # "{'type': 'text', 'text': '\\n[System Prompt]\\n", stdout_value[:500]
206
+ # )
207
+ # self.assertNotIn(
208
+ # " {'type': 'text', 'text': 'Image of the Question (question_img) (Image) = '}, "
209
+ # "{'type': 'image_url', 'image_url': {'url': 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQAB",
210
+ # stdout_value[:500],
211
+ # )
212
+ # except Exception:
213
+ # self.skipTest("This test requires Pillow to be installed.")
211
214
 
212
215
  def test_ignore(self) -> None:
213
216
  """Parse micro jac file."""
@@ -857,7 +860,18 @@ class JacLanguageTests(TestCase):
857
860
  """Test conn assign on edges."""
858
861
  Jac.get_root()._jac_.edges.clear()
859
862
  mypass = jac_file_to_pass(
860
- self.fixture_abs_path("../../../examples/micro/simple_walk.jac")
863
+ self.fixture_abs_path("../../../examples/micro/simple_walk.jac"),
864
+ schedule=py_code_gen_typed,
865
+ )
866
+ self.assertEqual(len(mypass.errors_had), 0)
867
+ self.assertEqual(len(mypass.warnings_had), 0)
868
+
869
+ def test_ds_type_check_pass2(self) -> None:
870
+ """Test conn assign on edges."""
871
+ Jac.get_root()._jac_.edges.clear()
872
+ mypass = jac_file_to_pass(
873
+ self.fixture_abs_path("../../../examples/guess_game/guess_game5.jac"),
874
+ schedule=py_code_gen_typed,
861
875
  )
862
876
  self.assertEqual(len(mypass.errors_had), 0)
863
877
  self.assertEqual(len(mypass.warnings_had), 0)
@@ -879,3 +893,54 @@ class JacLanguageTests(TestCase):
879
893
  sys.stdout = sys.__stdout__
880
894
  stdout_value = captured_output.getvalue()
881
895
  self.assertIn("Test Passed", stdout_value)
896
+
897
+ def test_multiline_single_tok(self) -> None:
898
+ """Test conn assign on edges."""
899
+ Jac.get_root()._jac_.edges.clear()
900
+ mypass = jac_file_to_pass(self.fixture_abs_path("byllmissue.jac"))
901
+ self.assertIn("2:5 - 4:8", mypass.ir.pp())
902
+
903
+ def test_single_impl_annex(self) -> None:
904
+ """Basic test for pass."""
905
+ mypass = jac_file_to_pass(
906
+ self.fixture_abs_path("../../../examples/manual_code/circle_pure.jac"),
907
+ target=passes.JacImportPass,
908
+ )
909
+
910
+ self.assertEqual(mypass.ir.pp().count("AbilityDef - (o)Circle.(c)area"), 1)
911
+ self.assertIsNone(mypass.ir._sym_tab)
912
+ mypass = jac_file_to_pass(
913
+ self.fixture_abs_path("../../../examples/manual_code/circle_pure.jac"),
914
+ target=passes.SymTabBuildPass,
915
+ )
916
+ self.assertEqual(
917
+ len([i for i in mypass.ir.sym_tab.kid if i.name == "circle_pure.impl"]),
918
+ 1,
919
+ )
920
+
921
+ def test_inherit_baseclass_sym(self) -> None:
922
+ """Basic test for symtable support for inheritance."""
923
+ mypass = jac_file_to_pass(
924
+ self.fixture_abs_path("../../../examples/guess_game/guess_game4.jac"),
925
+ target=passes.DefUsePass,
926
+ )
927
+ table = None
928
+ for i in mypass.ir.sym_tab.kid:
929
+ print(i.name)
930
+ if i.name == "GuessTheNumberGame":
931
+ for j in i.kid:
932
+ if j.name == "play":
933
+ table = j
934
+ break
935
+ break
936
+ self.assertIsNotNone(table)
937
+ self.assertIsNotNone(table.lookup("attempts"))
938
+
939
+ def test_edge_expr_not_type(self) -> None:
940
+ """Test importing python."""
941
+ captured_output = io.StringIO()
942
+ sys.stdout = captured_output
943
+ jac_import("edgetypeissue", base_path=self.fixture_abs_path("./"))
944
+ sys.stdout = sys.__stdout__
945
+ stdout_value = captured_output.getvalue()
946
+ 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.6
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