jaclang 0.5.18__py3-none-any.whl → 0.6.1__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.

Files changed (57) hide show
  1. jaclang/cli/cli.py +94 -5
  2. jaclang/cli/cmdreg.py +18 -6
  3. jaclang/compiler/__init__.py +12 -5
  4. jaclang/compiler/absyntree.py +4 -5
  5. jaclang/compiler/generated/jac_parser.py +2 -2
  6. jaclang/compiler/jac.lark +2 -2
  7. jaclang/compiler/parser.py +48 -8
  8. jaclang/compiler/passes/main/__init__.py +3 -2
  9. jaclang/compiler/passes/main/access_modifier_pass.py +173 -0
  10. jaclang/compiler/passes/main/def_impl_match_pass.py +4 -1
  11. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +10 -7
  12. jaclang/compiler/passes/main/import_pass.py +70 -40
  13. jaclang/compiler/passes/main/pyast_gen_pass.py +47 -83
  14. jaclang/compiler/passes/main/pyast_load_pass.py +136 -73
  15. jaclang/compiler/passes/main/pyjac_ast_link_pass.py +218 -0
  16. jaclang/compiler/passes/main/pyout_pass.py +14 -13
  17. jaclang/compiler/passes/main/registry_pass.py +8 -3
  18. jaclang/compiler/passes/main/schedules.py +7 -3
  19. jaclang/compiler/passes/main/sym_tab_build_pass.py +32 -29
  20. jaclang/compiler/passes/main/tests/test_import_pass.py +13 -2
  21. jaclang/compiler/passes/tool/jac_formatter_pass.py +83 -21
  22. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +11 -4
  23. jaclang/compiler/passes/transform.py +2 -0
  24. jaclang/compiler/symtable.py +10 -3
  25. jaclang/compiler/tests/test_importer.py +9 -0
  26. jaclang/compiler/workspace.py +17 -5
  27. jaclang/core/aott.py +43 -63
  28. jaclang/core/construct.py +157 -21
  29. jaclang/core/importer.py +77 -65
  30. jaclang/core/llms/__init__.py +20 -0
  31. jaclang/core/llms/anthropic.py +61 -0
  32. jaclang/core/llms/base.py +206 -0
  33. jaclang/core/llms/groq.py +67 -0
  34. jaclang/core/llms/huggingface.py +73 -0
  35. jaclang/core/llms/ollama.py +78 -0
  36. jaclang/core/llms/openai.py +61 -0
  37. jaclang/core/llms/togetherai.py +60 -0
  38. jaclang/core/llms/utils.py +9 -0
  39. jaclang/core/memory.py +48 -0
  40. jaclang/core/shelve_storage.py +55 -0
  41. jaclang/core/utils.py +16 -1
  42. jaclang/plugin/__init__.py +1 -2
  43. jaclang/plugin/builtin.py +1 -1
  44. jaclang/plugin/default.py +134 -18
  45. jaclang/plugin/feature.py +35 -13
  46. jaclang/plugin/spec.py +52 -10
  47. jaclang/plugin/tests/test_jaseci.py +219 -0
  48. jaclang/settings.py +1 -1
  49. jaclang/utils/helpers.py +6 -2
  50. jaclang/utils/treeprinter.py +14 -6
  51. jaclang-0.6.1.dist-info/METADATA +17 -0
  52. {jaclang-0.5.18.dist-info → jaclang-0.6.1.dist-info}/RECORD +55 -42
  53. jaclang/core/llms.py +0 -111
  54. jaclang-0.5.18.dist-info/METADATA +0 -7
  55. {jaclang-0.5.18.dist-info → jaclang-0.6.1.dist-info}/WHEEL +0 -0
  56. {jaclang-0.5.18.dist-info → jaclang-0.6.1.dist-info}/entry_points.txt +0 -0
  57. {jaclang-0.5.18.dist-info → jaclang-0.6.1.dist-info}/top_level.txt +0 -0
@@ -19,8 +19,6 @@ T = TypeVar("T", bound=ast3.AST)
19
19
  class PyastGenPass(Pass):
20
20
  """Jac blue transpilation to python pass."""
21
21
 
22
- cout = 1
23
-
24
22
  @staticmethod
25
23
  def node_compilable_test(node: ast3.AST) -> None:
26
24
  """Convert any AST node to a compilable module node."""
@@ -214,25 +212,18 @@ class PyastGenPass(Pass):
214
212
  i.end_lineno = (
215
213
  jac_node.loc.last_line
216
214
  if jac_node.loc.last_line
215
+ and (jac_node.loc.last_line > jac_node.loc.first_line)
217
216
  else jac_node.loc.first_line
218
217
  )
