jaclang 0.8.0__py3-none-any.whl → 0.8.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 (77) hide show
  1. jaclang/cli/cli.py +11 -9
  2. jaclang/compiler/jac.lark +2 -12
  3. jaclang/compiler/larkparse/jac_parser.py +1 -1
  4. jaclang/compiler/parser.py +360 -521
  5. jaclang/compiler/passes/main/cfg_build_pass.py +2 -2
  6. jaclang/compiler/passes/main/def_impl_match_pass.py +14 -13
  7. jaclang/compiler/passes/main/def_use_pass.py +4 -7
  8. jaclang/compiler/passes/main/import_pass.py +3 -3
  9. jaclang/compiler/passes/main/inheritance_pass.py +2 -2
  10. jaclang/compiler/passes/main/pyast_gen_pass.py +196 -218
  11. jaclang/compiler/passes/main/pyast_load_pass.py +115 -311
  12. jaclang/compiler/passes/main/pyjac_ast_link_pass.py +8 -7
  13. jaclang/compiler/passes/main/sym_tab_build_pass.py +3 -3
  14. jaclang/compiler/passes/main/sym_tab_link_pass.py +4 -4
  15. jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/action/actions.jac +1 -5
  16. jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/main.jac +1 -8
  17. jaclang/compiler/passes/main/tests/test_cfg_build_pass.py +4 -2
  18. jaclang/compiler/passes/tool/doc_ir_gen_pass.py +197 -120
  19. jaclang/compiler/program.py +2 -7
  20. jaclang/compiler/tests/fixtures/fam.jac +2 -2
  21. jaclang/compiler/tests/fixtures/pkg_import_lib/__init__.jac +1 -0
  22. jaclang/compiler/tests/fixtures/pkg_import_lib/sub/__init__.jac +1 -0
  23. jaclang/compiler/tests/fixtures/pkg_import_lib/sub/helper.jac +3 -0
  24. jaclang/compiler/tests/fixtures/pkg_import_lib/tools.jac +3 -0
  25. jaclang/compiler/tests/fixtures/pkg_import_lib_py/__init__.py +11 -0
  26. jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/__init__.py +7 -0
  27. jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/helper.jac +3 -0
  28. jaclang/compiler/tests/fixtures/pkg_import_lib_py/tools.jac +3 -0
  29. jaclang/compiler/tests/fixtures/pkg_import_main.jac +10 -0
  30. jaclang/compiler/tests/fixtures/pkg_import_main_py.jac +11 -0
  31. jaclang/compiler/tests/test_importer.py +20 -0
  32. jaclang/compiler/tests/test_parser.py +1 -0
  33. jaclang/compiler/unitree.py +456 -304
  34. jaclang/langserve/engine.jac +498 -0
  35. jaclang/langserve/sem_manager.jac +309 -0
  36. jaclang/langserve/server.jac +186 -0
  37. jaclang/langserve/tests/server_test/test_lang_serve.py +6 -7
  38. jaclang/langserve/tests/server_test/utils.py +4 -1
  39. jaclang/langserve/tests/session.jac +294 -0
  40. jaclang/langserve/tests/test_sem_tokens.py +2 -2
  41. jaclang/langserve/tests/test_server.py +12 -7
  42. jaclang/langserve/utils.jac +51 -30
  43. jaclang/runtimelib/archetype.py +1 -1
  44. jaclang/runtimelib/builtin.py +17 -14
  45. jaclang/runtimelib/importer.py +26 -8
  46. jaclang/runtimelib/machine.py +96 -55
  47. jaclang/runtimelib/tests/fixtures/traversing_save.jac +7 -5
  48. jaclang/runtimelib/utils.py +3 -3
  49. jaclang/tests/fixtures/backward_edge_visit.jac +31 -0
  50. jaclang/tests/fixtures/builtin_printgraph.jac +85 -0
  51. jaclang/tests/fixtures/builtin_printgraph_json.jac +21 -0
  52. jaclang/tests/fixtures/builtin_printgraph_mermaid.jac +16 -0
  53. jaclang/tests/fixtures/chandra_bugs2.jac +20 -13
  54. jaclang/tests/fixtures/concurrency.jac +1 -1
  55. jaclang/tests/fixtures/edge_ability.jac +49 -0
  56. jaclang/tests/fixtures/guess_game.jac +1 -1
  57. jaclang/tests/fixtures/here_usage_error.jac +21 -0
  58. jaclang/tests/fixtures/here_visitor_usage.jac +21 -0
  59. jaclang/tests/fixtures/node_del.jac +30 -36
  60. jaclang/tests/fixtures/visit_traversal.jac +47 -0
  61. jaclang/tests/test_cli.py +12 -7
  62. jaclang/tests/test_language.py +91 -16
  63. jaclang/utils/helpers.py +14 -6
  64. jaclang/utils/lang_tools.py +2 -3
  65. jaclang/utils/tests/test_lang_tools.py +2 -1
  66. jaclang/utils/treeprinter.py +3 -4
  67. {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/METADATA +4 -3
  68. {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/RECORD +71 -55
  69. {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/WHEEL +1 -1
  70. jaclang/langserve/engine.py +0 -553
  71. jaclang/langserve/sem_manager.py +0 -383
  72. jaclang/langserve/server.py +0 -167
  73. jaclang/langserve/tests/session.py +0 -255
  74. jaclang/tests/fixtures/builtin_dotgen.jac +0 -42
  75. jaclang/tests/fixtures/builtin_dotgen_json.jac +0 -21
  76. /jaclang/langserve/{__init__.py → __init__.jac} +0 -0
  77. {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/entry_points.txt +0 -0
jaclang/cli/cli.py CHANGED
@@ -14,7 +14,7 @@ import jaclang.compiler.unitree as uni
14
14
  from jaclang.cli.cmdreg import CommandShell, cmd_registry
15
15
  from jaclang.compiler.passes.main import CompilerMode as CMode, PyastBuildPass
16
16
  from jaclang.compiler.program import JacProgram
17
- from jaclang.runtimelib.builtin import dotgen
17
+ from jaclang.runtimelib.builtin import printgraph
18
18
  from jaclang.runtimelib.constructs import WalkerArchetype
19
19
  from jaclang.runtimelib.machine import (
20
20
  JacMachine,
@@ -85,7 +85,7 @@ def format(path: str, outfile: str = "", to_screen: bool = False) -> None:
85
85
 
86
86
 
87
87
  def proc_file_sess(
88
- filename: str, session: str, root: Optional[str] = None, interp: bool = False
88
+ filename: str, session: str, root: Optional[str] = None
89
89
  ) -> tuple[str, str, JacMachine]:
90
90
  """Create JacMachine and return the base path, module name, and machine state."""
91
91
  if session == "":
@@ -99,7 +99,7 @@ def proc_file_sess(
99
99
  base, mod = os.path.split(filename)
100
100
  base = base if base else "./"
101
101
  mod = mod[:-4]
102
- mach = JacMachine(base, session=session, root=root, interp_mode=interp)
102
+ mach = JacMachine(base, session=session, root=root)
103
103
  return base, mod, mach
104
104
 
105
105
 
@@ -109,7 +109,6 @@ def run(
109
109
  session: str = "",
110
110
  main: bool = True,
111
111
  cache: bool = True,
112
- interp: bool = False,
113
112
  ) -> None:
114
113
  """Run the specified .jac file.
115
114
 
@@ -121,7 +120,6 @@ def run(
121
120
  session: Optional session identifier for persistent state
122
121
  main: Treat the module as __main__ (default: True)
123
122
  cache: Use cached compilation if available (default: True)
124
- interp: Run in interpreter mode (default: False)
125
123
 
126
124
  Examples:
127
125
  jac run myprogram.jac
@@ -130,7 +128,7 @@ def run(
130
128
  """
131
129
  # if no session specified, check if it was defined when starting the command shell
132
130
  # otherwise default to jaclang.session
133
- base, mod, mach = proc_file_sess(filename, session, interp=interp)
131
+ base, mod, mach = proc_file_sess(filename, session)
134
132
 
135
133
  if filename.endswith(".jac"):
136
134
  try:
@@ -286,9 +284,13 @@ def lsp() -> None:
286
284
  Examples:
287
285
  jac lsp
288
286
  """
289
- from jaclang.langserve.server import run_lang_server
287
+ from jaclang import JacMachineInterface as _
290
288
 
291
- run_lang_server()
289
+ run_lang_server_tuple = _.py_jac_import(
290
+ "...jaclang.langserve.server", __file__, items={"run_lang_server": None}
291
+ )
292
+ run_lang_server = run_lang_server_tuple[0]
293
+ run_lang_server() # type: ignore
292
294
 
293
295
 
294
296
  @cmd_registry.register
@@ -533,7 +535,7 @@ def dot(
533
535
  globals().update(vars(module))
534
536
  try:
535
537
  node = globals().get(initial, eval(initial)) if initial else None
536
- graph = dotgen(
538
+ graph = printgraph(
537
539
  node=node,
538
540
  depth=depth,
539
541
  traverse=traverse,
jaclang/compiler/jac.lark CHANGED
@@ -1,19 +1,9 @@
1
1
  // [Heading]: Base Module structure.
2
2
  start: module
3
3
 
4
- // TODO:AST: We should allow the very first top level statement to have
5
- // docstring but not the module to have one. After allowing that
6
- // the rule for the module would be:
7
- //
8
- // module: STRING? toplevel_stmt*
9
- //
10
4
  module: (toplevel_stmt (tl_stmt_with_doc | toplevel_stmt)*)?
11
5
  | STRING (tl_stmt_with_doc | toplevel_stmt)*
12
6
 
13
- // AST:TODO: Docstring should be part of the definition of the statement
14
- // and not all toplevel statement have docstring, example: ImportStmt.
15
- //
16
- // Statements that are only valid at the toplevel.
17
7
  tl_stmt_with_doc: STRING toplevel_stmt
18
8
  toplevel_stmt: import_stmt
19
9
  | archetype
@@ -66,7 +56,7 @@ enum: decorators? enum_decl
66
56
  enum_decl: KW_ENUM access_tag? NAME inherited_archs? (enum_block | SEMI)
67
57
  enum_block: LBRACE assignment_list COMMA? (py_code_block | free_code)* RBRACE
68
58
 
69
- // [Heading]: Abilities.
59
+ // [Heading]: Functions and Abilities.
70
60
  ability: decorators? KW_ASYNC? (ability_decl | function_decl)
71
61
 
72
62
  function_decl: KW_OVERRIDE? KW_STATIC? KW_DEF access_tag? named_ref func_decl? (block_tail | KW_ABSTRACT? SEMI)
@@ -165,7 +155,7 @@ pattern: literal_pattern
165
155
  | class_pattern
166
156
 
167
157
 
168
- // [Heading]: Match litteral patterns.
158
+ // [Heading]: Match literal patterns.
169
159
  literal_pattern: (INT | FLOAT | multistring)
170
160
 
171
161
  // [Heading]: Match singleton patterns.