jaclang 0.8.4__py3-none-any.whl → 0.8.5__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 (53) hide show
  1. jaclang/cli/cli.py +74 -22
  2. jaclang/compiler/jac.lark +3 -3
  3. jaclang/compiler/larkparse/jac_parser.py +2 -2
  4. jaclang/compiler/parser.py +14 -21
  5. jaclang/compiler/passes/main/__init__.py +3 -1
  6. jaclang/compiler/passes/main/binder_pass.py +594 -0
  7. jaclang/compiler/passes/main/import_pass.py +8 -256
  8. jaclang/compiler/passes/main/inheritance_pass.py +2 -2
  9. jaclang/compiler/passes/main/pyast_gen_pass.py +35 -69
  10. jaclang/compiler/passes/main/pyast_load_pass.py +24 -13
  11. jaclang/compiler/passes/main/sem_def_match_pass.py +1 -1
  12. jaclang/compiler/passes/main/tests/fixtures/M1.jac +3 -0
  13. jaclang/compiler/passes/main/tests/fixtures/sym_binder.jac +47 -0
  14. jaclang/compiler/passes/main/tests/test_binder_pass.py +111 -0
  15. jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +13 -13
  16. jaclang/compiler/passes/main/tests/test_sem_def_match_pass.py +6 -6
  17. jaclang/compiler/passes/tool/doc_ir_gen_pass.py +2 -0
  18. jaclang/compiler/passes/tool/tests/fixtures/simple_walk_fmt.jac +6 -0
  19. jaclang/compiler/program.py +15 -8
  20. jaclang/compiler/tests/test_sr_errors.py +32 -0
  21. jaclang/compiler/unitree.py +21 -15
  22. jaclang/langserve/engine.jac +23 -4
  23. jaclang/langserve/tests/test_server.py +13 -0
  24. jaclang/runtimelib/importer.py +33 -62
  25. jaclang/runtimelib/utils.py +29 -0
  26. jaclang/tests/fixtures/pyfunc_fmt.py +60 -0
  27. jaclang/tests/fixtures/pyfunc_fstr.py +25 -0
  28. jaclang/tests/fixtures/pyfunc_kwesc.py +33 -0
  29. jaclang/tests/fixtures/python_run_test.py +19 -0
  30. jaclang/tests/test_cli.py +67 -0
  31. jaclang/tests/test_language.py +96 -1
  32. jaclang/utils/lang_tools.py +3 -3
  33. jaclang/utils/module_resolver.py +90 -0
  34. jaclang/utils/symtable_test_helpers.py +125 -0
  35. jaclang/utils/test.py +3 -4
  36. jaclang/vendor/interegular/__init__.py +34 -0
  37. jaclang/vendor/interegular/comparator.py +163 -0
  38. jaclang/vendor/interegular/fsm.py +1015 -0
  39. jaclang/vendor/interegular/patterns.py +732 -0
  40. jaclang/vendor/interegular/py.typed +0 -0
  41. jaclang/vendor/interegular/utils/__init__.py +15 -0
  42. jaclang/vendor/interegular/utils/simple_parser.py +165 -0
  43. jaclang/vendor/interegular-0.3.3.dist-info/INSTALLER +1 -0
  44. jaclang/vendor/interegular-0.3.3.dist-info/LICENSE.txt +21 -0
  45. jaclang/vendor/interegular-0.3.3.dist-info/METADATA +64 -0
  46. jaclang/vendor/interegular-0.3.3.dist-info/RECORD +20 -0
  47. jaclang/vendor/interegular-0.3.3.dist-info/REQUESTED +0 -0
  48. jaclang/vendor/interegular-0.3.3.dist-info/WHEEL +5 -0
  49. jaclang/vendor/interegular-0.3.3.dist-info/top_level.txt +1 -0
  50. {jaclang-0.8.4.dist-info → jaclang-0.8.5.dist-info}/METADATA +1 -1
  51. {jaclang-0.8.4.dist-info → jaclang-0.8.5.dist-info}/RECORD +53 -29
  52. {jaclang-0.8.4.dist-info → jaclang-0.8.5.dist-info}/WHEEL +0 -0
  53. {jaclang-0.8.4.dist-info → jaclang-0.8.5.dist-info}/entry_points.txt +0 -0
@@ -523,7 +523,7 @@ class JacParser(Transform[uni.Source, uni.Module]):
523
523
  or self.match(uni.FuncSignature)
524
524
  or self.match(uni.EventSignature)
525
525
  )
526
- tail = self.match(list) or self.match(uni.FuncCall)
526
+ tail = self.match(list) or self.match(uni.Expr)
527
527
  valid_tail = spec if tail is None else tail
528
528
  valid_spec = None if tail is None else spec
529
529
  impl = uni.ImplDef(
@@ -578,14 +578,12 @@ class JacParser(Transform[uni.Source, uni.Module]):
578
578
 
579
579
  def impl_tail(
580
580
  self, _: None
581
- ) -> Sequence[uni.EnumBlockStmt] | list[uni.CodeBlockStmt] | uni.FuncCall:
581
+ ) -> Sequence[uni.EnumBlockStmt] | list[uni.CodeBlockStmt] | uni.Expr:
582
582
  """Grammar rule.
583
583
 
584
584
  impl_tail: enum_block | block_tail
585
585
  """
586
- tail = self.match(list) or self.consume( # enum_block or code_block
587
- uni.FuncCall
588
- ) # block_tail (KW_BY atomic_call)
586
+ tail = self.match(list) or self.consume(uni.Expr)
589
587
  return tail
590
588
 
591
589
  def archetype_decl(self, _: None) -> uni.ArchSpec:
@@ -772,7 +770,7 @@ class JacParser(Transform[uni.Source, uni.Module]):
772
770
  signature = self.consume(uni.EventSignature)
