jaclang 0.5.17__py3-none-any.whl → 0.6.0__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 +2 -6
- jaclang/cli/cli.py +4 -2
- jaclang/compiler/__init__.py +12 -5
- jaclang/compiler/absyntree.py +23 -23
- jaclang/compiler/generated/jac_parser.py +2 -2
- jaclang/compiler/jac.lark +9 -9
- jaclang/compiler/parser.py +76 -21
- jaclang/compiler/passes/ir_pass.py +10 -8
- jaclang/compiler/passes/main/__init__.py +3 -2
- jaclang/compiler/passes/main/access_modifier_pass.py +173 -0
- jaclang/compiler/passes/main/fuse_typeinfo_pass.py +3 -2
- jaclang/compiler/passes/main/import_pass.py +33 -21
- jaclang/compiler/passes/main/pyast_gen_pass.py +99 -44
- jaclang/compiler/passes/main/pyast_load_pass.py +141 -77
- jaclang/compiler/passes/main/pyout_pass.py +14 -13
- jaclang/compiler/passes/main/registry_pass.py +8 -3
- jaclang/compiler/passes/main/schedules.py +5 -3
- jaclang/compiler/passes/main/sym_tab_build_pass.py +47 -37
- jaclang/compiler/passes/main/tests/test_import_pass.py +2 -2
- jaclang/compiler/passes/tool/jac_formatter_pass.py +85 -23
- jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +11 -4
- jaclang/compiler/passes/transform.py +2 -0
- jaclang/compiler/symtable.py +10 -3
- jaclang/compiler/tests/test_importer.py +9 -0
- jaclang/compiler/workspace.py +19 -11
- jaclang/core/aott.py +34 -63
- jaclang/core/importer.py +73 -65
- jaclang/core/llms/__init__.py +20 -0
- jaclang/core/llms/anthropic.py +61 -0
- jaclang/core/llms/base.py +206 -0
- jaclang/core/llms/groq.py +67 -0
- jaclang/core/llms/huggingface.py +73 -0
- jaclang/core/llms/ollama.py +78 -0
- jaclang/core/llms/openai.py +61 -0
- jaclang/core/llms/togetherai.py +60 -0
- jaclang/core/llms/utils.py +9 -0
- jaclang/core/utils.py +16 -1
- jaclang/plugin/default.py +47 -16
- jaclang/plugin/feature.py +9 -6
- jaclang/plugin/spec.py +8 -1
- jaclang/settings.py +95 -0
- jaclang/utils/helpers.py +6 -2
- jaclang/utils/treeprinter.py +9 -6
- jaclang/vendor/mypy/checker.py +2 -3
- jaclang-0.6.0.dist-info/METADATA +17 -0
- {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/RECORD +49 -39
- jaclang/core/llms.py +0 -29
- jaclang-0.5.17.dist-info/METADATA +0 -7
- {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/WHEEL +0 -0
- {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/entry_points.txt +0 -0
- {jaclang-0.5.17.dist-info → jaclang-0.6.0.dist-info}/top_level.txt +0 -0
jaclang/__init__.py
CHANGED
|
@@ -17,13 +17,9 @@ from jaclang.vendor import pluggy # noqa: E402
|
|
|
17
17
|
|
|
18
18
|
jac_import = JacFeature.jac_import
|
|
19
19
|
|
|
20
|
-
__all__ = [
|
|
21
|
-
"jac_import",
|
|
22
|
-
"lark",
|
|
23
|
-
"mypy",
|
|
24
|
-
"pluggy",
|
|
25
|
-
]
|
|
26
20
|
pm.register(JacFeatureDefaults)
|
|
27
21
|
pm.register(JacBuiltin)
|
|
28
22
|
pm.register(JacCmdDefaults)
|
|
29
23
|
pm.load_setuptools_entrypoints("jac")
|
|
24
|
+
|
|
25
|
+
__all__ = ["jac_import", "lark", "mypy", "pluggy"]
|
jaclang/cli/cli.py
CHANGED
|
@@ -106,7 +106,7 @@ def build(filename: str) -> None:
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
@cmd_registry.register
|
|
109
|
-
def check(filename: str) -> None:
|
|
109
|
+
def check(filename: str, print_errs: bool = True) -> None:
|
|
110
110
|
"""Run type checker for a specified .jac file.
|
|
111
111
|
|
|
112
112
|
:param filename: The path to the .jac file.
|
|
@@ -119,7 +119,9 @@ def check(filename: str) -> None:
|
|
|
119
119
|
|
|
120
120
|
errs = len(out.errors_had)
|
|
121
121
|
warnings = len(out.warnings_had)
|
|
122
|
-
|
|
122
|
+
if print_errs:
|
|
123
|
+
for e in out.errors_had:
|
|
124
|
+
print("Error:", e)
|
|
123
125
|
print(f"Errors: {errs}, Warnings: {warnings}")
|
|
124
126
|
else:
|
|
125
127
|
print("Not a .jac file.")
|
jaclang/compiler/__init__.py
CHANGED
|
@@ -86,17 +86,24 @@ TOKEN_MAP.update(
|
|
|
86
86
|
"A_PIPE_FWD": ":>",
|
|
87
87
|
"A_PIPE_BKWD": "<:",
|
|
88
88
|
"DOT_FWD": ".>",
|
|
89
|
+
"STAR_POW": "**",
|
|
90
|
+
"STAR_MUL": "*",
|
|
91
|
+
"FLOOR_DIV": "//",
|
|
92
|
+
"DIV": "/",
|
|
93
|
+
"PYNLINE": "::py::",
|
|
94
|
+
"ADD_EQ": "+=",
|
|
95
|
+
"SUB_EQ": "-=",
|
|
89
96
|
"STAR_POW_EQ": "**=",
|
|
90
97
|
"MUL_EQ": "*=",
|
|
91
98
|
"FLOOR_DIV_EQ": "//=",
|
|
92
99
|
"DIV_EQ": "/=",
|
|
100
|
+
"MOD_EQ": "%=",
|
|
101
|
+
"BW_AND_EQ": "&=",
|
|
93
102
|
"BW_OR_EQ": "|=",
|
|
94
103
|
"BW_XOR_EQ": "^=",
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"DIV": "/",
|
|
99
|
-
"PYNLINE": "::py::",
|
|
104
|
+
"BW_NOT_EQ": "~=",
|
|
105
|
+
"LSHIFT_EQ": "<<=",
|
|
106
|
+
"RSHIFT_EQ": ">>=",
|
|
100
107
|
}
|
|
101
108
|
)
|
|
102
109
|
|
jaclang/compiler/absyntree.py
CHANGED
|
@@ -110,11 +110,15 @@ class AstNode:
|
|
|
110
110
|
|
|
111
111
|
return Pass.get_all_sub_nodes(node=self, typ=typ, brute_force=brute_force)
|
|
112
112
|
|
|
113
|
-
def
|
|
113
|
+
def parent_of_type(self, typ: Type[T]) -> T:
|
|
114
114
|
"""Get parent of type."""
|
|
115
115
|
from jaclang.compiler.passes import Pass
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
ret = Pass.has_parent_of_type(node=self, typ=typ)
|
|
118
|
+
if isinstance(ret, typ):
|
|
119
|
+
return ret
|
|
120
|
+
else:
|
|
121
|
+
raise ValueError(f"Parent of type {typ} not found.")
|
|
118
122
|
|
|
119
123
|
def format(self) -> str:
|
|
120
124
|
"""Get all sub nodes of type."""
|
|
@@ -190,10 +194,10 @@ class AstAccessNode(AstNode):
|
|
|
190
194
|
"""Get access spec."""
|
|
191
195
|
return (
|
|
192
196
|
SymbolAccess.PRIVATE
|
|
193
|
-
if self.access and self.access.tag.
|
|
197
|
+
if self.access and self.access.tag.name == Tok.KW_PRIV
|
|
194
198
|
else (
|
|
195
199
|
SymbolAccess.PROTECTED
|
|
196
|
-
if self.access and self.access.tag.
|
|
200
|
+
if self.access and self.access.tag.name == Tok.KW_PROT
|
|
197
201
|
else SymbolAccess.PUBLIC
|
|
198
202
|
)
|
|
199
203
|
)
|
|
@@ -592,15 +596,15 @@ class Import(ElementStmt, CodeBlockStmt):
|
|
|
592
596
|
def __init__(
|
|
593
597
|
self,
|
|
594
598
|
hint: SubTag[Name],
|
|
595
|
-
|
|
596
|
-
items:
|
|
599
|
+
from_loc: Optional[ModulePath],
|
|
600
|
+
items: SubNodeList[ModuleItem] | SubNodeList[ModulePath],
|
|
597
601
|
is_absorb: bool, # For includes
|
|
598
602
|
kid: Sequence[AstNode],
|
|
599
603
|
doc: Optional[String] = None,
|
|
600
604
|
) -> None:
|
|
601
605
|
"""Initialize import node."""
|
|
602
606
|
self.hint = hint
|
|
603
|
-
self.
|
|
607
|
+
self.from_loc = from_loc
|
|
604
608
|
self.items = items
|
|
605
609
|
self.is_absorb = is_absorb
|
|
606
610
|
AstNode.__init__(self, kid=kid)
|
|
@@ -611,9 +615,8 @@ class Import(ElementStmt, CodeBlockStmt):
|
|
|
611
615
|
res = True
|
|
612
616
|
if deep:
|
|
613
617
|
res = self.hint.normalize(deep)
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
res = res and self.items.normalize(deep) if self.items else res
|
|
618
|
+
res = res and self.from_loc.normalize(deep) if self.from_loc else res
|
|
619
|
+
res = res and self.items.normalize(deep)
|
|
617
620
|
res = res and self.doc.normalize(deep) if self.doc else res
|
|
618
621
|
new_kid: list[AstNode] = []
|
|
619
622
|
if self.doc:
|
|
@@ -623,15 +626,11 @@ class Import(ElementStmt, CodeBlockStmt):
|
|
|
623
626
|
else:
|
|
624
627
|
new_kid.append(self.gen_token(Tok.KW_IMPORT))
|
|
625
628
|
new_kid.append(self.hint)
|
|
626
|
-
if self.
|
|
629
|
+
if self.from_loc:
|
|
627
630
|
new_kid.append(self.gen_token(Tok.KW_FROM))
|
|
628
|
-
|
|
629
|
-
new_kid.append(p)
|
|
631
|
+
new_kid.append(self.from_loc)
|
|
630
632
|
new_kid.append(self.gen_token(Tok.COMMA))
|
|
631
|
-
new_kid.
|
|
632
|
-
if self.items:
|
|
633
|
-
new_kid.append(self.gen_token(Tok.COMMA))
|
|
634
|
-
new_kid.append(self.items)
|
|
633
|
+
new_kid.append(self.items)
|
|
635
634
|
new_kid.append(self.gen_token(Tok.SEMI))
|
|
636
635
|
self.set_kids(nodes=new_kid)
|
|
637
636
|
return res
|
|
@@ -2389,9 +2388,9 @@ class LambdaExpr(Expr):
|
|
|
2389
2388
|
|
|
2390
2389
|
def __init__(
|
|
2391
2390
|
self,
|
|
2392
|
-
signature: FuncSignature,
|
|
2393
2391
|
body: Expr,
|
|
2394
2392
|
kid: Sequence[AstNode],
|
|
2393
|
+
signature: Optional[FuncSignature] = None,
|
|
2395
2394
|
) -> None:
|
|
2396
2395
|
"""Initialize lambda expression node."""
|
|
2397
2396
|
self.signature = signature
|
|
@@ -2402,11 +2401,12 @@ class LambdaExpr(Expr):
|
|
|
2402
2401
|
"""Normalize ast node."""
|
|
2403
2402
|
res = True
|
|
2404
2403
|
if deep:
|
|
2405
|
-
res = self.signature.normalize(deep)
|
|
2404
|
+
res = self.signature.normalize(deep) if self.signature else res
|
|
2406
2405
|
res = res and self.body.normalize(deep)
|
|
2407
|
-
new_kid: list[AstNode] = [
|
|
2408
|
-
|
|
2409
|
-
self.signature
|
|
2406
|
+
new_kid: list[AstNode] = [self.gen_token(Tok.KW_WITH)]
|
|
2407
|
+
if self.signature:
|
|
2408
|
+
new_kid.append(self.signature)
|
|
2409
|
+
new_kid += [
|
|
2410
2410
|
self.gen_token(Tok.KW_CAN),
|
|
2411
2411
|
self.body,
|
|
2412
2412
|
self.gen_token(Tok.SEMI),
|
|
@@ -3716,7 +3716,7 @@ class MatchArch(MatchPattern):
|
|
|
3716
3716
|
|
|
3717
3717
|
def __init__(
|
|
3718
3718
|
self,
|
|
3719
|
-
name: NameSpec,
|
|
3719
|
+
name: AtomTrailer | NameSpec,
|
|
3720
3720
|
arg_patterns: Optional[SubNodeList[MatchPattern]],
|
|
3721
3721
|
kw_patterns: Optional[SubNodeList[MatchKVPair]],
|
|
3722
3722
|
kid: Sequence[AstNode],
|