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.
- jaclang/cli/cli.py +11 -9
- jaclang/compiler/jac.lark +2 -12
- jaclang/compiler/larkparse/jac_parser.py +1 -1
- jaclang/compiler/parser.py +360 -521
- jaclang/compiler/passes/main/cfg_build_pass.py +2 -2
- jaclang/compiler/passes/main/def_impl_match_pass.py +14 -13
- jaclang/compiler/passes/main/def_use_pass.py +4 -7
- jaclang/compiler/passes/main/import_pass.py +3 -3
- jaclang/compiler/passes/main/inheritance_pass.py +2 -2
- jaclang/compiler/passes/main/pyast_gen_pass.py +196 -218
- jaclang/compiler/passes/main/pyast_load_pass.py +115 -311
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +8 -7
- jaclang/compiler/passes/main/sym_tab_build_pass.py +3 -3
- jaclang/compiler/passes/main/sym_tab_link_pass.py +4 -4
- jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/action/actions.jac +1 -5
- jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/main.jac +1 -8
- jaclang/compiler/passes/main/tests/test_cfg_build_pass.py +4 -2
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +197 -120
- jaclang/compiler/program.py +2 -7
- jaclang/compiler/tests/fixtures/fam.jac +2 -2
- jaclang/compiler/tests/fixtures/pkg_import_lib/__init__.jac +1 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/sub/__init__.jac +1 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/sub/helper.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib/tools.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/__init__.py +11 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/__init__.py +7 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/helper.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_lib_py/tools.jac +3 -0
- jaclang/compiler/tests/fixtures/pkg_import_main.jac +10 -0
- jaclang/compiler/tests/fixtures/pkg_import_main_py.jac +11 -0
- jaclang/compiler/tests/test_importer.py +20 -0
- jaclang/compiler/tests/test_parser.py +1 -0
- jaclang/compiler/unitree.py +456 -304
- jaclang/langserve/engine.jac +498 -0
- jaclang/langserve/sem_manager.jac +309 -0
- jaclang/langserve/server.jac +186 -0
- jaclang/langserve/tests/server_test/test_lang_serve.py +6 -7
- jaclang/langserve/tests/server_test/utils.py +4 -1
- jaclang/langserve/tests/session.jac +294 -0
- jaclang/langserve/tests/test_sem_tokens.py +2 -2
- jaclang/langserve/tests/test_server.py +12 -7
- jaclang/langserve/utils.jac +51 -30
- jaclang/runtimelib/archetype.py +1 -1
- jaclang/runtimelib/builtin.py +17 -14
- jaclang/runtimelib/importer.py +26 -8
- jaclang/runtimelib/machine.py +96 -55
- jaclang/runtimelib/tests/fixtures/traversing_save.jac +7 -5
- jaclang/runtimelib/utils.py +3 -3
- jaclang/tests/fixtures/backward_edge_visit.jac +31 -0
- jaclang/tests/fixtures/builtin_printgraph.jac +85 -0
- jaclang/tests/fixtures/builtin_printgraph_json.jac +21 -0
- jaclang/tests/fixtures/builtin_printgraph_mermaid.jac +16 -0
- jaclang/tests/fixtures/chandra_bugs2.jac +20 -13
- jaclang/tests/fixtures/concurrency.jac +1 -1
- jaclang/tests/fixtures/edge_ability.jac +49 -0
- jaclang/tests/fixtures/guess_game.jac +1 -1
- jaclang/tests/fixtures/here_usage_error.jac +21 -0
- jaclang/tests/fixtures/here_visitor_usage.jac +21 -0
- jaclang/tests/fixtures/node_del.jac +30 -36
- jaclang/tests/fixtures/visit_traversal.jac +47 -0
- jaclang/tests/test_cli.py +12 -7
- jaclang/tests/test_language.py +91 -16
- jaclang/utils/helpers.py +14 -6
- jaclang/utils/lang_tools.py +2 -3
- jaclang/utils/tests/test_lang_tools.py +2 -1
- jaclang/utils/treeprinter.py +3 -4
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/METADATA +4 -3
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/RECORD +71 -55
- {jaclang-0.8.0.dist-info → jaclang-0.8.1.dist-info}/WHEEL +1 -1
- jaclang/langserve/engine.py +0 -553
- jaclang/langserve/sem_manager.py +0 -383
- jaclang/langserve/server.py +0 -167
- jaclang/langserve/tests/session.py +0 -255
- jaclang/tests/fixtures/builtin_dotgen.jac +0 -42
- jaclang/tests/fixtures/builtin_dotgen_json.jac +0 -21
- /jaclang/langserve/{__init__.py → __init__.jac} +0 -0
- {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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
287
|
+
from jaclang import JacMachineInterface as _
|
|
290
288
|
|
|
291
|
-
|
|
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 =
|
|
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
|
|
158
|
+
// [Heading]: Match literal patterns.
|
|
169
159
|
literal_pattern: (INT | FLOAT | multistring)
|
|
170
160
|
|
|
171
161
|
// [Heading]: Match singleton patterns.
|