219
218
  i.end_col_offset = (
220
219
  jac_node.loc.col_end
221
220
  if jac_node.loc.col_end
221
+ and (jac_node.loc.col_end > jac_node.loc.col_start)
222
222
  else jac_node.loc.col_start
223
223
  )
224
224
  i.jac_link: list[ast3.AST] = [jac_node] # type: ignore
225
225
  return py_node
226
226
 
227
- def link_jac_py_nodes(
228
- self, jac_node: ast.AstNode, py_nodes: list[ast3.AST]
229
- ) -> None:
230
- """Link jac name ast to py ast nodes."""
231
- jac_node.gen.py_ast = py_nodes
232
- for i in py_nodes:
233
- if isinstance(i.jac_link, list): # type: ignore
234
- i.jac_link.append(jac_node) # type: ignore
235
-
236
227
  def pyinline_sync(
237
228
  self,
238
229
  py_nodes: list[ast3.AST],
@@ -329,7 +320,10 @@ class PyastGenPass(Pass):
329
320
  is_imported: bool,
330
321
  """
331
322
  clean_body = [i for i in node.body if not isinstance(i, ast.AstImplOnlyNode)]
332
- pre_body = [*node.impl_mod.body, *clean_body] if node.impl_mod else clean_body
323
+ pre_body: list[ast.AstNode] = []
324
+ for pbody in node.impl_mod:
325
+ pre_body = [*pre_body, *pbody.body]
326
+ pre_body = [*pre_body, *clean_body]
333
327
  pre_body = [*pre_body, *node.test_mod.body] if node.test_mod else pre_body
334
328
  body = (
335
329
  [
@@ -611,9 +605,10 @@ class PyastGenPass(Pass):
611
605
  )
612
606
  )
613
607
  if node.items:
614
- self.warning(
615
- "Includes import * in target module into current namespace."
616
- )
608
+ pass
609
+ # self.warning(
610
+ # "Includes import * in target module into current namespace."
611
+ # )
617
612
  if not node.from_loc:
618
613
  py_nodes.append(self.sync(ast3.Import(names=node.items.gen.py_ast)))
619
614
  else:
@@ -647,8 +642,6 @@ class PyastGenPass(Pass):
647
642
  )
648
643
  )
649
644
  ]
650
- if node.alias:
651
- self.link_jac_py_nodes(jac_node=node.alias, py_nodes=node.gen.py_ast)
652
645
 
653
646
  def exit_module_item(self, node: ast.ModuleItem) -> None:
654
647
  """Sub objects.
@@ -676,8 +669,6 @@ class PyastGenPass(Pass):
676
669
  doc: Optional[String],
677
670
  decorators: Optional[SubNodeList[ExprType]],
678
671
  """
679
- self.needs_jac_feature()
680
- self.needs_dataclass()
681
672
  body = self.resolve_stmt_block(
682
673
  node.body.body if isinstance(node.body, ast.ArchDef) else node.body,
683
674
  doc=node.doc,
@@ -689,6 +680,8 @@ class PyastGenPass(Pass):
689
680
  )
690
681
  ds_on_entry, ds_on_exit = self.collect_events(node)
691
682
  if node.arch_type.name != Tok.KW_CLASS:
683
+ self.needs_jac_feature()
684
+ self.needs_dataclass()
692
685
  decorators.append(
693
686
  self.sync(
694
687
  ast3.Call(
@@ -723,24 +716,26 @@ class PyastGenPass(Pass):
723
716
  )
724
717
  )
725
718
  )
726
- decorators.append(
727
- self.sync(
728
- ast3.Call(
729
- func=self.sync(ast3.Name(id="__jac_dataclass__", ctx=ast3.Load())),
730
- args=[],
731
- keywords=[
732
- self.sync(
733
- ast3.keyword(
734
- arg="eq",
735
- value=self.sync(
736
- ast3.Constant(value=False),
737
- ),
719
+ decorators.append(
720
+ self.sync(
721
+ ast3.Call(
722
+ func=self.sync(
723
+ ast3.Name(id="__jac_dataclass__", ctx=ast3.Load())
724
+ ),
725
+ args=[],
726
+ keywords=[
727
+ self.sync(
728
+ ast3.keyword(
729
+ arg="eq",
730
+ value=self.sync(
731
+ ast3.Constant(value=False),
732
+ ),
733
+ )
738
734
  )
739
- )
740
- ],
735
+ ],
736
+ )
741
737
  )
742
738
  )
743
- )
744
739
  base_classes = node.base_classes.gen.py_ast if node.base_classes else []
745
740
  if node.is_abstract:
746
741
  self.needs_jac_feature()
@@ -773,9 +768,6 @@ class PyastGenPass(Pass):
773
768
  )
774
769
  )
775
770
  ]
776
- self.link_jac_py_nodes(jac_node=node.name, py_nodes=node.gen.py_ast)
777
- if isinstance(node.body, ast.ArchDef):
778
- self.link_jac_py_nodes(jac_node=node.body, py_nodes=node.gen.py_ast)
779
771
 
780
772
  def collect_events(
781
773
  self, node: ast.Architype
@@ -828,12 +820,6 @@ class PyastGenPass(Pass):
828
820
  doc: Optional[String],
829
821
  decorators: Optional[SubNodeList[ExprType]],
830
822
  """
831
- for i in node.target.archs:
832
- if i.sym_link:
833
- self.link_jac_py_nodes(jac_node=i, py_nodes=i.sym_link.decl.gen.py_ast)
834
- self.link_jac_py_nodes(
835
- jac_node=i.name_ref, py_nodes=i.sym_link.decl.gen.py_ast
836
- )
837
823
 
838
824
  def exit_enum(self, node: ast.Enum) -> None:
839
825
  """Sub objects.
@@ -874,8 +860,6 @@ class PyastGenPass(Pass):
874
860
  )
875
861
  )
876
862
  ]
877
- if isinstance(node.body, ast.EnumDef):
878
- self.link_jac_py_nodes(jac_node=node.body, py_nodes=node.gen.py_ast)
879
863
 
880
864
  def exit_enum_def(self, node: ast.EnumDef) -> None:
881
865
  """Sub objects.
@@ -885,12 +869,6 @@ class PyastGenPass(Pass):
885
869
  doc: Optional[String],
886
870
  decorators: Optional[SubNodeList[ExprType]],
887
871
  """
888
- for i in node.target.archs:
889
- if i.sym_link:
890
- self.link_jac_py_nodes(jac_node=i, py_nodes=i.sym_link.decl.gen.py_ast)
891
- self.link_jac_py_nodes(
892
- jac_node=i.name_ref, py_nodes=i.sym_link.decl.gen.py_ast
893
- )
894
872
 
895
873
  def exit_ability(self, node: ast.Ability) -> None:
896
874
  """Sub objects.
@@ -992,9 +970,6 @@ class PyastGenPass(Pass):
992
970
  )
