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/runtimelib/machine.py
CHANGED
|
@@ -34,10 +34,10 @@ from uuid import UUID
|
|
|
34
34
|
from jaclang.compiler.constant import Constants as Con, EdgeDir, colors
|
|
35
35
|
from jaclang.compiler.program import JacProgram
|
|
36
36
|
from jaclang.runtimelib.archetype import (
|
|
37
|
-
DataSpatialDestination,
|
|
38
|
-
DataSpatialFunction,
|
|
39
|
-
DataSpatialPath,
|
|
40
37
|
GenericEdge as _GenericEdge,
|
|
38
|
+
ObjectSpatialDestination,
|
|
39
|
+
ObjectSpatialFunction,
|
|
40
|
+
ObjectSpatialPath,
|
|
41
41
|
Root as _Root,
|
|
42
42
|
)
|
|
43
43
|
from jaclang.runtimelib.constructs import (
|
|
@@ -267,7 +267,7 @@ class JacNode:
|
|
|
267
267
|
|
|
268
268
|
@staticmethod
|
|
269
269
|
def get_edges(
|
|
270
|
-
origin: list[NodeArchetype], destination:
|
|
270
|
+
origin: list[NodeArchetype], destination: ObjectSpatialDestination
|
|
271
271
|
) -> list[EdgeArchetype]:
|
|
272
272
|
"""Get edges connected to this node."""
|
|
273
273
|
edges: OrderedDict[EdgeAnchor, EdgeArchetype] = OrderedDict()
|
|
@@ -300,7 +300,7 @@ class JacNode:
|
|
|
300
300
|
@staticmethod
|
|
301
301
|
def get_edges_with_node(
|
|
302
302
|
origin: list[NodeArchetype],
|
|
303
|
-
destination:
|
|
303
|
+
destination: ObjectSpatialDestination,
|
|
304
304
|
from_visit: bool = False,
|
|
305
305
|
) -> list[EdgeArchetype | NodeArchetype]:
|
|
306
306
|
"""Get edges connected to this node and the node."""
|
|
@@ -337,7 +337,7 @@ class JacNode:
|
|
|
337
337
|
|
|
338
338
|
@staticmethod
|
|
339
339
|
def edges_to_nodes(
|
|
340
|
-
origin: list[NodeArchetype], destination:
|
|
340
|
+
origin: list[NodeArchetype], destination: ObjectSpatialDestination
|
|
341
341
|
) -> list[NodeArchetype]:
|
|
342
342
|
"""Get set of nodes connected to this node."""
|
|
343
343
|
nodes: OrderedDict[NodeAnchor, NodeArchetype] = OrderedDict()
|
|
@@ -424,36 +424,6 @@ class JacWalker:
|
|
|
424
424
|
else:
|
|
425
425
|
raise TypeError("Invalid walker object")
|
|
426
426
|
|
|
427
|
-
@staticmethod
|
|
428
|
-
def ignore(
|
|
429
|
-
walker: WalkerArchetype,
|
|
430
|
-
expr: (
|
|
431
|
-
list[NodeArchetype | EdgeArchetype]
|
|
432
|
-
| list[NodeArchetype]
|
|
433
|
-
| list[EdgeArchetype]
|
|
434
|
-
| NodeArchetype
|
|
435
|
-
| EdgeArchetype
|
|
436
|
-
),
|
|
437
|
-
) -> bool: # noqa: ANN401
|
|
438
|
-
"""Jac's ignore stmt feature."""
|
|
439
|
-
if isinstance(walker, WalkerArchetype):
|
|
440
|
-
wanch = walker.__jac__
|
|
441
|
-
before_len = len(wanch.ignores)
|
|
442
|
-
for anchor in (
|
|
443
|
-
(i.__jac__ for i in expr) if isinstance(expr, list) else [expr.__jac__]
|
|
444
|
-
):
|
|
445
|
-
if anchor not in wanch.ignores:
|
|
446
|
-
if isinstance(anchor, NodeAnchor):
|
|
447
|
-
wanch.ignores.append(anchor)
|
|
448
|
-
elif isinstance(anchor, EdgeAnchor):
|
|
449
|
-
if target := anchor.target:
|
|
450
|
-
wanch.ignores.append(target)
|
|
451
|
-
else:
|
|
452
|
-
raise ValueError("Edge has no target.")
|
|
453
|
-
return len(wanch.ignores) > before_len
|
|
454
|
-
else:
|
|
455
|
-
raise TypeError("Invalid walker object")
|
|
456
|
-
|
|
457
427
|
@staticmethod
|
|
458
428
|
def spawn_call(
|
|
459
429
|
walker: WalkerAnchor,
|
|
@@ -718,7 +688,7 @@ class JacClassReferences:
|
|
|
718
688
|
|
|
719
689
|
TYPE_CHECKING: bool = TYPE_CHECKING
|
|
720
690
|
EdgeDir: TypeAlias = EdgeDir
|
|
721
|
-
DSFunc: TypeAlias =
|
|
691
|
+
DSFunc: TypeAlias = ObjectSpatialFunction
|
|
722
692
|
|
|
723
693
|
Obj: TypeAlias = Archetype
|
|
724
694
|
Node: TypeAlias = NodeArchetype
|
|
@@ -728,7 +698,7 @@ class JacClassReferences:
|
|
|
728
698
|
Root: TypeAlias = _Root
|
|
729
699
|
GenericEdge: TypeAlias = _GenericEdge
|
|
730
700
|
|
|
731
|
-
Path: TypeAlias =
|
|
701
|
+
Path: TypeAlias = ObjectSpatialPath
|
|
732
702
|
|
|
733
703
|
|
|
734
704
|
class JacBuiltin:
|
|
@@ -1102,17 +1072,18 @@ class JacBasics:
|
|
|
1102
1072
|
if custom:
|
|
1103
1073
|
ctx.custom = expr
|
|
1104
1074
|
else:
|
|
1075
|
+
print(expr)
|
|
1105
1076
|
ctx.reports.append(expr)
|
|
1106
1077
|
|
|
1107
1078
|
@staticmethod
|
|
1108
1079
|
def refs(
|
|
1109
|
-
path:
|
|
1080
|
+
path: ObjectSpatialPath | NodeArchetype | list[NodeArchetype],
|
|
1110
1081
|
) -> (
|
|
1111
1082
|
list[NodeArchetype] | list[EdgeArchetype] | list[NodeArchetype | EdgeArchetype]
|
|
1112
1083
|
):
|
|
1113
1084
|
"""Jac's apply_dir stmt feature."""
|
|
1114
|
-
if not isinstance(path,
|
|
1115
|
-
path =
|
|
1085
|
+
if not isinstance(path, ObjectSpatialPath):
|
|
1086
|
+
path = ObjectSpatialPath(path, [ObjectSpatialDestination(EdgeDir.OUT)])
|
|
1116
1087
|
|
|
1117
1088
|
origin = path.origin
|
|
1118
1089
|
|
|
@@ -1133,7 +1104,14 @@ class JacBasics:
|
|
|
1133
1104
|
return origin
|
|
1134
1105
|
|
|
1135
1106
|
@staticmethod
|
|
1136
|
-
def
|
|
1107
|
+
async def arefs(
|
|
1108
|
+
path: ObjectSpatialPath | NodeArchetype | list[NodeArchetype],
|
|
1109
|
+
) -> None:
|
|
1110
|
+
"""Jac's apply_dir stmt feature."""
|
|
1111
|
+
pass
|
|
1112
|
+
|
|
1113
|
+
@staticmethod
|
|
1114
|
+
def filter_on(
|
|
1137
1115
|
items: list[Archetype],
|
|
1138
1116
|
func: Callable[[Archetype], bool],
|
|
1139
1117
|
) -> list[Archetype]:
|
|
@@ -1219,7 +1197,7 @@ class JacBasics:
|
|
|
1219
1197
|
return disconnect_occurred
|
|
1220
1198
|
|
|
1221
1199
|
@staticmethod
|
|
1222
|
-
def
|
|
1200
|
+
def assign_all(target: list[T], attr_val: tuple[tuple[str], tuple[Any]]) -> list[T]:
|
|
1223
1201
|
"""Jac's assign comprehension feature."""
|
|
1224
1202
|
for obj in target:
|
|
1225
1203
|
attrs, values = attr_val
|
|
@@ -1321,17 +1299,26 @@ class JacBasics:
|
|
|
1321
1299
|
JacMachineInterface.get_context().mem.remove(anchor.id)
|
|
1322
1300
|
|
|
1323
1301
|
@staticmethod
|
|
1324
|
-
def
|
|
1302
|
+
def on_entry(func: Callable) -> Callable:
|
|
1325
1303
|
"""Mark a method as jac entry with this decorator."""
|
|
1326
1304
|
setattr(func, "__jac_entry", None) # noqa:B010
|
|
1327
1305
|
return func
|
|
1328
1306
|
|
|
1329
1307
|
@staticmethod
|
|
1330
|
-
def
|
|
1308
|
+
def on_exit(func: Callable) -> Callable:
|
|
1331
1309
|
"""Mark a method as jac exit with this decorator."""
|
|
1332
1310
|
setattr(func, "__jac_exit", None) # noqa:B010
|
|
1333
1311
|
return func
|
|
1334
1312
|
|
|
1313
|
+
|
|
1314
|
+
class JacByLLM:
|
|
1315
|
+
"""Jac byLLM integration."""
|
|
1316
|
+
|
|
1317
|
+
@staticmethod
|
|
1318
|
+
def get_mtir(caller: Callable, args: dict, call_params: dict) -> object:
|
|
1319
|
+
"""Get byLLM library."""
|
|
1320
|
+
return None
|
|
1321
|
+
|
|
1335
1322
|
@staticmethod
|
|
1336
1323
|
def sem(semstr: str, inner_semstr: dict[str, str]) -> Callable:
|
|
1337
1324
|
"""Attach the semstring to the given object."""
|
|
@@ -1345,11 +1332,39 @@ class JacBasics:
|
|
|
1345
1332
|
|
|
1346
1333
|
@staticmethod
|
|
1347
1334
|
def call_llm(model: object, mtir: object) -> Any: # noqa: ANN401
|
|
1348
|
-
"""Call the LLM model.
|
|
1335
|
+
"""Call the LLM model.
|
|
1336
|
+
|
|
1337
|
+
Note: This is for future uses of the feature in contexts that cannot be decorated.
|
|
1338
|
+
For most use cases, use the `by` decorator instead.
|
|
1339
|
+
"""
|
|
1349
1340
|
raise ImportError(
|
|
1350
1341
|
"byLLM is not installed. Please install it with `pip install byllm` and run `jac clean`."
|
|
1351
1342
|
)
|
|
1352
1343
|
|
|
1344
|
+
@staticmethod
|
|
1345
|
+
def by(model: object) -> Callable:
|
|
1346
|
+
"""Python library mode decorator for Jac's by llm() syntax."""
|
|
1347
|
+
|
|
1348
|
+
def _decorator(caller: Callable) -> Callable:
|
|
1349
|
+
def _wrapped_caller(*args: object, **kwargs: object) -> object:
|
|
1350
|
+
invoke_args: dict[int | str, object] = {}
|
|
1351
|
+
for i, arg in enumerate(args):
|
|
1352
|
+
invoke_args[i] = arg
|
|
1353
|
+
for key, value in kwargs.items():
|
|
1354
|
+
invoke_args[key] = value
|
|
1355
|
+
mtir = JacMachine.get_mtir(
|
|
1356
|
+
caller=caller,
|
|
1357
|
+
args=invoke_args,
|
|
1358
|
+
call_params=(
|
|
1359
|
+
model.call_params if hasattr(model, "call_params") else {}
|
|
1360
|
+
),
|
|
1361
|
+
)
|
|
1362
|
+
return JacMachine.call_llm(model, mtir)
|
|
1363
|
+
|
|
1364
|
+
return _wrapped_caller
|
|
1365
|
+
|
|
1366
|
+
return _decorator
|
|
1367
|
+
|
|
1353
1368
|
|
|
1354
1369
|
class JacUtils:
|
|
1355
1370
|
"""Jac Machine Utilities."""
|
|
@@ -1566,6 +1581,7 @@ class JacMachineInterface(
|
|
|
1566
1581
|
JacBuiltin,
|
|
1567
1582
|
JacCmd,
|
|
1568
1583
|
JacBasics,
|
|
1584
|
+
JacByLLM,
|
|
1569
1585
|
JacUtils,
|
|
1570
1586
|
):
|
|
1571
1587
|
"""Jac Feature."""
|
|
@@ -1709,4 +1725,5 @@ class JacMachine(JacMachineInterface):
|
|
|
1709
1725
|
JacMachine.base_path_dir = os.getcwd()
|
|
1710
1726
|
JacMachine.program = JacProgram()
|
|
1711
1727
|
JacMachine.pool = ThreadPoolExecutor()
|
|
1728
|
+
JacMachine.exec_ctx.mem.close()
|
|
1712
1729
|
JacMachine.exec_ctx = ExecutionContext()
|
|
@@ -9,7 +9,8 @@ from typing import Optional, Sequence
|
|
|
9
9
|
|
|
10
10
|
from jaclang.runtimelib.machine import JacMachine as Jac
|
|
11
11
|
from jaclang.runtimelib.machine import JacMachineInterface
|
|
12
|
-
from jaclang.
|
|
12
|
+
from jaclang.settings import settings
|
|
13
|
+
from jaclang.utils.module_resolver import get_jac_search_paths, get_py_search_paths
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class JacMetaImporter(importlib.abc.MetaPathFinder, importlib.abc.Loader):
|
|
@@ -48,6 +49,30 @@ class JacMetaImporter(importlib.abc.MetaPathFinder, importlib.abc.Loader):
|
|
|
48
49
|
return importlib.util.spec_from_file_location(
|
|
49
50
|
fullname, candidate_path + ".jac", loader=self
|
|
50
51
|
)
|
|
52
|
+
|
|
53
|
+
# TODO: We can remove it once python modules are fully supported in jac
|
|
54
|
+
if path is None and settings.pyfile_raise:
|
|
55
|
+
if settings.pyfile_raise_full:
|
|
56
|
+
paths_to_search = get_jac_search_paths()
|
|
57
|
+
else:
|
|
58
|
+
paths_to_search = get_py_search_paths()
|
|
59
|
+
for search_path in paths_to_search:
|
|
60
|
+
candidate_path = os.path.join(search_path, *module_path_parts)
|
|
61
|
+
# Check for directory package
|
|
62
|
+
if os.path.isdir(candidate_path):
|
|
63
|
+
init_file = os.path.join(candidate_path, "__init__.py")
|
|
64
|
+
if os.path.isfile(init_file):
|
|
65
|
+
return importlib.util.spec_from_file_location(
|
|
66
|
+
fullname,
|
|
67
|
+
init_file,
|
|
68
|
+
loader=self,
|
|
69
|
+
submodule_search_locations=[candidate_path],
|
|
70
|
+
)
|
|
71
|
+
# Check for .py file
|
|
72
|
+
if os.path.isfile(candidate_path + ".py"):
|
|
73
|
+
return importlib.util.spec_from_file_location(
|
|
74
|
+
fullname, candidate_path + ".py", loader=self
|
|
75
|
+
)
|
|
51
76
|
return None
|
|
52
77
|
|
|
53
78
|
def create_module(
|
|
@@ -78,6 +103,7 @@ class JacMetaImporter(importlib.abc.MetaPathFinder, importlib.abc.Loader):
|
|
|
78
103
|
target=target,
|
|
79
104
|
base_path=base_path,
|
|
80
105
|
override_name=module.__name__,
|
|
106
|
+
lng="py" if file_path.endswith(".py") else "jac",
|
|
81
107
|
)
|
|
82
108
|
if ret:
|
|
83
109
|
loaded_module = ret[0]
|
|
@@ -44,7 +44,7 @@ walker create_custom_object {
|
|
|
44
44
|
|
|
45
45
|
can exit1 with `root exit {
|
|
46
46
|
# get directly from shelf
|
|
47
|
-
o =
|
|
47
|
+
o = _jl.get_context().mem.__shelf__.get(str(self.obj.__jac__.id)).archetype;
|
|
48
48
|
print(jid(o));
|
|
49
49
|
print(o);
|
|
50
50
|
}
|
|
@@ -87,6 +87,6 @@ walker delete_custom_object {
|
|
|
87
87
|
has object_id: str;
|
|
88
88
|
|
|
89
89
|
can enter1 with `root entry {
|
|
90
|
-
|
|
90
|
+
_jl.destroy([&(self.object_id)]);
|
|
91
91
|
}
|
|
92
92
|
}
|
jaclang/settings.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import configparser
|
|
4
4
|
import os
|
|
5
|
+
from argparse import Namespace
|
|
5
6
|
from dataclasses import dataclass, fields
|
|
6
7
|
|
|
7
8
|
|
|
@@ -13,17 +14,21 @@ class Settings:
|
|
|
13
14
|
filter_sym_builtins: bool = True
|
|
14
15
|
ast_symbol_info_detailed: bool = False
|
|
15
16
|
pass_timer: bool = False
|
|
16
|
-
collect_py_dep_debug: bool = False
|
|
17
17
|
print_py_raised_ast: bool = False
|
|
18
18
|
|
|
19
19
|
# Compiler configuration
|
|
20
|
-
disable_mtllm: bool = False
|
|
21
20
|
ignore_test_annex: bool = False
|
|
22
|
-
pyout_jaclib_alias: str = "
|
|
21
|
+
pyout_jaclib_alias: str = "_jl"
|
|
22
|
+
library_mode: bool = False
|
|
23
|
+
pyfile_raise: bool = False
|
|
24
|
+
pyfile_raise_full: bool = False
|
|
23
25
|
|
|
24
26
|
# Formatter configuration
|
|
25
27
|
max_line_length: int = 88
|
|
26
28
|
|
|
29
|
+
# pytorch configuration
|
|
30
|
+
predynamo_pass: bool = False
|
|
31
|
+
|
|
27
32
|
# LSP configuration
|
|
28
33
|
lsp_debug: bool = False
|
|
29
34
|
|
|
@@ -42,6 +47,8 @@ class Settings:
|
|
|
42
47
|
"""Load settings from all available sources."""
|
|
43
48
|
self.load_config_file()
|
|
44
49
|
self.load_env_vars()
|
|
50
|
+
# CLI arguments are applied by the CLI after parsing, via
|
|
51
|
+
# `settings.load_command_line_arguments(args)` in start_cli.
|
|
45
52
|
|
|
46
53
|
def load_config_file(self) -> None:
|
|
47
54
|
"""Load settings from a configuration file."""
|
|
@@ -64,19 +71,15 @@ class Settings:
|
|
|
64
71
|
if env_value is not None:
|
|
65
72
|
setattr(self, key, self.convert_type(env_value))
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
# )
|
|
77
|
-
# parser.add_argument("--port", type=int, default=self.config["port"])
|
|
78
|
-
# parser.add_argument("--host", default=self.config["host"])
|
|
79
|
-
# args = parser.parse_args()
|
|
74
|
+
def load_command_line_arguments(self, args: Namespace) -> None:
|
|
75
|
+
"""Override settings from command-line arguments if provided."""
|
|
76
|
+
args_dict = vars(args) if not isinstance(args, dict) else args
|
|
77
|
+
for key in [f.name for f in fields(self)]:
|
|
78
|
+
if key in args_dict and args_dict[key] is not None:
|
|
79
|
+
val = args_dict[key]
|
|
80
|
+
if isinstance(val, str):
|
|
81
|
+
val = self.convert_type(val)
|
|
82
|
+
setattr(self, key, val)
|
|
80
83
|
|
|
81
84
|
def str_to_bool(self, value: str) -> bool:
|
|
82
85
|
"""Convert string to boolean."""
|
|
@@ -63,15 +63,15 @@ with entry:__main__ {
|
|
|
63
63
|
glob expected_area = 78.53981633974483;
|
|
64
64
|
|
|
65
65
|
test calc_area {
|
|
66
|
-
|
|
66
|
+
assert almostEqual(calculate_area(RAD), expected_area);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
test circle_area {
|
|
70
70
|
c = Circle(RAD);
|
|
71
|
-
|
|
71
|
+
assert almostEqual(c.area(), expected_area);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
test circle_type {
|
|
75
75
|
c = Circle(RAD);
|
|
76
|
-
|
|
76
|
+
assert c.shape_type == ShapeType.CIRCLE;
|
|
77
77
|
}
|
|
@@ -3,20 +3,20 @@ import from jaclang.runtimelib.machine { JacMachine }
|
|
|
3
3
|
|
|
4
4
|
glob dynamic_module_source =
|
|
5
5
|
"""
|
|
6
|
-
|
|
6
|
+
import from arch_create_util {UtilityNode}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
walker DynamicWalker {
|
|
9
|
+
can start with entry {
|
|
10
|
+
print("DynamicWalker Started");
|
|
11
|
+
here ++> UtilityNode(data=42);
|
|
12
|
+
visit [-->](`?UtilityNode);
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
def UtilityNode {
|
|
16
|
+
here.display_data();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
""";
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
with entry {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import re;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
glob a
|
|
4
|
+
glob a: int = 5;
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
with entry {
|
|
8
8
|
arguments = { x : None for x in re.findall(r'\{([A-Za-z0-9_]+)\}', "Apple {apple} pineapple {pineapple}") };
|
|
9
|
-
a
|
|
9
|
+
a: int = 5;
|
|
10
10
|
if False {
|
|
11
|
-
with open(f"Apple{apple}.txt") as f
|
|
11
|
+
with open(f"Apple{apple}.txt") as f {
|
|
12
12
|
# Fix syntax highlighting
|
|
13
13
|
print(
|
|
14
14
|
f.read()
|
|
@@ -2,23 +2,23 @@ import from jaclang.runtimelib.machine { JacMachine }
|
|
|
2
2
|
# Dynamically create a node archetype
|
|
3
3
|
glob source_code =
|
|
4
4
|
"""
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
node dynamic_node {
|
|
6
|
+
has value:int;
|
|
7
|
+
can print_value with entry {
|
|
8
|
+
print("Dynamic Node Value:", f'{self.value}');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
""";
|
|
12
12
|
|
|
13
13
|
# Create a new walker archetype dynamically
|
|
14
14
|
glob walker_code =
|
|
15
15
|
"""
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
walker dynamic_walker {
|
|
17
|
+
can visit_nodes with entry {
|
|
18
|
+
visit [-->];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
""";
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
with entry {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
glob x = 5, y = 2;
|
|
2
2
|
|
|
3
3
|
test a {
|
|
4
|
-
|
|
4
|
+
assert almostEqual(5, x);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
test b {
|
|
8
|
-
|
|
8
|
+
assert "l" in "llm";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
test c {
|
|
12
|
-
|
|
12
|
+
assert x - y == 3;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
test d {
|
|
16
|
-
|
|
16
|
+
assert 1 == 2;
|
|
17
17
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Test complex parameter combinations
|
|
2
|
+
|
|
3
|
+
def ultimate_signature(
|
|
4
|
+
pos_only: int,
|
|
5
|
+
pos_def: str = "def",
|
|
6
|
+
/,
|
|
7
|
+
reg_def: bool = True,
|
|
8
|
+
*args: int,
|
|
9
|
+
kw_req: str,
|
|
10
|
+
kw_opt: int = 100,
|
|
11
|
+
**kwargs: any
|
|
12
|
+
) -> str {
|
|
13
|
+
return f"{pos_only}|{pos_def}|{reg_def}|{len(args)}|{kw_req}|{kw_opt}|{len(kwargs)}";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
def separators_only(/, *, x: int) -> int {
|
|
17
|
+
return x;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
def edge_case_mix(a: int, /, b: str, *args: float, c: bool, **kwargs: str) -> str {
|
|
21
|
+
return f"{a}-{b}-{len(args)}-{c}-{len(kwargs)}";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def recursive_test(data: int, /, depth: int = 0, *, max_depth: int = 2) -> int {
|
|
25
|
+
if depth >= max_depth {
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
return recursive_test(data + 1, depth + 1, max_depth=max_depth);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def validation_test(x: int, y: str = "test", /, z: float, *args: int, w: bool, **kwargs: str) -> str {
|
|
32
|
+
return f"x:{x},y:{y},z:{z},args:{len(args)},w:{w},kwargs:{len(kwargs)}";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
with entry {
|
|
36
|
+
print("ULTIMATE_MIN:", ultimate_signature(1, reg_def=2.5, kw_req="test"));
|
|
37
|
+
print("ULTIMATE_FULL:", ultimate_signature(1, "custom", 3.14, False, 10, 20, kw_req="req", kw_opt=200, extra="data"));
|
|
38
|
+
print("SEPARATORS:", separators_only(x=42));
|
|
39
|
+
print("EDGE_MIX:", edge_case_mix(1, "test", 1.1, 2.2, c=True, name="edge"));
|
|
40
|
+
print("RECURSIVE:", recursive_test(5), recursive_test(10, max_depth=1));
|
|
41
|
+
print("VALIDATION:", validation_test(1, 2.5, 10, 20, w=True, debug="on"));
|
|
42
|
+
}
|