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.
- jaclang/cli/cli.py +2 -2
- jaclang/compiler/absyntree.py +499 -294
- jaclang/compiler/codeloc.py +2 -2
- jaclang/compiler/constant.py +100 -2
- jaclang/compiler/jac.lark +27 -19
- jaclang/compiler/parser.py +119 -92
- jaclang/compiler/passes/main/access_modifier_pass.py +20 -12
- jaclang/compiler/passes/main/def_impl_match_pass.py +28 -14
- jaclang/compiler/passes/main/def_use_pass.py +59 -40
- jaclang/compiler/passes/main/fuse_typeinfo_pass.py +65 -43
- jaclang/compiler/passes/main/import_pass.py +8 -6
- jaclang/compiler/passes/main/pyast_gen_pass.py +97 -42
- jaclang/compiler/passes/main/pyast_load_pass.py +47 -12
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +19 -10
- jaclang/compiler/passes/main/registry_pass.py +6 -6
- jaclang/compiler/passes/main/sub_node_tab_pass.py +0 -5
- jaclang/compiler/passes/main/sym_tab_build_pass.py +43 -235
- jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +21 -4
- jaclang/compiler/passes/main/tests/test_def_use_pass.py +5 -10
- jaclang/compiler/passes/main/type_check_pass.py +2 -1
- jaclang/compiler/passes/tool/jac_formatter_pass.py +30 -9
- jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +16 -0
- jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +16 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/essay_review.jac +1 -1
- jaclang/compiler/passes/tool/tests/fixtures/genai/expert_answer.jac +1 -1
- jaclang/compiler/passes/tool/tests/fixtures/genai/joke_gen.jac +1 -1
- jaclang/compiler/passes/tool/tests/fixtures/genai/odd_word_out.jac +1 -1
- jaclang/compiler/passes/tool/tests/fixtures/genai/personality_finder.jac +1 -1
- jaclang/compiler/passes/tool/tests/fixtures/genai/text_to_type.jac +1 -1
- jaclang/compiler/passes/tool/tests/fixtures/genai/translator.jac +1 -1
- jaclang/compiler/passes/tool/tests/fixtures/genai/wikipedia.jac +1 -1
- jaclang/compiler/passes/transform.py +2 -4
- jaclang/{core/registry.py → compiler/semtable.py} +1 -3
- jaclang/compiler/symtable.py +142 -101
- jaclang/compiler/tests/test_parser.py +2 -2
- jaclang/core/aott.py +15 -11
- jaclang/core/{construct.py → architype.py} +25 -240
- jaclang/core/constructs.py +44 -0
- jaclang/core/context.py +157 -0
- jaclang/core/importer.py +18 -9
- jaclang/core/memory.py +99 -0
- jaclang/core/test.py +90 -0
- jaclang/core/utils.py +2 -2
- jaclang/langserve/engine.py +127 -50
- jaclang/langserve/server.py +34 -61
- jaclang/langserve/tests/fixtures/base_module_structure.jac +28 -0
- jaclang/langserve/tests/fixtures/circle.jac +16 -12
- jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
- jaclang/langserve/tests/fixtures/circle_pure.test.jac +15 -0
- jaclang/langserve/tests/fixtures/import_include_statements.jac +6 -0
- jaclang/langserve/tests/fixtures/py_import.py +26 -0
- jaclang/langserve/tests/test_server.py +93 -18
- jaclang/langserve/utils.py +124 -10
- jaclang/plugin/builtin.py +1 -1
- jaclang/plugin/default.py +23 -9
- jaclang/plugin/feature.py +25 -7
- jaclang/plugin/spec.py +18 -20
- jaclang/settings.py +3 -0
- jaclang/tests/fixtures/abc.jac +16 -12
- jaclang/tests/fixtures/aott_raise.jac +1 -1
- jaclang/tests/fixtures/byllmissue.jac +9 -0
- jaclang/tests/fixtures/edgetypeissue.jac +10 -0
- jaclang/tests/fixtures/hello.jac +1 -1
- jaclang/tests/fixtures/impl_match_confused.impl.jac +1 -0
- jaclang/tests/fixtures/impl_match_confused.jac +5 -0
- jaclang/tests/fixtures/maxfail_run_test.jac +17 -5
- jaclang/tests/fixtures/run_test.jac +17 -5
- jaclang/tests/fixtures/with_llm_function.jac +1 -1
- jaclang/tests/fixtures/with_llm_lower.jac +1 -1
- jaclang/tests/fixtures/with_llm_method.jac +1 -1
- jaclang/tests/fixtures/with_llm_type.jac +1 -1
- jaclang/tests/fixtures/with_llm_vision.jac +1 -1
- jaclang/tests/test_bugs.py +19 -0
- jaclang/tests/test_cli.py +1 -1
- jaclang/tests/test_language.py +161 -96
- jaclang/tests/test_reference.py +1 -1
- jaclang/utils/lang_tools.py +5 -4
- jaclang/utils/test.py +2 -1
- jaclang/utils/treeprinter.py +22 -8
- {jaclang-0.7.2.dist-info → jaclang-0.7.6.dist-info}/METADATA +1 -1
- {jaclang-0.7.2.dist-info → jaclang-0.7.6.dist-info}/RECORD +83 -80
- jaclang/core/llms/__init__.py +0 -20
- jaclang/core/llms/anthropic.py +0 -90
- jaclang/core/llms/base.py +0 -206
- jaclang/core/llms/groq.py +0 -70
- jaclang/core/llms/huggingface.py +0 -76
- jaclang/core/llms/ollama.py +0 -81
- jaclang/core/llms/openai.py +0 -65
- jaclang/core/llms/togetherai.py +0 -63
- jaclang/core/llms/utils.py +0 -9
- {jaclang-0.7.2.dist-info → jaclang-0.7.6.dist-info}/WHEEL +0 -0
- {jaclang-0.7.2.dist-info → jaclang-0.7.6.dist-info}/entry_points.txt +0 -0
jaclang/settings.py
CHANGED
jaclang/tests/fixtures/abc.jac
CHANGED
|
@@ -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(
|
|
55
|
-
|
|
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
|
|
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
|
|
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
|
|
76
|
+
check assertEqual(c.shape_type, ShapeType.CIRCLE);
|
|
73
77
|
}
|
jaclang/tests/fixtures/hello.jac
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:walker:gen_outline:can:get_highlights {}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
glob x = 5,y=2;
|
|
2
|
-
|
|
3
|
-
test
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
3
|
-
test
|
|
4
|
-
|
|
5
|
-
|
|
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"),
|
|
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
|
|
jaclang/tests/test_language.py
CHANGED
|
@@ -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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
def test_with_llm_vision(self) -> None:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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)
|
jaclang/tests/test_reference.py
CHANGED
jaclang/utils/lang_tools.py
CHANGED
|
@@ -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
|
-
"
|
|
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=
|
|
238
|
-
).ir
|
|
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
|
-
"
|
|
128
|
+
"name_atom",
|
|
128
129
|
"arch_spec",
|
|
129
130
|
"match_pattern",
|
|
130
131
|
]
|
jaclang/utils/treeprinter.py
CHANGED
|
@@ -96,17 +96,20 @@ def print_ast_tree(
|
|
|
96
96
|
else ""
|
|
97
97
|
)
|
|
98
98
|
sym_table_link = (
|
|
99
|
-
f"SymbolTable: {node.
|
|
100
|
-
if isinstance(node, AstSymbolNode) and node.
|
|
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 =
|
|
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.
|
|
109
|
-
if node.
|
|
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 =
|
|
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.
|
|
121
|
-
if node.
|
|
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.
|
|
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
|