993
971
  )
994
972
  ]
995
- self.link_jac_py_nodes(jac_node=node.name_ref, py_nodes=node.gen.py_ast)
996
- if isinstance(node.body, ast.AbilityDef):
997
- self.link_jac_py_nodes(jac_node=node.body, py_nodes=node.gen.py_ast)
998
973
 
999
974
  def gen_llm_body(self, node: ast.Ability) -> list[ast3.AST]:
1000
975
  """Generate llm body."""
@@ -1065,7 +1040,11 @@ class PyastGenPass(Pass):
1065
1040
  if isinstance(node.signature, ast.FuncSignature)
1066
1041
  else []
1067
1042
  )
1068
- action = node.semstr.gen.py_ast[0] if node.semstr else None
1043
+ action = (
1044
+ node.semstr.gen.py_ast[0]
1045
+ if node.semstr
1046
+ else self.sync(ast3.Constant(value=None))
1047
+ )
1069
1048
  return [
1070
1049
  self.sync(
1071
1050
  ast3.Assign(
@@ -1284,15 +1263,6 @@ class PyastGenPass(Pass):
1284
1263
  doc: Optional[String],
1285
1264
  decorators: Optional[SubNodeList[ExprType]],
1286
1265
  """
1287
- for i in node.target.archs:
1288
- if i.sym_link:
1289
- self.link_jac_py_nodes(jac_node=i, py_nodes=i.sym_link.decl.gen.py_ast)
1290
- self.link_jac_py_nodes(
1291
- jac_node=i.name_ref, py_nodes=i.sym_link.decl.gen.py_ast
1292
- )
1293
- if isinstance(node.parent, ast.Ability) and node.parent.signature:
1294
- # TODO: Here we need to do a link for each subnode to the original parent signature
1295
- pass
1296
1266
 
1297
1267
  def exit_func_signature(self, node: ast.FuncSignature) -> None:
1298
1268
  """Sub objects.
@@ -1385,12 +1355,20 @@ class PyastGenPass(Pass):
1385
1355
  ):
1386
1356
  node.gen.py_ast = [
1387
1357
  self.sync(
1388
- ast3.Attribute(
1389
- value=self.sync(
1390
- ast3.Name(id=Con.JAC_FEATURE.value, ctx=ast3.Load())
1358
+ ast3.Call(
1359
+ func=self.sync(
1360
+ ast3.Attribute(
1361
+ value=self.sync(
1362
+ ast3.Name(
1363
+ id=Con.JAC_FEATURE.value, ctx=ast3.Load()
1364
+ )
1365
+ ),
1366
+ attr="get_root_type",
1367
+ ctx=ast3.Load(),
1368
+ )
1391
1369
  ),
1392
- attr="RootType",
1393
- ctx=ast3.Load(),
1370
+ args=[],
1371
+ keywords=[],
1394
1372
  )
1395
1373
  )
1396
1374
  ]
@@ -1449,7 +1427,6 @@ class PyastGenPass(Pass):
1449
1427
  )
1450
1428
  )
1451
1429
  ]
1452
- self.link_jac_py_nodes(jac_node=node.name, py_nodes=node.gen.py_ast)
1453
1430
 
1454
1431
  def exit_arch_has(self, node: ast.ArchHas) -> None:
1455
1432
  """Sub objects.
@@ -1705,8 +1682,6 @@ class PyastGenPass(Pass):
1705
1682
  )
1706
1683
  )
1707
1684
  ]
1708
- if node.name:
1709
- self.link_jac_py_nodes(jac_node=node.name, py_nodes=node.gen.py_ast)
1710
1685
 
1711
1686
  def exit_finally_stmt(self, node: ast.FinallyStmt) -> None:
1712
1687
  """Sub objects.
@@ -1814,9 +1789,6 @@ class PyastGenPass(Pass):
1814
1789
  )