773
771
 
774
772
  # Handle block_tail
775
- body_sn_or_call = self.match(list) or self.match(uni.FuncCall)
773
+ body_sn_or_call = self.match(list) or self.match(uni.Expr)
776
774
  if body_sn_or_call is None:
777
775
  is_abstract = self.match_token(Tok.KW_ABSTRACT) is not None
778
776
  self.consume_token(Tok.SEMI)
@@ -812,7 +810,7 @@ class JacParser(Transform[uni.Source, uni.Module]):
812
810
  signature = self.match(uni.FuncSignature)
813
811
 
814
812
  # Handle block_tail
815
- body_sn_or_call = self.match(list) or self.match(uni.FuncCall)
813
+ body_sn_or_call = self.match(list) or self.match(uni.Expr)
816
814
  if body_sn_or_call is None:
817
815
  is_abstract = self.match_token(Tok.KW_ABSTRACT) is not None
818
816
  self.consume_token(Tok.SEMI)
@@ -1867,15 +1865,13 @@ class JacParser(Transform[uni.Source, uni.Module]):
1867
1865
  def atomic_call(self, _: None) -> uni.FuncCall:
1868
1866
  """Grammar rule.
1869
1867
 
1870
- atomic_call: atomic_chain LPAREN param_list? by_call? RPAREN by_call?
1868
+ atomic_call: atomic_chain LPAREN param_list? by_llm? RPAREN
1871
1869
  """
1872
- genai_call: uni.FuncCall | None = None
1873
1870
  target = self.consume(uni.Expr)
1874
1871
  self.consume_token(Tok.LPAREN)
1875
1872
  params_sn = self.match(list)
1876
- genai_call = self.match(uni.FuncCall)
1873
+ genai_call = self.match(uni.Expr)
1877
1874
  self.consume_token(Tok.RPAREN)
1878
- body_genai_call = self.match(uni.FuncCall)
1879
1875
 
1880
1876
  return uni.FuncCall(
1881
1877
  target=target,
@@ -1885,19 +1881,16 @@ class JacParser(Transform[uni.Source, uni.Module]):
1885
1881
  else []
1886
1882
  ),
1887
1883
  genai_call=genai_call,
1888
- body_genai_call=body_genai_call,
1889
1884
  kid=self.flat_cur_nodes,
1890
1885
  )
1891
1886
 
1892
- def by_call(self, _: None) -> uni.FuncCall:
1887
+ def by_llm(self, _: None) -> uni.Expr:
1893
1888
  """Grammar rule.
1894
1889
 
1895
- by_call: KW_BY expression
1890
+ by_llm: KW_BY expression
1896
1891
  """
1897
1892
  self.consume_token(Tok.KW_BY)
1898
- if call := self.match(uni.FuncCall):
1899
- return call
1900
- raise ValueError("Expected a function call")
1893
+ return self.consume(uni.Expr)
1901
1894
 
1902
1895
  def index_slice(self, _: None) -> uni.IndexSlice:
1903
1896
  """Grammar rule.
@@ -2924,18 +2917,18 @@ class JacParser(Transform[uni.Source, uni.Module]):
2924
2917
  kid=self.cur_nodes,
2925
2918
  )
2926
2919
 
2927
- def block_tail(self, _: None) -> list[uni.CodeBlockStmt] | uni.FuncCall:
2920
+ def block_tail(self, _: None) -> list[uni.CodeBlockStmt] | uni.Expr:
2928
2921
  """Grammar rule.
2929
2922
 
2930
- block_tail: code_block | KW_BY atomic_call SEMI | KW_ABSTRACT? SEMI
2923
+ block_tail: code_block | KW_BY expression SEMI
2931
2924
  """
2932
2925
  # Try to match code_block first
2933
2926
  if code_block := self.match(list):
2934
2927
  return code_block
2935
2928
 
2936
- # Otherwise, it must be KW_BY atomic_call SEMI
2929
+ # Otherwise, it must be KW_BY expression SEMI
2937
2930
  by_token = self.consume_token(Tok.KW_BY)
2938
- func_call = self.consume(uni.FuncCall)
2931
+ func_call = self.consume(uni.Expr)
2939
2932
  semi_token = self.consume_token(Tok.SEMI)
2940
2933
 
2941
2934
  # Add the tokens to the function call's kid array
@@ -2,11 +2,12 @@
2
2
 
3
3
  from ..transform import Alert, Transform # noqa: I100
4
4
  from .annex_pass import JacAnnexPass # noqa: I100
5
+ from .binder_pass import BinderPass # noqa: I100
5
6
  from .sym_tab_build_pass import SymTabBuildPass, UniPass # noqa: I100
6
7
  from .sym_tab_link_pass import SymTabLinkPass # noqa: I100
7
8
  from .def_use_pass import DefUsePass # noqa: I100
8
9
  from .sem_def_match_pass import SemDefMatchPass # noqa: I100
9
- from .import_pass import JacImportDepsPass, PyImportDepsPass # noqa: I100
10
+ from .import_pass import JacImportDepsPass # noqa: I100
10
11
  from .def_impl_match_pass import DeclImplMatchPass # noqa: I100
11
12
  from .pyast_load_pass import PyastBuildPass # type: ignore # noqa: I100
12
13
  from .pyast_gen_pass import PyastGenPass # noqa: I100
@@ -23,6 +24,7 @@ __all__ = [
23
24
  "JacAnnexPass",
24
25
  "JacImportDepsPass",
25
26
  "PyImportDepsPass",
27
+ "BinderPass",
26
28
  "SymTabBuildPass",
27
29
  "SymTabLinkPass",
28
30
  "DeclImplMatchPass",