jaclang 0.8.0__py3-none-any.whl → 0.8.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jaclang might be problematic. Click here for more details.
- jaclang/__init__.py +6 -0
- jaclang/cli/cli.py +23 -50
- jaclang/compiler/codeinfo.py +0 -1
- jaclang/compiler/jac.lark +14 -22
- jaclang/compiler/larkparse/jac_parser.py +2 -2
- jaclang/compiler/parser.py +378 -531
- jaclang/compiler/passes/main/__init__.py +0 -14
- jaclang/compiler/passes/main/annex_pass.py +2 -8
- jaclang/compiler/passes/main/cfg_build_pass.py +39 -13
- jaclang/compiler/passes/main/def_impl_match_pass.py +14 -13
- jaclang/compiler/passes/main/def_use_pass.py +4 -7
- jaclang/compiler/passes/main/import_pass.py +6 -14
- jaclang/compiler/passes/main/inheritance_pass.py +2 -2
- jaclang/compiler/passes/main/pyast_gen_pass.py +428 -799
- jaclang/compiler/passes/main/pyast_load_pass.py +115 -311
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +8 -7
- jaclang/compiler/passes/main/sym_tab_build_pass.py +3 -3
- jaclang/compiler/passes/main/sym_tab_link_pass.py +6 -9
- jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/action/actions.jac +1 -5
- jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/main.jac +1 -8
- jaclang/compiler/passes/main/tests/test_cfg_build_pass.py +5 -9
- jaclang/compiler/passes/main/tests/test_decl_impl_match_pass.py +7 -8
- jaclang/compiler/passes/main/tests/test_import_pass.py +5 -18
- jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +2 -6
- jaclang/compiler/passes/main/tests/test_sub_node_pass.py +1 -3
- jaclang/compiler/passes/main/tests/test_sym_tab_link_pass.py +20 -17
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +425 -216
- jaclang/compiler/passes/tool/jac_formatter_pass.py +2 -0
- jaclang/compiler/passes/tool/tests/fixtures/archetype_frmt.jac +14 -0
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +5 -4
- jaclang/compiler/passes/tool/tests/fixtures/import_fmt.jac +6 -0
- jaclang/compiler/passes/tool/tests/fixtures/simple_walk_fmt.jac +3 -3
- jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +9 -0
- jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +18 -3
- jaclang/compiler/passes/tool/tests/test_unparse_validate.py +2 -2
- jaclang/compiler/program.py +22 -66
- jaclang/compiler/tests/fixtures/fam.jac +2 -2
- jaclang/compiler/tests/fixtures/pkg_import_lib/__init__.jac +1 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/sub/__init__.jac +1 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/sub/helper.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/tools.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/__init__.py +5 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/__init__.py +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/helper.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/tools.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_main.jac +10 -0
- jaclang/compiler/tests/fixtures/pkg_import_main_py.jac +11 -0
- jaclang/compiler/tests/test_importer.py +30 -13
- jaclang/compiler/tests/test_parser.py +1 -0
- jaclang/compiler/unitree.py +488 -320
- jaclang/langserve/__init__.jac +1 -0
- jaclang/langserve/engine.jac +503 -0
- jaclang/langserve/sem_manager.jac +309 -0
- jaclang/langserve/server.jac +201 -0
- jaclang/langserve/tests/server_test/test_lang_serve.py +139 -48
- jaclang/langserve/tests/server_test/utils.py +35 -6
- jaclang/langserve/tests/session.jac +294 -0
- jaclang/langserve/tests/test_sem_tokens.py +2 -2
- jaclang/langserve/tests/test_server.py +8 -7
- jaclang/langserve/utils.jac +51 -30
- jaclang/runtimelib/archetype.py +128 -6
- jaclang/runtimelib/builtin.py +17 -14
- jaclang/runtimelib/importer.py +51 -76
- jaclang/runtimelib/machine.py +469 -305
- jaclang/runtimelib/meta_importer.py +86 -0
- jaclang/runtimelib/tests/fixtures/graph_purger.jac +24 -26
- jaclang/runtimelib/tests/fixtures/other_root_access.jac +25 -16
- jaclang/runtimelib/tests/fixtures/traversing_save.jac +7 -5
- jaclang/runtimelib/tests/test_jaseci.py +3 -1
- jaclang/runtimelib/utils.py +3 -3
- jaclang/tests/fixtures/arch_rel_import_creation.jac +23 -23
- jaclang/tests/fixtures/async_ability.jac +43 -10
- jaclang/tests/fixtures/async_function.jac +18 -0
- jaclang/tests/fixtures/async_walker.jac +17 -12
- jaclang/tests/fixtures/backward_edge_visit.jac +31 -0
- jaclang/tests/fixtures/builtin_printgraph.jac +85 -0
- jaclang/tests/fixtures/builtin_printgraph_json.jac +21 -0
- jaclang/tests/fixtures/builtin_printgraph_mermaid.jac +16 -0
- jaclang/tests/fixtures/chandra_bugs2.jac +20 -13
- jaclang/tests/fixtures/concurrency.jac +1 -1
- jaclang/tests/fixtures/create_dynamic_archetype.jac +25 -28
- jaclang/tests/fixtures/deep/deeper/deep_outer_import.jac +7 -4
- jaclang/tests/fixtures/deep/deeper/snd_lev.jac +2 -2
- jaclang/tests/fixtures/deep/deeper/snd_lev_dup.jac +6 -0
- jaclang/tests/fixtures/deep/one_lev.jac +2 -2
- jaclang/tests/fixtures/deep/one_lev_dup.jac +4 -3
- jaclang/tests/fixtures/dynamic_archetype.jac +19 -12
- jaclang/tests/fixtures/edge_ability.jac +49 -0
- jaclang/tests/fixtures/foo.jac +14 -22
- jaclang/tests/fixtures/guess_game.jac +1 -1
- jaclang/tests/fixtures/here_usage_error.jac +21 -0
- jaclang/tests/fixtures/here_visitor_usage.jac +21 -0
- jaclang/tests/fixtures/jac_from_py.py +1 -1
- jaclang/tests/fixtures/jp_importer.jac +6 -6
- jaclang/tests/fixtures/jp_importer_auto.jac +5 -3
- jaclang/tests/fixtures/node_del.jac +30 -36
- jaclang/tests/fixtures/unicode_strings.jac +24 -0
- jaclang/tests/fixtures/visit_traversal.jac +47 -0
- jaclang/tests/fixtures/walker_update.jac +5 -7
- jaclang/tests/test_cli.py +12 -7
- jaclang/tests/test_language.py +218 -145
- jaclang/tests/test_reference.py +9 -4
- jaclang/tests/test_typecheck.py +13 -26
- jaclang/utils/helpers.py +14 -6
- jaclang/utils/lang_tools.py +9 -8
- jaclang/utils/module_resolver.py +23 -0
- jaclang/utils/tests/test_lang_tools.py +2 -1
- jaclang/utils/treeprinter.py +3 -4
- {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/METADATA +4 -3
- {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/RECORD +112 -94
- {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/WHEEL +1 -1
- jaclang/compiler/passes/main/tests/fixtures/main_err.jac +0 -6
- jaclang/compiler/passes/main/tests/fixtures/second_err.jac +0 -4
- jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +0 -644
- jaclang/compiler/passes/tool/tests/test_doc_ir_gen_pass.py +0 -29
- jaclang/langserve/__init__.py +0 -1
- jaclang/langserve/engine.py +0 -553
- jaclang/langserve/sem_manager.py +0 -383
- jaclang/langserve/server.py +0 -167
- jaclang/langserve/tests/session.py +0 -255
- jaclang/tests/fixtures/builtin_dotgen.jac +0 -42
- jaclang/tests/fixtures/builtin_dotgen_json.jac +0 -21
- jaclang/tests/fixtures/deep/deeper/__init__.jac +0 -1
- {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/entry_points.txt +0 -0
jaclang/tests/test_reference.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import Callable, Optional
|
|
|
7
7
|
|
|
8
8
|
import jaclang
|
|
9
9
|
from jaclang.compiler.program import JacProgram
|
|
10
|
-
from jaclang.runtimelib.machine import JacMachine
|
|
10
|
+
from jaclang.runtimelib.machine import JacMachine as Jac
|
|
11
11
|
from jaclang.utils.test import TestCase
|
|
12
12
|
|
|
13
13
|
|
|
@@ -59,7 +59,6 @@ class JacReferenceTests(TestCase):
|
|
|
59
59
|
{
|
|
60
60
|
"__file__": filename,
|
|
61
61
|
"__name__": "__main__",
|
|
62
|
-
"__jac_mach__": JacMachine(),
|
|
63
62
|
},
|
|
64
63
|
)
|
|
65
64
|
return f.getvalue()
|
|
@@ -74,7 +73,7 @@ class JacReferenceTests(TestCase):
|
|
|
74
73
|
mode="exec",
|
|
75
74
|
)
|
|
76
75
|
output_jac = execute_and_capture_output(code_content, filename=filename)
|
|
77
|
-
|
|
76
|
+
Jac.reset_machine()
|
|
78
77
|
filename = filename.replace(".jac", ".py")
|
|
79
78
|
with open(filename, "r") as file:
|
|
80
79
|
code_content = file.read()
|
|
@@ -84,7 +83,13 @@ class JacReferenceTests(TestCase):
|
|
|
84
83
|
# print(f"\nPython Output:\n{output_py}")
|
|
85
84
|
|
|
86
85
|
self.assertGreater(len(output_py), 0)
|
|
87
|
-
self.assertEqual(
|
|
86
|
+
self.assertEqual(len(output_jac.split("\n")), len(output_py.split("\n")))
|
|
87
|
+
# doing like below for concurrent_expressions.jac and other current tests
|
|
88
|
+
for i in output_py.split("\n"):
|
|
89
|
+
self.assertIn(i, output_jac)
|
|
90
|
+
for i in output_jac.split("\n"):
|
|
91
|
+
self.assertIn(i, output_py)
|
|
92
|
+
# self.assertEqual(output_py, output_jac)
|
|
88
93
|
except Exception as e:
|
|
89
94
|
# print(f"\nJAC Output:\n{output_jac}")
|
|
90
95
|
# print(f"\nPython Output:\n{output_py}")
|
jaclang/tests/test_typecheck.py
CHANGED
|
@@ -10,7 +10,6 @@ from unittest.mock import patch
|
|
|
10
10
|
|
|
11
11
|
from jaclang import JacMachineInterface as Jac, JacMachine
|
|
12
12
|
from jaclang.cli import cli
|
|
13
|
-
from jaclang.compiler.passes.main import CompilerMode as CMode
|
|
14
13
|
from jaclang.compiler.program import JacProgram
|
|
15
14
|
from jaclang.utils.lang_tools import AstTool
|
|
16
15
|
from jaclang.utils.test import TestCase
|
|
@@ -87,10 +86,9 @@ class JacTypeCheckTests(TestCase):
|
|
|
87
86
|
except Exception as e:
|
|
88
87
|
return f"Error While Jac to Py AST conversion: {e}"
|
|
89
88
|
|
|
90
|
-
(prog := JacProgram()).
|
|
91
|
-
|
|
89
|
+
(prog := JacProgram()).build(
|
|
90
|
+
use_str=py_ast_build_pass.unparse(),
|
|
92
91
|
file_path=file_name[:-3] + ".jac",
|
|
93
|
-
mode=CMode.TYPECHECK,
|
|
94
92
|
)
|
|
95
93
|
|
|
96
94
|
archetype_count = 0
|
|
@@ -131,10 +129,9 @@ class JacTypeCheckTests(TestCase):
|
|
|
131
129
|
except Exception as e:
|
|
132
130
|
return f"Error While Jac to Py AST conversion: {e}"
|
|
133
131
|
|
|
134
|
-
(prog := JacProgram()).
|
|
135
|
-
|
|
132
|
+
(prog := JacProgram()).build(
|
|
133
|
+
use_str=py_ast_build_pass.unparse(),
|
|
136
134
|
file_path=file_name[:-3] + ".jac",
|
|
137
|
-
mode=CMode.TYPECHECK,
|
|
138
135
|
)
|
|
139
136
|
|
|
140
137
|
archetype_count = 0
|
|
@@ -163,9 +160,7 @@ class JacTypeCheckTests(TestCase):
|
|
|
163
160
|
|
|
164
161
|
with open(file_name, "r") as f:
|
|
165
162
|
file_source = f.read()
|
|
166
|
-
(prog := JacProgram()).
|
|
167
|
-
source_str=file_source, file_path=file_name, mode=CMode.TYPECHECK
|
|
168
|
-
)
|
|
163
|
+
(prog := JacProgram()).build(use_str=file_source, file_path=file_name)
|
|
169
164
|
|
|
170
165
|
archetype_count = sum(
|
|
171
166
|
len(mod.get_all_sub_nodes(uni.Archetype))
|
|
@@ -226,10 +221,9 @@ class JacTypeCheckTests(TestCase):
|
|
|
226
221
|
settings.print_py_raised_ast = True
|
|
227
222
|
with open(file_path) as f:
|
|
228
223
|
file_source = f.read()
|
|
229
|
-
ir = JacProgram().
|
|
230
|
-
|
|
224
|
+
ir = JacProgram().build(
|
|
225
|
+
use_str=file_source,
|
|
231
226
|
file_path=file_path,
|
|
232
|
-
mode=CMode.TYPECHECK,
|
|
233
227
|
)
|
|
234
228
|
gen_ast = ir.pp()
|
|
235
229
|
if module_path == "random":
|
|
@@ -247,9 +241,7 @@ class JacTypeCheckTests(TestCase):
|
|
|
247
241
|
settings.print_py_raised_ast = True
|
|
248
242
|
with open(file_name, "r") as f:
|
|
249
243
|
file_source = f.read()
|
|
250
|
-
ir = (prog := JacProgram()).
|
|
251
|
-
source_str=file_source, file_path=file_name, mode=CMode.TYPECHECK
|
|
252
|
-
)
|
|
244
|
+
ir = (prog := JacProgram()).build(use_str=file_source, file_path=file_name)
|
|
253
245
|
jac_ast = ir.pp()
|
|
254
246
|
self.assertIn(" | +-- String - 'Loop completed normally{}'", jac_ast)
|
|
255
247
|
sub_node_list_count = 0
|
|
@@ -267,27 +259,24 @@ class JacTypeCheckTests(TestCase):
|
|
|
267
259
|
|
|
268
260
|
def test_ds_type_check_pass(self) -> None:
|
|
269
261
|
"""Test conn assign on edges."""
|
|
270
|
-
(mypass := JacProgram()).
|
|
262
|
+
(mypass := JacProgram()).build(
|
|
271
263
|
self.examples_abs_path("micro/simple_walk.jac"),
|
|
272
|
-
mode=CMode.TYPECHECK,
|
|
273
264
|
)
|
|
274
265
|
self.assertEqual(len(mypass.errors_had), 0)
|
|
275
266
|
self.assertEqual(len(mypass.warnings_had), 0)
|
|
276
267
|
|
|
277
268
|
def test_ds_type_check_pass2(self) -> None:
|
|
278
269
|
"""Test conn assign on edges."""
|
|
279
|
-
(mypass := JacProgram()).
|
|
270
|
+
(mypass := JacProgram()).build(
|
|
280
271
|
self.examples_abs_path("guess_game/guess_game5.jac"),
|
|
281
|
-
mode=CMode.TYPECHECK,
|
|
282
272
|
)
|
|
283
273
|
self.assertEqual(len(mypass.errors_had), 0)
|
|
284
274
|
self.assertEqual(len(mypass.warnings_had), 0)
|
|
285
275
|
|
|
286
276
|
def test_circle_override1_type_check_pass(self) -> None:
|
|
287
277
|
"""Test conn assign on edges."""
|
|
288
|
-
(mypass := JacProgram()).
|
|
278
|
+
(mypass := JacProgram()).build(
|
|
289
279
|
self.examples_abs_path("manual_code/circle.jac"),
|
|
290
|
-
mode=CMode.TYPECHECK,
|
|
291
280
|
)
|
|
292
281
|
self.assertEqual(len(mypass.errors_had), 0)
|
|
293
282
|
# FIXME: Figure out what to do with warning.
|
|
@@ -340,9 +329,8 @@ class JacTypeCheckTests(TestCase):
|
|
|
340
329
|
|
|
341
330
|
def test_type_errors(self) -> None:
|
|
342
331
|
"""Basic test for pass."""
|
|
343
|
-
(type_checked := JacProgram()).
|
|
332
|
+
(type_checked := JacProgram()).build(
|
|
344
333
|
file_path=self.fixture_abs_path("func.jac"),
|
|
345
|
-
mode=CMode.TYPECHECK,
|
|
346
334
|
)
|
|
347
335
|
|
|
348
336
|
errs = "\n".join([i.msg for i in type_checked.warnings_had])
|
|
@@ -358,9 +346,8 @@ class JacTypeCheckTests(TestCase):
|
|
|
358
346
|
|
|
359
347
|
def test_imported_module_typecheck(self) -> None:
|
|
360
348
|
"""Basic test for pass."""
|
|
361
|
-
(type_checked := JacProgram()).
|
|
349
|
+
(type_checked := JacProgram()).build(
|
|
362
350
|
file_path=self.fixture_abs_path("game1.jac"),
|
|
363
|
-
mode=CMode.TYPECHECK,
|
|
364
351
|
)
|
|
365
352
|
|
|
366
353
|
errs = "\n".join([i.msg for i in type_checked.warnings_had])
|
jaclang/utils/helpers.py
CHANGED
|
@@ -99,12 +99,20 @@ def auto_generate_refs() -> str:
|
|
|
99
99
|
heading = heading.strip()
|
|
100
100
|
heading_snakecase = heading_to_snake(heading)
|
|
101
101
|
content = (
|
|
102
|
-
f'## {heading}\n**Code Example**\n
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
f'{heading_snakecase}.
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
f'## {heading}\n**Code Example**\n!!! example "Runnable Example in Jac and JacLib"\n'
|
|
103
|
+
' === "Try it!"\n <div class="code-block">\n'
|
|
104
|
+
" ```jac\n"
|
|
105
|
+
f' --8<-- "jac/examples/reference/{heading_snakecase}.jac"\n'
|
|
106
|
+
" ```\n"
|
|
107
|
+
" </div>\n"
|
|
108
|
+
' === "Jac"\n ```jac linenums="1"\n'
|
|
109
|
+
f' --8<-- "jac/examples/reference/{heading_snakecase}.jac"\n'
|
|
110
|
+
f' ```\n === "Python"\n'
|
|
111
|
+
' ```python linenums="1"\n'
|
|
112
|
+
' --8<-- "jac/examples/reference/'
|
|
113
|
+
f'{heading_snakecase}.py"\n ```\n'
|
|
114
|
+
f'??? info "Jac Grammar Snippet"\n ```yaml linenums="{lines[0]}"\n --8<-- '
|
|
115
|
+
f'"jac/jaclang/compiler/jac.lark:{lines[0]}:{lines[1]}"\n ```\n'
|
|
108
116
|
"**Description**\n\n--8<-- "
|
|
109
117
|
f'"jac/examples/reference/'
|
|
110
118
|
f'{heading_snakecase}.md"\n'
|
jaclang/utils/lang_tools.py
CHANGED
|
@@ -7,7 +7,7 @@ import sys
|
|
|
7
7
|
from typing import List, Optional, Type
|
|
8
8
|
|
|
9
9
|
import jaclang.compiler.unitree as uni
|
|
10
|
-
from jaclang.compiler.passes.main import
|
|
10
|
+
from jaclang.compiler.passes.main import PyastBuildPass
|
|
11
11
|
from jaclang.compiler.passes.tool.doc_ir_gen_pass import DocIRGenPass
|
|
12
12
|
from jaclang.compiler.program import JacProgram
|
|
13
13
|
from jaclang.compiler.unitree import UniScopeNode
|
|
@@ -209,15 +209,15 @@ class AstTool:
|
|
|
209
209
|
).ir_out
|
|
210
210
|
print(rep.unparse())
|
|
211
211
|
|
|
212
|
-
ir = prog.
|
|
213
|
-
|
|
212
|
+
ir = prog.compile(
|
|
213
|
+
use_str=rep.unparse(),
|
|
214
214
|
file_path=file_name[:-3] + ".jac",
|
|
215
|
-
|
|
215
|
+
no_cgen=True,
|
|
216
216
|
)
|
|
217
217
|
except Exception as e:
|
|
218
218
|
return f"Error While Jac to Py AST conversion: {e}"
|
|
219
219
|
else:
|
|
220
|
-
ir = prog.compile(file_name,
|
|
220
|
+
ir = prog.compile(file_name, no_cgen=True)
|
|
221
221
|
|
|
222
222
|
match output:
|
|
223
223
|
case "sym":
|
|
@@ -229,7 +229,7 @@ class AstTool:
|
|
|
229
229
|
return out
|
|
230
230
|
case "sym.":
|
|
231
231
|
return (
|
|
232
|
-
ir.sym_tab.
|
|
232
|
+
ir.sym_tab.sym_printgraph()
|
|
233
233
|
if isinstance(ir.sym_tab, UniScopeNode)
|
|
234
234
|
else "Sym_tab is None."
|
|
235
235
|
)
|
|
@@ -241,10 +241,11 @@ class AstTool:
|
|
|
241
241
|
out += f"##{t}##\n# {mod_name} #\n##{t}##\n{module_.pp()}\n"
|
|
242
242
|
return out
|
|
243
243
|
case "ast.":
|
|
244
|
-
return ir.
|
|
244
|
+
return ir.printgraph()
|
|
245
245
|
case "unparse":
|
|
246
246
|
return ir.unparse()
|
|
247
247
|
case "pyast":
|
|
248
|
+
ir = prog.compile(file_name)
|
|
248
249
|
return (
|
|
249
250
|
f"\n{py_ast.dump(ir.gen.py_ast[0], indent=2)}"
|
|
250
251
|
if isinstance(ir.gen.py_ast[0], py_ast.AST)
|
|
@@ -253,6 +254,7 @@ class AstTool:
|
|
|
253
254
|
case "docir":
|
|
254
255
|
return str(DocIRGenPass(ir, prog).ir_out.gen.doc_ir)
|
|
255
256
|
case "py":
|
|
257
|
+
ir = prog.compile(file_name)
|
|
256
258
|
return (
|
|
257
259
|
f"\n{ir.gen.py}"
|
|
258
260
|
if isinstance(ir.gen.py[0], str)
|
|
@@ -277,7 +279,6 @@ class AstTool:
|
|
|
277
279
|
arrow = "-.->" if "Optional" in kid.typ else "-->"
|
|
278
280
|
typ = (
|
|
279
281
|
kid.typ.replace("Optional[", "")
|
|
280
|
-
.replace("SubNodeList[", "")
|
|
281
282
|
.replace("SubTag[", "")
|
|
282
283
|
.replace("Sequence[", "")
|
|
283
284
|
.replace("]", "")
|
jaclang/utils/module_resolver.py
CHANGED
|
@@ -4,9 +4,32 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
6
|
import site
|
|
7
|
+
import sys
|
|
7
8
|
from typing import Optional, Tuple
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
def get_jac_search_paths(base_path: Optional[str] = None) -> list[str]:
|
|
12
|
+
"""Construct a list of paths to search for Jac modules."""
|
|
13
|
+
paths = []
|
|
14
|
+
if base_path:
|
|
15
|
+
paths.append(base_path)
|
|
16
|
+
paths.append(os.getcwd())
|
|
17
|
+
if "JACPATH" in os.environ:
|
|
18
|
+
paths.extend(
|
|
19
|
+
p.strip() for p in os.environ["JACPATH"].split(os.pathsep) if p.strip()
|
|
20
|
+
)
|
|
21
|
+
paths.extend(sys.path)
|
|
22
|
+
site_pkgs = site.getsitepackages()
|
|
23
|
+
if site_pkgs:
|
|
24
|
+
paths.extend(site_pkgs)
|
|
25
|
+
user_site = getattr(site, "getusersitepackages", None)
|
|
26
|
+
if user_site:
|
|
27
|
+
user_dir = user_site()
|
|
28
|
+
if user_dir:
|
|
29
|
+
paths.append(user_dir)
|
|
30
|
+
return list(dict.fromkeys(filter(None, paths)))
|
|
31
|
+
|
|
32
|
+
|
|
10
33
|
def _candidate_from(base: str, parts: list[str]) -> Optional[Tuple[str, str]]:
|
|
11
34
|
candidate = os.path.join(base, *parts)
|
|
12
35
|
if os.path.isdir(candidate):
|
|
@@ -21,7 +21,8 @@ class JacAstToolTests(TestCase):
|
|
|
21
21
|
out = self.tool.pass_template()
|
|
22
22
|
self.assertIn("target: Expr,", out)
|
|
23
23
|
self.assertIn("self, node: ast.ReturnStmt", out)
|
|
24
|
-
self.assertIn("exprs:
|
|
24
|
+
self.assertIn("exprs: Sequence[ExprAsItem],", out)
|
|
25
|
+
self.assertIn("path: Optional[Sequence[Name]],", out)
|
|
25
26
|
self.assertIn("value: str,", out)
|
|
26
27
|
self.assertIn("def exit_module(self, node: ast.Module)", out)
|
|
27
28
|
self.assertGreater(out.count("def exit_"), 20)
|
jaclang/utils/treeprinter.py
CHANGED
|
@@ -28,7 +28,6 @@ CLASS_COLOR_MAP: dict[str, str] = {
|
|
|
28
28
|
"ArchSpec": "#a3d3f0",
|
|
29
29
|
"MatchPattern": "#a0d8b3",
|
|
30
30
|
"SubTag": "#cafafa",
|
|
31
|
-
"SubNodeList": "#dbbfe5",
|
|
32
31
|
"Module": "#D1FFE2 ",
|
|
33
32
|
"GlobalVars": "#e1d1ff",
|
|
34
33
|
"Test": "#e1d1ff",
|
|
@@ -136,7 +135,7 @@ CLASS_COLOR_MAP: dict[str, str] = {
|
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
|
|
139
|
-
def
|
|
138
|
+
def printgraph_ast_tree(
|
|
140
139
|
root: UniNode,
|
|
141
140
|
dot_lines: Optional[list[str]] = None,
|
|
142
141
|
) -> str:
|
|
@@ -184,7 +183,7 @@ def dotgen_ast_tree(
|
|
|
184
183
|
dot_lines.append(f"{gen_node_id(root)} {gen_node_parameters(root)};")
|
|
185
184
|
for i in root.kid:
|
|
186
185
|
dot_lines.append(f"{gen_node_id(root)} -> {gen_node_id(i)};")
|
|
187
|
-
|
|
186
|
+
printgraph_ast_tree(i, dot_lines)
|
|
188
187
|
if starting_call:
|
|
189
188
|
return "\ndigraph graph1 {\n" + "\n".join(list(set(dot_lines))) + "\n}"
|
|
190
189
|
return " "
|
|
@@ -502,7 +501,7 @@ def get_symtab_tree_str(
|
|
|
502
501
|
)
|
|
503
502
|
|
|
504
503
|
|
|
505
|
-
def
|
|
504
|
+
def printgraph_symtab_tree(node: UniScopeNode) -> str:
|
|
506
505
|
"""Generate DOT graph representation of a symbol table tree."""
|
|
507
506
|
dot_lines = []
|
|
508
507
|
id_map = {}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: jaclang
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.2
|
|
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
|
-
Home-page: https://jaseci.org
|
|
6
5
|
License: MIT
|
|
7
6
|
Keywords: jac,jaclang,jaseci,python,programming-language,machine-learning,artificial-intelligence
|
|
8
7
|
Author: Jason Mars
|
|
@@ -14,11 +13,13 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
14
13
|
Classifier: Programming Language :: Python :: 3
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Provides-Extra: all
|
|
18
18
|
Provides-Extra: llm
|
|
19
19
|
Provides-Extra: streamlit
|
|
20
20
|
Requires-Dist: mypy (>=1.15.0,<2.0.0)
|
|
21
21
|
Project-URL: Documentation, https://jac-lang.org
|
|
22
|
+
Project-URL: Homepage, https://jaseci.org
|
|
22
23
|
Project-URL: Repository, https://github.com/Jaseci-Labs/jaclang
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
24
25
|
|