1815
1790
  )
1816
1791
  ]
1817
- self.link_jac_py_nodes(jac_node=node.expr, py_nodes=node.gen.py_ast)
1818
- if node.alias:
1819
- self.link_jac_py_nodes(jac_node=node.alias, py_nodes=node.gen.py_ast)
1820
1792
 
1821
1793
  def exit_raise_stmt(self, node: ast.RaiseStmt) -> None:
1822
1794
  """Sub objects.
@@ -2074,7 +2046,6 @@ class PyastGenPass(Pass):
2074
2046
  jac_node=x,
2075
2047
  )
2076
2048
  )
2077
- self.link_jac_py_nodes(jac_node=x, py_nodes=[py_nodes[-1]])
2078
2049
  node.gen.py_ast = [*py_nodes]
2079
2050
 
2080
2051
  def exit_non_local_stmt(self, node: ast.NonLocalStmt) -> None:
@@ -2090,7 +2061,6 @@ class PyastGenPass(Pass):
2090
2061
  jac_node=x,
2091
2062
  )
2092
2063
  )
2093
- self.link_jac_py_nodes(jac_node=x, py_nodes=[py_nodes[-1]])
2094
2064
  node.gen.py_ast = [*py_nodes]
2095
2065
 
2096
2066
  def exit_assignment(self, node: ast.Assignment) -> None:
@@ -2632,8 +2602,6 @@ class PyastGenPass(Pass):
2632
2602
  )
2633
2603
  )
2634
2604
  ]
2635
- if node.key:
2636
- self.link_jac_py_nodes(jac_node=node.key, py_nodes=node.gen.py_ast)
2637
2605
 
2638
2606
  def exit_inner_compr(self, node: ast.InnerCompr) -> None:
2639
2607
  """Sub objects.
@@ -2743,9 +2711,6 @@ class PyastGenPass(Pass):
2743
2711
  )
2744
2712
  )
2745
2713
  ]
2746
- self.link_jac_py_nodes(
2747
- jac_node=node.right.sym_name_node, py_nodes=node.gen.py_ast
2748
- )
2749
2714
  else:
2750
2715
  self.error("Invalid attribute access")
2751
2716
  elif isinstance(node.right, ast.FilterCompr):
@@ -3010,7 +2975,6 @@ class PyastGenPass(Pass):
3010
2975
  for kw_pair in node.params.items
3011
2976
  if isinstance(kw_pair, ast.KWPair)
3012
2977
  ]
3013
- self.cout += 1
3014
2978
  else:
3015
2979
  inputs = []
3016
2980