jaclang 0.8.7__py3-none-any.whl → 0.8.9__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 +77 -29
- jaclang/cli/cmdreg.py +44 -0
- jaclang/compiler/constant.py +6 -2
- jaclang/compiler/jac.lark +37 -47
- jaclang/compiler/larkparse/jac_parser.py +2 -2
- jaclang/compiler/parser.py +356 -61
- jaclang/compiler/passes/main/__init__.py +2 -4
- jaclang/compiler/passes/main/def_use_pass.py +1 -4
- jaclang/compiler/passes/main/predynamo_pass.py +221 -0
- jaclang/compiler/passes/main/pyast_gen_pass.py +221 -135
- jaclang/compiler/passes/main/pyast_load_pass.py +54 -20
- 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_cat_is_animal.jac +18 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_float.jac +7 -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 +190 -0
- jaclang/compiler/passes/main/tests/test_predynamo_pass.py +56 -0
- jaclang/compiler/passes/main/type_checker_pass.py +29 -73
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +302 -58
- 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/import_fmt.jac +7 -1
- jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +276 -10
- jaclang/compiler/passes/transform.py +12 -8
- jaclang/compiler/program.py +19 -7
- 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/type_evaluator.jac +959 -0
- jaclang/compiler/type_system/type_utils.py +246 -0
- jaclang/compiler/type_system/types.py +58 -2
- jaclang/compiler/unitree.py +102 -107
- jaclang/langserve/engine.jac +138 -159
- jaclang/langserve/server.jac +25 -1
- 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 -309
- jaclang/langserve/tests/server_test/utils.py +153 -116
- jaclang/langserve/tests/test_server.py +21 -84
- jaclang/langserve/utils.jac +12 -15
- jaclang/lib.py +17 -0
- jaclang/runtimelib/archetype.py +25 -25
- jaclang/runtimelib/constructs.py +2 -2
- jaclang/runtimelib/machine.py +63 -46
- 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 +19 -16
- jaclang/tests/fixtures/abc_check.jac +3 -3
- jaclang/tests/fixtures/arch_rel_import_creation.jac +12 -12
- jaclang/tests/fixtures/attr_pattern_case.jac +18 -0
- jaclang/tests/fixtures/chandra_bugs2.jac +3 -3
- jaclang/tests/fixtures/create_dynamic_archetype.jac +13 -13
- jaclang/tests/fixtures/funccall_genexpr.jac +7 -0
- jaclang/tests/fixtures/funccall_genexpr.py +5 -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 +159 -7
- jaclang/tests/test_language.py +213 -38
- jaclang/tests/test_reference.py +3 -1
- jaclang/utils/helpers.py +67 -6
- jaclang/utils/module_resolver.py +10 -0
- jaclang/utils/test.py +8 -0
- jaclang/utils/tests/test_lang_tools.py +4 -15
- jaclang/utils/treeprinter.py +0 -18
- {jaclang-0.8.7.dist-info → jaclang-0.8.9.dist-info}/METADATA +1 -2
- {jaclang-0.8.7.dist-info → jaclang-0.8.9.dist-info}/RECORD +95 -65
- {jaclang-0.8.7.dist-info → jaclang-0.8.9.dist-info}/WHEEL +1 -1
- jaclang/compiler/passes/main/inheritance_pass.py +0 -131
- jaclang/compiler/type_system/type_evaluator.py +0 -560
- jaclang/langserve/dev_engine.jac +0 -645
- jaclang/langserve/dev_server.jac +0 -201
- /jaclang/{langserve/tests/server_test/code_test.py → tests/fixtures/py2jac_empty.py} +0 -0
- {jaclang-0.8.7.dist-info → jaclang-0.8.9.dist-info}/entry_points.txt +0 -0
jaclang/utils/helpers.py
CHANGED
|
@@ -94,12 +94,19 @@ def auto_generate_refs() -> str:
|
|
|
94
94
|
os.path.split(os.path.dirname(__file__))[0], "../jaclang/compiler/jac.lark"
|
|
95
95
|
)
|
|
96
96
|
result = extract_headings(file_path)
|
|
97
|
-
|
|
97
|
+
|
|
98
|
+
# Create the reference subdirectory if it doesn't exist
|
|
99
|
+
docs_ref_dir = os.path.join(
|
|
100
|
+
os.path.split(os.path.dirname(__file__))[0], "../../docs/docs/learn/jac_ref"
|
|
101
|
+
)
|
|
102
|
+
os.makedirs(docs_ref_dir, exist_ok=True)
|
|
103
|
+
|
|
104
|
+
# Generate individual markdown files for each section
|
|
98
105
|
for heading, lines in result.items():
|
|
99
106
|
heading = heading.strip()
|
|
100
107
|
heading_snakecase = heading_to_snake(heading)
|
|
101
108
|
content = (
|
|
102
|
-
f'
|
|
109
|
+
f'# {heading}\n\n**Code Example**\n!!! example "Runnable Example in Jac and JacLib"\n'
|
|
103
110
|
' === "Try it!"\n <div class="code-block">\n'
|
|
104
111
|
" ```jac\n"
|
|
105
112
|
f' --8<-- "jac/examples/reference/{heading_snakecase}.jac"\n'
|
|
@@ -112,12 +119,21 @@ def auto_generate_refs() -> str:
|
|
|
112
119
|
' --8<-- "jac/examples/reference/'
|
|
113
120
|
f'{heading_snakecase}.py"\n ```\n'
|
|
114
121
|
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'
|
|
122
|
+
f'"jac/jaclang/compiler/jac.lark:{lines[0]}:{lines[1]}"\n ```\n\n'
|
|
116
123
|
"**Description**\n\n--8<-- "
|
|
117
124
|
f'"jac/examples/reference/'
|
|
118
125
|
f'{heading_snakecase}.md"\n'
|
|
119
126
|
)
|
|
120
|
-
|
|
127
|
+
|
|
128
|
+
# Write individual file
|
|
129
|
+
output_file = os.path.join(docs_ref_dir, f"{heading_snakecase}.md")
|
|
130
|
+
with open(output_file, "w") as f:
|
|
131
|
+
f.write(content)
|
|
132
|
+
|
|
133
|
+
# Return just the introduction for the main jac_ref.md file
|
|
134
|
+
md_str = (
|
|
135
|
+
'# Jac Language Reference\n\n--8<-- "jac/examples/reference/introduction.md"\n'
|
|
136
|
+
)
|
|
121
137
|
return md_str
|
|
122
138
|
|
|
123
139
|
|
|
@@ -192,6 +208,37 @@ def dump_traceback(e: Exception) -> str:
|
|
|
192
208
|
return trace_dump
|
|
193
209
|
|
|
194
210
|
|
|
211
|
+
# FIXME: Use a proper color library and/or move this somewhere common to jac stack and use it everywhere.
|
|
212
|
+
# Reference: https://gist.github.com/rene-d/9e584a7dd2935d0f461904b9f2950007
|
|
213
|
+
class ANSIColors:
|
|
214
|
+
"""ANSI color codes."""
|
|
215
|
+
|
|
216
|
+
BLACK = "\033[0;30m"
|
|
217
|
+
RED = "\033[0;31m"
|
|
218
|
+
GREEN = "\033[0;32m"
|
|
219
|
+
BROWN = "\033[0;33m"
|
|
220
|
+
BLUE = "\033[0;34m"
|
|
221
|
+
PURPLE = "\033[0;35m"
|
|
222
|
+
CYAN = "\033[0;36m"
|
|
223
|
+
LIGHT_GRAY = "\033[0;37m"
|
|
224
|
+
DARK_GRAY = "\033[1;30m"
|
|
225
|
+
LIGHT_RED = "\033[1;31m"
|
|
226
|
+
LIGHT_GREEN = "\033[1;32m"
|
|
227
|
+
YELLOW = "\033[1;33m"
|
|
228
|
+
LIGHT_BLUE = "\033[1;34m"
|
|
229
|
+
LIGHT_PURPLE = "\033[1;35m"
|
|
230
|
+
LIGHT_CYAN = "\033[1;36m"
|
|
231
|
+
LIGHT_WHITE = "\033[1;37m"
|
|
232
|
+
BOLD = "\033[1m"
|
|
233
|
+
FAINT = "\033[2m"
|
|
234
|
+
ITALIC = "\033[3m"
|
|
235
|
+
UNDERLINE = "\033[4m"
|
|
236
|
+
BLINK = "\033[5m"
|
|
237
|
+
NEGATIVE = "\033[7m"
|
|
238
|
+
CROSSED = "\033[9m"
|
|
239
|
+
END = "\033[0m"
|
|
240
|
+
|
|
241
|
+
|
|
195
242
|
# TODO: After implementing the TextRange (or simillar named) class to mark a text range
|
|
196
243
|
# refactor the parameter to accept an instace of that text range object.
|
|
197
244
|
def pretty_print_source_location(
|
|
@@ -200,6 +247,8 @@ def pretty_print_source_location(
|
|
|
200
247
|
error_line: int,
|
|
201
248
|
pos_start: int,
|
|
202
249
|
pos_end: int,
|
|
250
|
+
*,
|
|
251
|
+
colors: bool = False,
|
|
203
252
|
) -> str:
|
|
204
253
|
"""Pretty print internal method for the pretty_print method."""
|
|
205
254
|
# NOTE: The Line numbers and the column numbers are starts with 1.
|
|
@@ -241,7 +290,16 @@ def pretty_print_source_location(
|
|
|
241
290
|
idx_line_start = idx
|
|
242
291
|
while idx < len(file_source) and file_source[idx] != "\n":
|
|
243
292
|
idx += 1 # Run to the line end.
|
|
244
|
-
|
|
293
|
+
|
|
294
|
+
if colors and (curr_line == error_line):
|
|
295
|
+
pretty_dump += (
|
|
296
|
+
file_source[idx_line_start:pos_start]
|
|
297
|
+
+ f"{ANSIColors.RED}{file_source[pos_start:pos_end]}{ANSIColors.END}"
|
|
298
|
+
+ file_source[pos_end:idx]
|
|
299
|
+
)
|
|
300
|
+
else:
|
|
301
|
+
pretty_dump += file_source[idx_line_start:idx]
|
|
302
|
+
|
|
245
303
|
pretty_dump += "\n"
|
|
246
304
|
|
|
247
305
|
if curr_line == error_line: # Print the current line with indicator.
|
|
@@ -252,7 +310,10 @@ def pretty_print_source_location(
|
|
|
252
310
|
spaces += "\t" if file_source[idx_pre] == "\t" else " "
|
|
253
311
|
|
|
254
312
|
err_token_len = pos_end - pos_start
|
|
255
|
-
|
|
313
|
+
underline = "^" * err_token_len
|
|
314
|
+
if colors:
|
|
315
|
+
underline = f"{ANSIColors.RED}{underline}{ANSIColors.END}"
|
|
316
|
+
pretty_dump += spaces + underline + "\n"
|
|
256
317
|
|
|
257
318
|
if idx == len(file_source):
|
|
258
319
|
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):
|
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."""
|
|
@@ -112,7 +112,7 @@ class JacAstToolTests(TestCase):
|
|
|
112
112
|
"""Testing for sym, sym. AstTool."""
|
|
113
113
|
jac_file = os.path.normpath(
|
|
114
114
|
os.path.join(
|
|
115
|
-
os.path.dirname(jaclang.__file__), "../examples/reference/
|
|
115
|
+
os.path.dirname(jaclang.__file__), "../examples/reference/while_statements.jac"
|
|
116
116
|
)
|
|
117
117
|
)
|
|
118
118
|
out = self.tool.ir(["sym", jac_file])
|
|
@@ -122,25 +122,14 @@ class JacAstToolTests(TestCase):
|
|
|
122
122
|
)
|
|
123
123
|
check_list = [
|
|
124
124
|
"########",
|
|
125
|
-
"#
|
|
125
|
+
"# while_statements #",
|
|
126
126
|
"########",
|
|
127
|
-
"SymTable::Module(
|
|
128
|
-
"| +-- list1",
|
|
129
|
-
"| +-- x",
|
|
130
|
-
"| +-- impl.x",
|
|
131
|
-
"| +-- c",
|
|
132
|
-
"| +-- d",
|
|
133
|
-
"| +-- a",
|
|
134
|
-
"| +-- b",
|
|
135
|
-
"+-- SymTable::ImplDef(impl.x)",
|
|
136
|
-
" SymTable::Enum(x)",
|
|
137
|
-
"+-- line 19, col 13",
|
|
127
|
+
"SymTable::Module(while_statements)",
|
|
138
128
|
]
|
|
139
129
|
for i in check_list:
|
|
140
130
|
self.assertIn(i, out)
|
|
141
131
|
out = self.tool.ir(["sym.", jac_file])
|
|
142
|
-
self.assertIn('[label="
|
|
143
|
-
self.assertNotIn('[label="str"];', out)
|
|
132
|
+
self.assertIn('[label="', out)
|
|
144
133
|
|
|
145
134
|
def test_uninode_doc(self) -> None:
|
|
146
135
|
"""Testing for Autodoc for Uninodes."""
|
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
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jaclang
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.9
|
|
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
|
|
@@ -19,7 +19,6 @@ Provides-Extra: all
|
|
|
19
19
|
Provides-Extra: cloud
|
|
20
20
|
Provides-Extra: llm
|
|
21
21
|
Provides-Extra: streamlit
|
|
22
|
-
Requires-Dist: mypy (>=1.15.0,<2.0.0)
|
|
23
22
|
Project-URL: Documentation, https://jac-lang.org
|
|
24
23
|
Project-URL: Homepage, https://jaseci.org
|
|
25
24
|
Project-URL: Repository, https://github.com/Jaseci-Labs/jaclang
|