jaclang 0.7.21__py3-none-any.whl → 0.7.23__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 +5 -10
- jaclang/cli/cli.py +4 -1
- jaclang/compiler/absyntree.py +28 -3
- jaclang/compiler/passes/main/pyast_load_pass.py +8 -6
- jaclang/compiler/passes/main/tests/fixtures/fstrings.jac +44 -1
- jaclang/compiler/passes/main/type_check_pass.py +8 -6
- jaclang/plugin/builtin.py +3 -3
- jaclang/plugin/default.py +582 -206
- jaclang/plugin/feature.py +273 -98
- jaclang/plugin/spec.py +229 -85
- jaclang/plugin/tests/fixtures/other_root_access.jac +9 -9
- jaclang/plugin/tests/test_features.py +2 -2
- jaclang/runtimelib/architype.py +1 -370
- jaclang/runtimelib/constructs.py +2 -0
- jaclang/runtimelib/context.py +0 -4
- jaclang/runtimelib/machine.py +57 -0
- jaclang/runtimelib/memory.py +2 -4
- jaclang/tests/fixtures/arch_create_util.jac +7 -0
- jaclang/tests/fixtures/arch_rel_import_creation.jac +30 -0
- jaclang/tests/fixtures/create_dynamic_architype.jac +35 -0
- jaclang/tests/fixtures/edge_node_walk.jac +1 -1
- jaclang/tests/fixtures/edges_walk.jac +1 -1
- jaclang/tests/fixtures/gendot_bubble_sort.jac +1 -1
- jaclang/tests/fixtures/visit_order.jac +20 -0
- jaclang/tests/test_language.py +72 -7
- {jaclang-0.7.21.dist-info → jaclang-0.7.23.dist-info}/METADATA +1 -1
- {jaclang-0.7.21.dist-info → jaclang-0.7.23.dist-info}/RECORD +29 -25
- {jaclang-0.7.21.dist-info → jaclang-0.7.23.dist-info}/WHEEL +0 -0
- {jaclang-0.7.21.dist-info → jaclang-0.7.23.dist-info}/entry_points.txt +0 -0
jaclang/__init__.py
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"""The Jac Programming Language."""
|
|
2
2
|
|
|
3
|
-
from jaclang.plugin.default import
|
|
4
|
-
|
|
5
|
-
JacCmdDefaults,
|
|
6
|
-
JacFeatureDefaults,
|
|
7
|
-
)
|
|
8
|
-
from jaclang.plugin.feature import JacFeature, pm # noqa: E402
|
|
3
|
+
from jaclang.plugin.default import JacFeatureImpl
|
|
4
|
+
from jaclang.plugin.feature import JacFeature, plugin_manager
|
|
9
5
|
|
|
10
6
|
jac_import = JacFeature.jac_import
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
pm.load_setuptools_entrypoints("jac")
|
|
8
|
+
|
|
9
|
+
plugin_manager.register(JacFeatureImpl)
|
|
10
|
+
plugin_manager.load_setuptools_entrypoints("jac")
|
|
16
11
|
|
|
17
12
|
__all__ = ["jac_import"]
|
jaclang/cli/cli.py
CHANGED
|
@@ -28,6 +28,7 @@ from jaclang.utils.lang_tools import AstTool
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
Cmd.create_cmd()
|
|
31
|
+
Jac.setup()
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
@cmd_registry.register
|
|
@@ -283,7 +284,9 @@ def enter(
|
|
|
283
284
|
|
|
284
285
|
jctx.set_entry_node(node)
|
|
285
286
|
|
|
286
|
-
if isinstance(architype, WalkerArchitype) and
|
|
287
|
+
if isinstance(architype, WalkerArchitype) and Jac.check_read_access(
|
|
288
|
+
jctx.entry_node
|
|
289
|
+
):
|
|
287
290
|
Jac.spawn_call(jctx.entry_node.architype, architype)
|
|
288
291
|
|
|
289
292
|
jctx.close()
|
jaclang/compiler/absyntree.py
CHANGED
|
@@ -2873,13 +2873,24 @@ class FString(AtomExpr):
|
|
|
2873
2873
|
if deep:
|
|
2874
2874
|
res = self.parts.normalize(deep) if self.parts else res
|
|
2875
2875
|
new_kid: list[AstNode] = []
|
|
2876
|
+
is_single_quote = (
|
|
2877
|
+
isinstance(self.kid[0], Token) and self.kid[0].name == Tok.FSTR_SQ_START
|
|
2878
|
+
)
|
|
2876
2879
|
if self.parts:
|
|
2880
|
+
if is_single_quote:
|
|
2881
|
+
new_kid.append(self.gen_token(Tok.FSTR_SQ_START))
|
|
2882
|
+
else:
|
|
2883
|
+
new_kid.append(self.gen_token(Tok.FSTR_START))
|
|
2877
2884
|
for i in self.parts.items:
|
|
2878
2885
|
if isinstance(i, String):
|
|
2879
2886
|
i.value = (
|
|
2880
2887
|
"{{" if i.value == "{" else "}}" if i.value == "}" else i.value
|
|
2881
2888
|
)
|
|
2882
2889
|
new_kid.append(self.parts)
|
|
2890
|
+
if is_single_quote:
|
|
2891
|
+
new_kid.append(self.gen_token(Tok.FSTR_SQ_END))
|
|
2892
|
+
else:
|
|
2893
|
+
new_kid.append(self.gen_token(Tok.FSTR_END))
|
|
2883
2894
|
self.set_kids(nodes=new_kid)
|
|
2884
2895
|
return res
|
|
2885
2896
|
|
|
@@ -4257,7 +4268,6 @@ class String(Literal):
|
|
|
4257
4268
|
"""Return literal value in its python type."""
|
|
4258
4269
|
if isinstance(self.value, bytes):
|
|
4259
4270
|
return self.value
|
|
4260
|
-
prefix_len = 3 if self.value.startswith(("'''", '"""')) else 1
|
|
4261
4271
|
if any(
|
|
4262
4272
|
self.value.startswith(prefix)
|
|
4263
4273
|
and self.value[len(prefix) :].startswith(("'", '"'))
|
|
@@ -4266,8 +4276,23 @@ class String(Literal):
|
|
|
4266
4276
|
return eval(self.value)
|
|
4267
4277
|
|
|
4268
4278
|
elif self.value.startswith(("'", '"')):
|
|
4269
|
-
|
|
4270
|
-
|
|
4279
|
+
repr_str = self.value.encode().decode("unicode_escape")
|
|
4280
|
+
if (
|
|
4281
|
+
self.value.startswith('"""')
|
|
4282
|
+
and self.value.endswith('"""')
|
|
4283
|
+
and not self.find_parent_of_type(FString)
|
|
4284
|
+
):
|
|
4285
|
+
return repr_str[3:-3]
|
|
4286
|
+
if (not self.find_parent_of_type(FString)) or (
|
|
4287
|
+
not (
|
|
4288
|
+
self.parent
|
|
4289
|
+
and isinstance(self.parent, SubNodeList)
|
|
4290
|
+
and self.parent.parent
|
|
4291
|
+
and isinstance(self.parent.parent, FString)
|
|
4292
|
+
)
|
|
4293
|
+
):
|
|
4294
|
+
return repr_str[1:-1]
|
|
4295
|
+
return repr_str
|
|
4271
4296
|
else:
|
|
4272
4297
|
return self.value
|
|
4273
4298
|
|
|
@@ -1148,14 +1148,16 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
|
|
|
1148
1148
|
else:
|
|
1149
1149
|
token_type = f"{value_type.__name__.upper()}"
|
|
1150
1150
|
|
|
1151
|
+
if value_type == str:
|
|
1152
|
+
raw_repr = repr(node.value)
|
|
1153
|
+
quote = "'" if raw_repr.startswith("'") else '"'
|
|
1154
|
+
value = f"{quote}{raw_repr[1:-1]}{quote}"
|
|
1155
|
+
else:
|
|
1156
|
+
value = str(node.value)
|
|
1151
1157
|
return type_mapping[value_type](
|
|
1152
1158
|
file_path=self.mod_path,
|
|
1153
1159
|
name=token_type,
|
|
1154
|
-
value=
|
|
1155
|
-
f'"{repr(node.value)[1:-1]}"'
|
|
1156
|
-
if value_type == str
|
|
1157
|
-
else str(node.value)
|
|
1158
|
-
),
|
|
1160
|
+
value=value,
|
|
1159
1161
|
line=node.lineno,
|
|
1160
1162
|
end_line=node.end_lineno if node.end_lineno else node.lineno,
|
|
1161
1163
|
col_start=node.col_offset,
|
|
@@ -2625,7 +2627,7 @@ class PyastBuildPass(Pass[ast.PythonModuleAst]):
|
|
|
2625
2627
|
|
|
2626
2628
|
def convert_to_doc(self, string: ast.String) -> None:
|
|
2627
2629
|
"""Convert a string to a docstring."""
|
|
2628
|
-
string.value = f'""{string.value}""'
|
|
2630
|
+
string.value = f'"""{string.value[1:-1]}"""'
|
|
2629
2631
|
|
|
2630
2632
|
def aug_op_map(self, tok_dict: dict, op: ast.Token) -> str:
|
|
2631
2633
|
"""aug_mapper."""
|
|
@@ -1,4 +1,47 @@
|
|
|
1
1
|
"""Small test for fstrings."""
|
|
2
2
|
|
|
3
|
+
glob apple = 2;
|
|
4
|
+
glob a=f"hello {40 + 2} wor{apple}ld ";
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
with entry {
|
|
7
|
+
a = 9;
|
|
8
|
+
s_2 = "'''hello'''";
|
|
9
|
+
s_3 = "'''hello '''";
|
|
10
|
+
s_4 = "''' hello'''";
|
|
11
|
+
s_5 = '""" hello"""';
|
|
12
|
+
s_6 = '"""hello"""';
|
|
13
|
+
s_7 = '"""hello"" "';
|
|
14
|
+
s_8 = '"""hello""" ';
|
|
15
|
+
print(
|
|
16
|
+
len(s_2),
|
|
17
|
+
len(s_3),
|
|
18
|
+
len(s_4),
|
|
19
|
+
len(s_5),
|
|
20
|
+
len(s_6),
|
|
21
|
+
len(s_7),
|
|
22
|
+
len(s_8)
|
|
23
|
+
) ;
|
|
24
|
+
b1 = f"{"'''hello''' "}";
|
|
25
|
+
b_2 = f"{'"""hello""" '}";
|
|
26
|
+
f_1 = f"{'hello '}{a}{'"""hello"""'}";
|
|
27
|
+
f_2 = f"{'hello '}{a}{"'''hello'''"}";
|
|
28
|
+
print(len(b1),len(b_2), b_2,len(f_1), len(f_2)) ;
|
|
29
|
+
f_3 = f"{'"""again"""'}";
|
|
30
|
+
f_4 = f"{'"""again""" '}";
|
|
31
|
+
f_5 = f"{"'''again'''"}";
|
|
32
|
+
f_6 = f"{"'''again''' "}";
|
|
33
|
+
f_7 = f"{'"""again"""'}";
|
|
34
|
+
f_s1 = f"{'hello '}{a}{'"""hello"""'}";
|
|
35
|
+
f_s2 = f"{'hello '}{a}{"'''hello'''"}{'kklkl'}";
|
|
36
|
+
print(
|
|
37
|
+
len(f_3),
|
|
38
|
+
len(f_4),
|
|
39
|
+
len(f_5),
|
|
40
|
+
len(f_6),
|
|
41
|
+
len(f_7),
|
|
42
|
+
len(f_s1), len(f_s2)
|
|
43
|
+
) ;
|
|
44
|
+
"""sdfsdf\nsdfsdfsdfsd dffgdfgd.""" ;
|
|
45
|
+
}
|
|
46
|
+
can func() {;
|
|
47
|
+
}
|
|
@@ -50,12 +50,6 @@ class JacTypeCheckPass(Pass):
|
|
|
50
50
|
options = myab.myb.Options()
|
|
51
51
|
options.ignore_missing_imports = True
|
|
52
52
|
options.cache_dir = Con.JAC_MYPY_CACHE
|
|
53
|
-
options.mypy_path = [
|
|
54
|
-
# str( # TODO: Remove me, this was the wrong way to point to stubs
|
|
55
|
-
# pathlib.Path(os.path.dirname(__file__)).parent.parent.parent.parent
|
|
56
|
-
# / "stubs"
|
|
57
|
-
# )
|
|
58
|
-
]
|
|
59
53
|
if top_module_path != "":
|
|
60
54
|
options.mypy_path.append(top_module_path)
|
|
61
55
|
|
|
@@ -116,6 +110,14 @@ class JacTypeCheckPass(Pass):
|
|
|
116
110
|
old_graph=mypy_graph,
|
|
117
111
|
new_modules=new_modules, # To parse the dependancies of modules
|
|
118
112
|
)
|
|
113
|
+
mypy_graph = {
|
|
114
|
+
k: v
|
|
115
|
+
for k, v in mypy_graph.items()
|
|
116
|
+
if (
|
|
117
|
+
k.startswith("jaclang.plugin")
|
|
118
|
+
or not (k.startswith("jaclang.") or k.startswith("mypy."))
|
|
119
|
+
)
|
|
120
|
+
}
|
|
119
121
|
for i in mypy_graph:
|
|
120
122
|
self.ir.py_mod_dep_map[i] = mypy_graph[i].xpath
|
|
121
123
|
for j in mypy_graph[i].dependencies:
|
jaclang/plugin/builtin.py
CHANGED
|
@@ -19,9 +19,9 @@ def dotgen(
|
|
|
19
19
|
dot_file: Optional[str] = None,
|
|
20
20
|
) -> str:
|
|
21
21
|
"""Print the dot graph."""
|
|
22
|
-
from jaclang.plugin.feature import
|
|
22
|
+
from jaclang.plugin.feature import JacFeature as Jac
|
|
23
23
|
|
|
24
|
-
root =
|
|
24
|
+
root = Jac.get_root()
|
|
25
25
|
node = node if node is not None else root
|
|
26
26
|
depth = depth if depth is not None else -1
|
|
27
27
|
traverse = traverse if traverse is not None else False
|
|
@@ -29,7 +29,7 @@ def dotgen(
|
|
|
29
29
|
edge_limit = edge_limit if edge_limit is not None else 512
|
|
30
30
|
node_limit = node_limit if node_limit is not None else 512
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return Jac.dotgen(
|
|
33
33
|
edge_type=edge_type,
|
|
34
34
|
node=node,
|
|
35
35
|
depth=depth,
|