jaclang 0.8.6__py3-none-any.whl → 0.8.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.
- jaclang/cli/cli.md +3 -3
- jaclang/cli/cli.py +37 -37
- jaclang/cli/cmdreg.py +45 -140
- jaclang/compiler/constant.py +0 -1
- jaclang/compiler/jac.lark +3 -6
- jaclang/compiler/larkparse/jac_parser.py +2 -2
- jaclang/compiler/parser.py +213 -34
- jaclang/compiler/passes/main/__init__.py +2 -4
- jaclang/compiler/passes/main/def_use_pass.py +0 -4
- jaclang/compiler/passes/main/predynamo_pass.py +221 -0
- jaclang/compiler/passes/main/pyast_gen_pass.py +83 -55
- jaclang/compiler/passes/main/pyast_load_pass.py +66 -40
- jaclang/compiler/passes/main/sym_tab_build_pass.py +1 -1
- jaclang/compiler/passes/main/tests/fixtures/checker/import_sym.jac +2 -0
- jaclang/compiler/passes/main/tests/fixtures/checker/import_sym_test.jac +6 -0
- jaclang/compiler/passes/main/tests/fixtures/checker/imported_sym.jac +5 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_arg_param_match.jac +37 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_arity.jac +18 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_binary_op.jac +21 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_call_expr_class.jac +12 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_cat_is_animal.jac +18 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_cyclic_symbol.jac +4 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_expr_call.jac +9 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_float.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_import_missing_module.jac +13 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_magic_call.jac +17 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_mod_path.jac +8 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_param_types.jac +11 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_self_type.jac +9 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_sym_inherit.jac +42 -0
- jaclang/compiler/passes/main/tests/fixtures/predynamo_fix3.jac +43 -0
- jaclang/compiler/passes/main/tests/fixtures/predynamo_where_assign.jac +13 -0
- jaclang/compiler/passes/main/tests/fixtures/predynamo_where_return.jac +11 -0
- jaclang/compiler/passes/main/tests/test_checker_pass.py +265 -0
- jaclang/compiler/passes/main/tests/test_predynamo_pass.py +57 -0
- jaclang/compiler/passes/main/type_checker_pass.py +36 -61
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +204 -44
- jaclang/compiler/passes/tool/jac_formatter_pass.py +119 -69
- jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +3 -3
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +4 -5
- jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +171 -11
- jaclang/compiler/passes/transform.py +12 -8
- jaclang/compiler/program.py +14 -6
- jaclang/compiler/tests/fixtures/jac_import_py_files.py +4 -0
- jaclang/compiler/tests/fixtures/jac_module.jac +3 -0
- jaclang/compiler/tests/fixtures/multiple_syntax_errors.jac +10 -0
- jaclang/compiler/tests/fixtures/python_module.py +1 -0
- jaclang/compiler/tests/test_importer.py +39 -0
- jaclang/compiler/tests/test_parser.py +49 -0
- jaclang/compiler/type_system/operations.py +104 -0
- jaclang/compiler/type_system/type_evaluator.py +470 -47
- jaclang/compiler/type_system/type_utils.py +246 -0
- jaclang/compiler/type_system/types.py +58 -2
- jaclang/compiler/unitree.py +79 -94
- jaclang/langserve/engine.jac +253 -230
- jaclang/langserve/server.jac +46 -15
- jaclang/langserve/tests/fixtures/circle.jac +3 -3
- jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
- jaclang/langserve/tests/fixtures/circle_pure.test.jac +3 -3
- jaclang/langserve/tests/fixtures/completion_test_err.jac +10 -0
- jaclang/langserve/tests/server_test/circle_template.jac +80 -0
- jaclang/langserve/tests/server_test/glob_template.jac +4 -0
- jaclang/langserve/tests/server_test/test_lang_serve.py +154 -312
- jaclang/langserve/tests/server_test/utils.py +153 -116
- jaclang/langserve/tests/test_dev_server.py +1 -1
- jaclang/langserve/tests/test_server.py +30 -86
- jaclang/langserve/utils.jac +56 -63
- jaclang/runtimelib/machine.py +7 -0
- jaclang/runtimelib/meta_importer.py +27 -1
- jaclang/runtimelib/tests/fixtures/custom_access_validation.jac +1 -1
- jaclang/runtimelib/tests/fixtures/savable_object.jac +2 -2
- jaclang/settings.py +18 -14
- jaclang/tests/fixtures/abc_check.jac +3 -3
- jaclang/tests/fixtures/arch_rel_import_creation.jac +12 -12
- jaclang/tests/fixtures/chandra_bugs2.jac +3 -3
- jaclang/tests/fixtures/create_dynamic_archetype.jac +13 -13
- jaclang/tests/fixtures/jac_run_py_bugs.py +18 -0
- jaclang/tests/fixtures/jac_run_py_import.py +13 -0
- jaclang/tests/fixtures/lambda_arg_annotation.jac +15 -0
- jaclang/tests/fixtures/lambda_self.jac +18 -0
- jaclang/tests/fixtures/maxfail_run_test.jac +4 -4
- jaclang/tests/fixtures/params/param_syntax_err.jac +9 -0
- jaclang/tests/fixtures/params/test_complex_params.jac +42 -0
- jaclang/tests/fixtures/params/test_failing_kwonly.jac +207 -0
- jaclang/tests/fixtures/params/test_failing_posonly.jac +116 -0
- jaclang/tests/fixtures/params/test_failing_varargs.jac +300 -0
- jaclang/tests/fixtures/params/test_kwonly_params.jac +29 -0
- jaclang/tests/fixtures/py2jac_params.py +8 -0
- jaclang/tests/fixtures/run_test.jac +4 -4
- jaclang/tests/test_cli.py +103 -18
- jaclang/tests/test_language.py +74 -16
- jaclang/utils/helpers.py +47 -2
- jaclang/utils/module_resolver.py +11 -1
- jaclang/utils/test.py +8 -0
- jaclang/utils/treeprinter.py +0 -18
- {jaclang-0.8.6.dist-info → jaclang-0.8.8.dist-info}/METADATA +3 -3
- {jaclang-0.8.6.dist-info → jaclang-0.8.8.dist-info}/RECORD +99 -62
- {jaclang-0.8.6.dist-info → jaclang-0.8.8.dist-info}/WHEEL +1 -1
- jaclang/compiler/passes/main/inheritance_pass.py +0 -131
- jaclang/langserve/dev_engine.jac +0 -645
- jaclang/langserve/dev_server.jac +0 -201
- jaclang/langserve/tests/server_test/code_test.py +0 -0
- {jaclang-0.8.6.dist-info → jaclang-0.8.8.dist-info}/entry_points.txt +0 -0
jaclang/tests/test_language.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import io
|
|
4
4
|
import os
|
|
5
5
|
import sys
|
|
6
|
-
import
|
|
6
|
+
import pytest
|
|
7
7
|
import tempfile
|
|
8
8
|
import subprocess
|
|
9
9
|
from pathlib import Path
|
|
@@ -514,14 +514,13 @@ class JacLanguageTests(TestCase):
|
|
|
514
514
|
),
|
|
515
515
|
prog=JacProgram(),
|
|
516
516
|
).ir_out.unparse()
|
|
517
|
-
self.assertIn("def greet2(**kwargs: Any)", output)
|
|
517
|
+
self.assertIn("def greet2( **kwargs: Any) {", output)
|
|
518
518
|
self.assertEqual(output.count("with entry {"), 14)
|
|
519
519
|
self.assertIn("assert (x == 5) , 'x should be equal to 5' ;", output)
|
|
520
520
|
self.assertIn("if not (x == y) {", output)
|
|
521
|
-
self.assertIn("
|
|
522
|
-
self.assertIn("squares_dict = { x : (x ** 2) for x in numbers };", output)
|
|
521
|
+
self.assertIn("squares_dict = {x : (x ** 2) for x in numbers};", output)
|
|
523
522
|
self.assertIn(
|
|
524
|
-
'\n\n"""Say hello"""\n@
|
|
523
|
+
'\n\n"""Say hello"""\n@my_decorator\n\n def say_hello() {', output
|
|
525
524
|
)
|
|
526
525
|
|
|
527
526
|
def test_pyfunc_2(self) -> None:
|
|
@@ -589,6 +588,27 @@ class JacLanguageTests(TestCase):
|
|
|
589
588
|
self.assertIn("case Container(inner = Inner(x = a, y = b)):\n", output)
|
|
590
589
|
self.assertIn("case _:\n", output)
|
|
591
590
|
|
|
591
|
+
def test_py2jac_params(self) -> None:
|
|
592
|
+
"""Test py ast to Jac ast conversion."""
|
|
593
|
+
from jaclang.compiler.passes.main import PyastBuildPass
|
|
594
|
+
import jaclang.compiler.unitree as ast
|
|
595
|
+
import ast as py_ast
|
|
596
|
+
|
|
597
|
+
py_out_path = os.path.join(self.fixture_abs_path("./"), "py2jac_params.py")
|
|
598
|
+
with open(py_out_path) as f:
|
|
599
|
+
file_source = f.read()
|
|
600
|
+
output = PyastBuildPass(
|
|
601
|
+
ir_in=ast.PythonModuleAst(
|
|
602
|
+
py_ast.parse(file_source),
|
|
603
|
+
orig_src=ast.Source(file_source, py_out_path),
|
|
604
|
+
),
|
|
605
|
+
prog=None,
|
|
606
|
+
).ir_out.unparse()
|
|
607
|
+
self.assertIn(
|
|
608
|
+
"def isinstance( <>obj: object , class_or_tuple: _ClassInfo , /) -> bool {", output)
|
|
609
|
+
self.assertIn(
|
|
610
|
+
"def len(<>obj: Sized, astt: Any, /, z: int, j: str, a: Any = 90) -> int {", output)
|
|
611
|
+
|
|
592
612
|
def test_refs_target(self) -> None:
|
|
593
613
|
"""Test py ast to Jac ast conversion output."""
|
|
594
614
|
captured_output = io.StringIO()
|
|
@@ -712,6 +732,7 @@ class JacLanguageTests(TestCase):
|
|
|
712
732
|
mypass = JacProgram().compile(self.fixture_abs_path("byllmissue.jac"))
|
|
713
733
|
self.assertIn("2:5 - 4:8", mypass.pp())
|
|
714
734
|
|
|
735
|
+
@pytest.mark.xfail(reason="TODO: Support symtable for inheritance")
|
|
715
736
|
def test_inherit_baseclass_sym(self) -> None:
|
|
716
737
|
"""Basic test for symtable support for inheritance."""
|
|
717
738
|
mypass = JacProgram().compile(
|
|
@@ -746,6 +767,43 @@ class JacLanguageTests(TestCase):
|
|
|
746
767
|
stdout_value = captured_output.getvalue()
|
|
747
768
|
self.assertIn("i work", stdout_value)
|
|
748
769
|
|
|
770
|
+
def test_kwonly_params(self) -> None:
|
|
771
|
+
"""Test importing python."""
|
|
772
|
+
captured_output = io.StringIO()
|
|
773
|
+
sys.stdout = captured_output
|
|
774
|
+
Jac.jac_import("test_kwonly_params", base_path=self.fixture_abs_path("./params"))
|
|
775
|
+
sys.stdout = sys.__stdout__
|
|
776
|
+
stdout_value = captured_output.getvalue().split("\n")
|
|
777
|
+
self.assertEqual("KW_SIMPLE: 42", stdout_value[0])
|
|
778
|
+
self.assertEqual("KW_DEF: 10-def 20-def", stdout_value[1])
|
|
779
|
+
self.assertEqual("REG_KW: 10|test", stdout_value[2])
|
|
780
|
+
self.assertEqual("MIXED_KW: 1-def-2.5-True 2-custom-3.5-False", stdout_value[3])
|
|
781
|
+
self.assertEqual("ALL_KW: 100:test:1.0 200:hi:9.9", stdout_value[4])
|
|
782
|
+
|
|
783
|
+
def test_complex_params(self) -> None:
|
|
784
|
+
"""Test importing python."""
|
|
785
|
+
captured_output = io.StringIO()
|
|
786
|
+
sys.stdout = captured_output
|
|
787
|
+
Jac.jac_import("test_complex_params", base_path=self.fixture_abs_path("./params"))
|
|
788
|
+
sys.stdout = sys.__stdout__
|
|
789
|
+
stdout_value = captured_output.getvalue().split("\n")
|
|
790
|
+
self.assertEqual("ULTIMATE_MIN: 1|def|2.5|0|test|100|0", stdout_value[0])
|
|
791
|
+
self.assertEqual("ULTIMATE_FULL: 1|custom|3.14|3|req|200|1", stdout_value[1])
|
|
792
|
+
self.assertEqual("SEPARATORS: 42", stdout_value[2])
|
|
793
|
+
self.assertEqual("EDGE_MIX: 1-test-2-True-1", stdout_value[3])
|
|
794
|
+
self.assertEqual("RECURSIVE: 7 11", stdout_value[4])
|
|
795
|
+
self.assertEqual("VALIDATION: x:1,y:2.5,z:10,args:1,w:True,kwargs:1", stdout_value[5])
|
|
796
|
+
|
|
797
|
+
def test_param_failing(self) -> None:
|
|
798
|
+
"""Test importing python."""
|
|
799
|
+
captured_output = io.StringIO()
|
|
800
|
+
sys.stdout = captured_output
|
|
801
|
+
for i in ["test_failing_posonly", "test_failing_kwonly", "test_failing_varargs"]:
|
|
802
|
+
Jac.jac_import(i, base_path=self.fixture_abs_path("./params"))
|
|
803
|
+
sys.stdout = sys.__stdout__
|
|
804
|
+
stdout_value = captured_output.getvalue()
|
|
805
|
+
self.assertNotIn('FAILED', stdout_value)
|
|
806
|
+
|
|
749
807
|
def test_double_import_exec(self) -> None:
|
|
750
808
|
"""Test importing python."""
|
|
751
809
|
captured_output = io.StringIO()
|
|
@@ -1238,9 +1296,9 @@ class JacLanguageTests(TestCase):
|
|
|
1238
1296
|
).ir_out.unparse()
|
|
1239
1297
|
self.assertIn("(prev_token_index is None)", output)
|
|
1240
1298
|
self.assertIn("(next_token_index is None)", output)
|
|
1241
|
-
self.assertIn("(tok[
|
|
1242
|
-
self.assertIn("(tok[
|
|
1243
|
-
self.assertIn("(tok[
|
|
1299
|
+
self.assertIn("(tok[0] > change_end_line)", output)
|
|
1300
|
+
self.assertIn("(tok[0] == change_end_line)", output)
|
|
1301
|
+
self.assertIn("(tok[1] > change_end_char)", output)
|
|
1244
1302
|
|
|
1245
1303
|
def test_here_visitor_usage(self) -> None:
|
|
1246
1304
|
"""Test visitor, here keyword usage in jaclang."""
|
|
@@ -1378,7 +1436,7 @@ class JacLanguageTests(TestCase):
|
|
|
1378
1436
|
test_content = "Hello, 世界! 🌍 Testing UTF-8 encoding."
|
|
1379
1437
|
f.write(test_content)
|
|
1380
1438
|
temp_path = f.name
|
|
1381
|
-
|
|
1439
|
+
|
|
1382
1440
|
try:
|
|
1383
1441
|
result = read_file_with_encoding(temp_path)
|
|
1384
1442
|
self.assertEqual(result, test_content)
|
|
@@ -1391,7 +1449,7 @@ class JacLanguageTests(TestCase):
|
|
|
1391
1449
|
test_content = "Hello, 世界! UTF-16 encoding test."
|
|
1392
1450
|
f.write(test_content)
|
|
1393
1451
|
temp_path = f.name
|
|
1394
|
-
|
|
1452
|
+
|
|
1395
1453
|
try:
|
|
1396
1454
|
result = read_file_with_encoding(temp_path)
|
|
1397
1455
|
self.assertEqual(result, test_content)
|
|
@@ -1404,7 +1462,7 @@ class JacLanguageTests(TestCase):
|
|
|
1404
1462
|
test_content = "Hello, UTF-8 BOM test! 🚀"
|
|
1405
1463
|
f.write(test_content)
|
|
1406
1464
|
temp_path = f.name
|
|
1407
|
-
|
|
1465
|
+
|
|
1408
1466
|
try:
|
|
1409
1467
|
result = read_file_with_encoding(temp_path)
|
|
1410
1468
|
self.assertEqual(result, test_content)
|
|
@@ -1431,9 +1489,9 @@ class JacLanguageTests(TestCase):
|
|
|
1431
1489
|
with tempfile.NamedTemporaryFile(delete=False) as f:
|
|
1432
1490
|
binary_data = bytes([0xFF, 0xFE, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F])
|
|
1433
1491
|
f.write(binary_data)
|
|
1434
|
-
f.flush()
|
|
1492
|
+
f.flush()
|
|
1435
1493
|
temp_path = f.name
|
|
1436
|
-
|
|
1494
|
+
|
|
1437
1495
|
try:
|
|
1438
1496
|
result = read_file_with_encoding(temp_path)
|
|
1439
1497
|
self.assertIsInstance(result, str)
|
|
@@ -1446,15 +1504,15 @@ class JacLanguageTests(TestCase):
|
|
|
1446
1504
|
with tempfile.NamedTemporaryFile(mode='w', encoding='utf-8', delete=False) as f:
|
|
1447
1505
|
test_content = (
|
|
1448
1506
|
"Special chars: åäö ñ ü ç é\n"
|
|
1449
|
-
"Symbols: ©®™ §¶†‡•\n"
|
|
1507
|
+
"Symbols: ©®™ §¶†‡•\n"
|
|
1450
1508
|
"Math: ∑∏∫√±≤≥≠\n"
|
|
1451
1509
|
"Arrows: ←→↑↓↔\n"
|
|
1452
1510
|
"Emoji: 😀😍🎉🔥💯\n"
|
|
1453
1511
|
)
|
|
1454
1512
|
f.write(test_content)
|
|
1455
|
-
f.flush()
|
|
1513
|
+
f.flush()
|
|
1456
1514
|
temp_path = f.name
|
|
1457
|
-
|
|
1515
|
+
|
|
1458
1516
|
try:
|
|
1459
1517
|
result = read_file_with_encoding(temp_path)
|
|
1460
1518
|
|
jaclang/utils/helpers.py
CHANGED
|
@@ -192,6 +192,37 @@ def dump_traceback(e: Exception) -> str:
|
|
|
192
192
|
return trace_dump
|
|
193
193
|
|
|
194
194
|
|
|
195
|
+
# FIXME: Use a proper color library and/or move this somewhere common to jac stack and use it everywhere.
|
|
196
|
+
# Reference: https://gist.github.com/rene-d/9e584a7dd2935d0f461904b9f2950007
|
|
197
|
+
class ANSIColors:
|
|
198
|
+
"""ANSI color codes."""
|
|
199
|
+
|
|
200
|
+
BLACK = "\033[0;30m"
|
|
201
|
+
RED = "\033[0;31m"
|
|
202
|
+
GREEN = "\033[0;32m"
|
|
203
|
+
BROWN = "\033[0;33m"
|
|
204
|
+
BLUE = "\033[0;34m"
|
|
205
|
+
PURPLE = "\033[0;35m"
|
|
206
|
+
CYAN = "\033[0;36m"
|
|
207
|
+
LIGHT_GRAY = "\033[0;37m"
|
|
208
|
+
DARK_GRAY = "\033[1;30m"
|
|
209
|
+
LIGHT_RED = "\033[1;31m"
|
|
210
|
+
LIGHT_GREEN = "\033[1;32m"
|
|
211
|
+
YELLOW = "\033[1;33m"
|
|
212
|
+
LIGHT_BLUE = "\033[1;34m"
|
|
213
|
+
LIGHT_PURPLE = "\033[1;35m"
|
|
214
|
+
LIGHT_CYAN = "\033[1;36m"
|
|
215
|
+
LIGHT_WHITE = "\033[1;37m"
|
|
216
|
+
BOLD = "\033[1m"
|
|
217
|
+
FAINT = "\033[2m"
|
|
218
|
+
ITALIC = "\033[3m"
|
|
219
|
+
UNDERLINE = "\033[4m"
|
|
220
|
+
BLINK = "\033[5m"
|
|
221
|
+
NEGATIVE = "\033[7m"
|
|
222
|
+
CROSSED = "\033[9m"
|
|
223
|
+
END = "\033[0m"
|
|
224
|
+
|
|
225
|
+
|
|
195
226
|
# TODO: After implementing the TextRange (or simillar named) class to mark a text range
|
|
196
227
|
# refactor the parameter to accept an instace of that text range object.
|
|
197
228
|
def pretty_print_source_location(
|
|
@@ -200,6 +231,8 @@ def pretty_print_source_location(
|
|
|
200
231
|
error_line: int,
|
|
201
232
|
pos_start: int,
|
|
202
233
|
pos_end: int,
|
|
234
|
+
*,
|
|
235
|
+
colors: bool = False,
|
|
203
236
|
) -> str:
|
|
204
237
|
"""Pretty print internal method for the pretty_print method."""
|
|
205
238
|
# NOTE: The Line numbers and the column numbers are starts with 1.
|
|
@@ -241,7 +274,16 @@ def pretty_print_source_location(
|
|
|
241
274
|
idx_line_start = idx
|
|
242
275
|
while idx < len(file_source) and file_source[idx] != "\n":
|
|
243
276
|
idx += 1 # Run to the line end.
|
|
244
|
-
|
|
277
|
+
|
|
278
|
+
if colors and (curr_line == error_line):
|
|
279
|
+
pretty_dump += (
|
|
280
|
+
file_source[idx_line_start:pos_start]
|
|
281
|
+
+ f"{ANSIColors.RED}{file_source[pos_start:pos_end]}{ANSIColors.END}"
|
|
282
|
+
+ file_source[pos_end:idx]
|
|
283
|
+
)
|
|
284
|
+
else:
|
|
285
|
+
pretty_dump += file_source[idx_line_start:idx]
|
|
286
|
+
|
|
245
287
|
pretty_dump += "\n"
|
|
246
288
|
|
|
247
289
|
if curr_line == error_line: # Print the current line with indicator.
|
|
@@ -252,7 +294,10 @@ def pretty_print_source_location(
|
|
|
252
294
|
spaces += "\t" if file_source[idx_pre] == "\t" else " "
|
|
253
295
|
|
|
254
296
|
err_token_len = pos_end - pos_start
|
|
255
|
-
|
|
297
|
+
underline = "^" * err_token_len
|
|
298
|
+
if colors:
|
|
299
|
+
underline = f"{ANSIColors.RED}{underline}{ANSIColors.END}"
|
|
300
|
+
pretty_dump += spaces + underline + "\n"
|
|
256
301
|
|
|
257
302
|
if idx == len(file_source):
|
|
258
303
|
break
|
jaclang/utils/module_resolver.py
CHANGED
|
@@ -30,6 +30,16 @@ def get_jac_search_paths(base_path: Optional[str] = None) -> list[str]:
|
|
|
30
30
|
return list(dict.fromkeys(filter(None, paths)))
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
# TODO: need to be removed once python modules are fully supported in jac
|
|
34
|
+
def get_py_search_paths(base_path: Optional[str] = None) -> list[str]:
|
|
35
|
+
"""Construct a list of paths to search for Python modules."""
|
|
36
|
+
paths = []
|
|
37
|
+
if base_path:
|
|
38
|
+
paths.append(base_path)
|
|
39
|
+
paths.append(os.getcwd())
|
|
40
|
+
return list(dict.fromkeys(filter(None, paths)))
|
|
41
|
+
|
|
42
|
+
|
|
33
43
|
def _candidate_from(base: str, parts: list[str]) -> Optional[Tuple[str, str]]:
|
|
34
44
|
candidate = os.path.join(base, *parts)
|
|
35
45
|
if os.path.isdir(candidate):
|
|
@@ -52,7 +62,7 @@ def resolve_module(target: str, base_path: str) -> Tuple[str, str]:
|
|
|
52
62
|
level += 1
|
|
53
63
|
actual_parts = parts[level:]
|
|
54
64
|
|
|
55
|
-
for sp in
|
|
65
|
+
for sp in get_jac_search_paths(base_path):
|
|
56
66
|
res = _candidate_from(sp, actual_parts)
|
|
57
67
|
if res:
|
|
58
68
|
return res
|
jaclang/utils/test.py
CHANGED
|
@@ -68,6 +68,14 @@ class TestCase(_TestCase):
|
|
|
68
68
|
)
|
|
69
69
|
return os.path.abspath(file_path)
|
|
70
70
|
|
|
71
|
+
def lang_fixture_abs_path(self, file: str) -> str:
|
|
72
|
+
"""Language fixture abs path."""
|
|
73
|
+
fixture_src = jaclang.__file__
|
|
74
|
+
file_path = os.path.join(
|
|
75
|
+
os.path.dirname(fixture_src), "tests", "fixtures", file
|
|
76
|
+
)
|
|
77
|
+
return os.path.abspath(file_path)
|
|
78
|
+
|
|
71
79
|
|
|
72
80
|
class TestCaseMicroSuite(TestCase):
|
|
73
81
|
"""Base test case for Jaseci."""
|
jaclang/utils/treeprinter.py
CHANGED
|
@@ -391,20 +391,6 @@ def _build_symbol_tree_common(
|
|
|
391
391
|
children = SymbolTree(node_name="Sub Tables", parent=root)
|
|
392
392
|
|
|
393
393
|
syms_to_iterate = set(node.names_in_scope.values())
|
|
394
|
-
for inhrited_symtab in node.inherited_scope:
|
|
395
|
-
for inhrited_sym in inhrited_symtab.symbols:
|
|
396
|
-
sym = inhrited_symtab.lookup(inhrited_sym)
|
|
397
|
-
assert sym is not None
|
|
398
|
-
syms_to_iterate.add(sym)
|
|
399
|
-
|
|
400
|
-
for stab in node.inherited_scope:
|
|
401
|
-
if stab.load_all_symbols:
|
|
402
|
-
syms_to_iterate.update(list(stab.base_symbol_table.names_in_scope.values()))
|
|
403
|
-
else:
|
|
404
|
-
for sname in stab.symbols:
|
|
405
|
-
sym = stab.base_symbol_table.lookup(sname)
|
|
406
|
-
assert sym is not None
|
|
407
|
-
syms_to_iterate.add(sym)
|
|
408
394
|
|
|
409
395
|
for sym in syms_to_iterate:
|
|
410
396
|
symbol_node = SymbolTree(node_name=f"{sym.sym_name}", parent=symbols)
|
|
@@ -437,10 +423,6 @@ def _build_symbol_tree_common(
|
|
|
437
423
|
continue
|
|
438
424
|
_build_symbol_tree_common(k, children)
|
|
439
425
|
|
|
440
|
-
for k2 in node.inherited_scope:
|
|
441
|
-
if k2.base_symbol_table.scope_name == "builtins":
|
|
442
|
-
continue
|
|
443
|
-
_build_symbol_tree_common(k2.base_symbol_table, children)
|
|
444
426
|
return root
|
|
445
427
|
|
|
446
428
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: jaclang
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.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
|
License: MIT
|
|
6
6
|
Keywords: jac,jaclang,jaseci,python,programming-language,machine-learning,artificial-intelligence
|
|
@@ -14,11 +14,11 @@ Classifier: Programming Language :: Python :: 3
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
18
|
Provides-Extra: all
|
|
18
19
|
Provides-Extra: cloud
|
|
19
20
|
Provides-Extra: llm
|
|
20
21
|
Provides-Extra: streamlit
|
|
21
|
-
Requires-Dist: mypy (>=1.15.0,<2.0.0)
|
|
22
22
|
Project-URL: Documentation, https://jac-lang.org
|
|
23
23
|
Project-URL: Homepage, https://jaseci.org
|
|
24
24
|
Project-URL: Repository, https://github.com/Jaseci-Labs/jaclang
|