jaclang 0.8.6__py3-none-any.whl → 0.8.8__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.md +3 -3
- jaclang/cli/cli.py +37 -37
- jaclang/cli/cmdreg.py +45 -140
- jaclang/compiler/constant.py +0 -1
- jaclang/compiler/jac.lark +3 -6
- jaclang/compiler/larkparse/jac_parser.py +2 -2
- jaclang/compiler/parser.py +213 -34
- jaclang/compiler/passes/main/__init__.py +2 -4
- jaclang/compiler/passes/main/def_use_pass.py +0 -4
- jaclang/compiler/passes/main/predynamo_pass.py +221 -0
- jaclang/compiler/passes/main/pyast_gen_pass.py +83 -55
- jaclang/compiler/passes/main/pyast_load_pass.py +66 -40
- jaclang/compiler/passes/main/sym_tab_build_pass.py +1 -1
- jaclang/compiler/passes/main/tests/fixtures/checker/import_sym.jac +2 -0
- jaclang/compiler/passes/main/tests/fixtures/checker/import_sym_test.jac +6 -0
- jaclang/compiler/passes/main/tests/fixtures/checker/imported_sym.jac +5 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_arg_param_match.jac +37 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_arity.jac +18 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_binary_op.jac +21 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_call_expr_class.jac +12 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_cat_is_animal.jac +18 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_cyclic_symbol.jac +4 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_expr_call.jac +9 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_float.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_import_missing_module.jac +13 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_magic_call.jac +17 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_mod_path.jac +8 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_param_types.jac +11 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_self_type.jac +9 -0
- jaclang/compiler/passes/main/tests/fixtures/checker_sym_inherit.jac +42 -0
- jaclang/compiler/passes/main/tests/fixtures/predynamo_fix3.jac +43 -0
- jaclang/compiler/passes/main/tests/fixtures/predynamo_where_assign.jac +13 -0
- jaclang/compiler/passes/main/tests/fixtures/predynamo_where_return.jac +11 -0
- jaclang/compiler/passes/main/tests/test_checker_pass.py +265 -0
- jaclang/compiler/passes/main/tests/test_predynamo_pass.py +57 -0
- jaclang/compiler/passes/main/type_checker_pass.py +36 -61
- jaclang/compiler/passes/tool/doc_ir_gen_pass.py +204 -44
- jaclang/compiler/passes/tool/jac_formatter_pass.py +119 -69
- jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +3 -3
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +4 -5
- jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +171 -11
- jaclang/compiler/passes/transform.py +12 -8
- jaclang/compiler/program.py +14 -6
- jaclang/compiler/tests/fixtures/jac_import_py_files.py +4 -0
- jaclang/compiler/tests/fixtures/jac_module.jac +3 -0
- jaclang/compiler/tests/fixtures/multiple_syntax_errors.jac +10 -0
- jaclang/compiler/tests/fixtures/python_module.py +1 -0
- jaclang/compiler/tests/test_importer.py +39 -0
- jaclang/compiler/tests/test_parser.py +49 -0
- jaclang/compiler/type_system/operations.py +104 -0
- jaclang/compiler/type_system/type_evaluator.py +470 -47
- jaclang/compiler/type_system/type_utils.py +246 -0
- jaclang/compiler/type_system/types.py +58 -2
- jaclang/compiler/unitree.py +79 -94
- jaclang/langserve/engine.jac +253 -230
- jaclang/langserve/server.jac +46 -15
- jaclang/langserve/tests/fixtures/circle.jac +3 -3
- jaclang/langserve/tests/fixtures/circle_err.jac +3 -3
- jaclang/langserve/tests/fixtures/circle_pure.test.jac +3 -3
- jaclang/langserve/tests/fixtures/completion_test_err.jac +10 -0
- jaclang/langserve/tests/server_test/circle_template.jac +80 -0
- jaclang/langserve/tests/server_test/glob_template.jac +4 -0
- jaclang/langserve/tests/server_test/test_lang_serve.py +154 -312
- jaclang/langserve/tests/server_test/utils.py +153 -116
- jaclang/langserve/tests/test_dev_server.py +1 -1
- jaclang/langserve/tests/test_server.py +30 -86
- jaclang/langserve/utils.jac +56 -63
- jaclang/runtimelib/machine.py +7 -0
- jaclang/runtimelib/meta_importer.py +27 -1
- jaclang/runtimelib/tests/fixtures/custom_access_validation.jac +1 -1
- jaclang/runtimelib/tests/fixtures/savable_object.jac +2 -2
- jaclang/settings.py +18 -14
- jaclang/tests/fixtures/abc_check.jac +3 -3
- jaclang/tests/fixtures/arch_rel_import_creation.jac +12 -12
- jaclang/tests/fixtures/chandra_bugs2.jac +3 -3
- jaclang/tests/fixtures/create_dynamic_archetype.jac +13 -13
- jaclang/tests/fixtures/jac_run_py_bugs.py +18 -0
- jaclang/tests/fixtures/jac_run_py_import.py +13 -0
- jaclang/tests/fixtures/lambda_arg_annotation.jac +15 -0
- jaclang/tests/fixtures/lambda_self.jac +18 -0
- jaclang/tests/fixtures/maxfail_run_test.jac +4 -4
- jaclang/tests/fixtures/params/param_syntax_err.jac +9 -0
- jaclang/tests/fixtures/params/test_complex_params.jac +42 -0
- jaclang/tests/fixtures/params/test_failing_kwonly.jac +207 -0
- jaclang/tests/fixtures/params/test_failing_posonly.jac +116 -0
- jaclang/tests/fixtures/params/test_failing_varargs.jac +300 -0
- jaclang/tests/fixtures/params/test_kwonly_params.jac +29 -0
- jaclang/tests/fixtures/py2jac_params.py +8 -0
- jaclang/tests/fixtures/run_test.jac +4 -4
- jaclang/tests/test_cli.py +103 -18
- jaclang/tests/test_language.py +74 -16
- jaclang/utils/helpers.py +47 -2
- jaclang/utils/module_resolver.py +11 -1
- jaclang/utils/test.py +8 -0
- jaclang/utils/treeprinter.py +0 -18
- {jaclang-0.8.6.dist-info → jaclang-0.8.8.dist-info}/METADATA +3 -3
- {jaclang-0.8.6.dist-info → jaclang-0.8.8.dist-info}/RECORD +99 -62
- {jaclang-0.8.6.dist-info → jaclang-0.8.8.dist-info}/WHEEL +1 -1
- jaclang/compiler/passes/main/inheritance_pass.py +0 -131
- jaclang/langserve/dev_engine.jac +0 -645
- jaclang/langserve/dev_server.jac +0 -201
- jaclang/langserve/tests/server_test/code_test.py +0 -0
- {jaclang-0.8.6.dist-info → jaclang-0.8.8.dist-info}/entry_points.txt +0 -0
jaclang/cli/cli.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# **Jac Language Command Line Interface (CLI)**
|
|
2
2
|
|
|
3
|
-
Jac Language CLI
|
|
3
|
+
git Jac Language CLI provides a variety of commands to facilitate users. Additionally, Jac language offers users the ability to define custom CLI commands through plugins. This document aims to provide an overview of each command along with clear usage instructions.
|
|
4
4
|
|
|
5
5
|
> [!TIP]
|
|
6
|
-
>
|
|
6
|
+
> Use `jac --help` to see available commands and usage.
|
|
7
7
|
|
|
8
8
|
### Click one of the default commands below and see the usage.
|
|
9
|
-
- [tool](#tool) , [run](#run) , [clean](#clean) , [format](#format) , [check](#check) , [build](#build)
|
|
9
|
+
- [tool](#tool) , [run](#run) , [clean](#clean) , [format](#format) , [check](#check) , [build](#build) , [enter](#enter) , [test](#test)
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
jaclang/cli/cli.py
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"""Command line interface tool for the Jac language."""
|
|
2
2
|
|
|
3
3
|
import ast as ast3
|
|
4
|
-
import importlib
|
|
5
4
|
import marshal
|
|
6
5
|
import os
|
|
7
6
|
import pickle
|
|
8
7
|
import sys
|
|
9
8
|
import types
|
|
9
|
+
from importlib.metadata import version as pkg_version
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
from typing import Optional
|
|
12
12
|
|
|
13
13
|
import jaclang.compiler.unitree as uni
|
|
14
|
-
from jaclang.cli.cmdreg import
|
|
14
|
+
from jaclang.cli.cmdreg import cmd_registry
|
|
15
15
|
from jaclang.compiler.passes.main import PyastBuildPass
|
|
16
16
|
from jaclang.compiler.program import JacProgram
|
|
17
17
|
from jaclang.runtimelib.builtin import printgraph
|
|
18
18
|
from jaclang.runtimelib.constructs import WalkerArchetype
|
|
19
19
|
from jaclang.runtimelib.machine import ExecutionContext, JacMachine as Jac
|
|
20
20
|
from jaclang.runtimelib.utils import read_file_with_encoding
|
|
21
|
+
from jaclang.settings import settings
|
|
21
22
|
from jaclang.utils.helpers import debugger as db
|
|
22
23
|
from jaclang.utils.lang_tools import AstTool
|
|
23
24
|
|
|
@@ -132,7 +133,7 @@ def run(
|
|
|
132
133
|
jac run myprogram.jac --session mysession
|
|
133
134
|
jac run myprogram.jac --no-main
|
|
134
135
|
"""
|
|
135
|
-
# if no session specified, check if it was defined
|
|
136
|
+
# if no session specified, check if it was defined via global CLI args
|
|
136
137
|
# otherwise default to jaclang.session
|
|
137
138
|
base, mod, mach = proc_file_sess(filename, session)
|
|
138
139
|
lng = filename.split(".")[-1]
|
|
@@ -160,11 +161,6 @@ def run(
|
|
|
160
161
|
)
|
|
161
162
|
except Exception as e:
|
|
162
163
|
print(f"Error running {filename}: {e}", file=sys.stderr)
|
|
163
|
-
else:
|
|
164
|
-
print(
|
|
165
|
-
"Not a valid file!\nOnly supports `.jac`, `.jir`, and `.py`",
|
|
166
|
-
file=sys.stderr,
|
|
167
|
-
)
|
|
168
164
|
|
|
169
165
|
mach.close()
|
|
170
166
|
|
|
@@ -322,25 +318,7 @@ def lsp() -> None:
|
|
|
322
318
|
Examples:
|
|
323
319
|
jac lsp
|
|
324
320
|
"""
|
|
325
|
-
from jaclang.langserve.server import run_lang_server
|
|
326
|
-
|
|
327
|
-
run_lang_server()
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
@cmd_registry.register
|
|
331
|
-
def lsp_dev() -> None:
|
|
332
|
-
"""Run Jac Language Server Protocol in Developer Mode.
|
|
333
|
-
|
|
334
|
-
Starts the experimental Jac Language Server with enhanced features
|
|
335
|
-
for development and testing. Used by editor extensions in developer mode.
|
|
336
|
-
|
|
337
|
-
Args:
|
|
338
|
-
This command takes no parameters.
|
|
339
|
-
|
|
340
|
-
Examples:
|
|
341
|
-
jac lsp_dev
|
|
342
|
-
"""
|
|
343
|
-
from jaclang.langserve.dev_server import run_lang_server
|
|
321
|
+
from jaclang.langserve.server import run_lang_server # type: ignore
|
|
344
322
|
|
|
345
323
|
run_lang_server()
|
|
346
324
|
|
|
@@ -662,25 +640,47 @@ def start_cli() -> None:
|
|
|
662
640
|
- None
|
|
663
641
|
"""
|
|
664
642
|
parser = cmd_registry.parser
|
|
643
|
+
# Default to `run` when a file is provided without a subcommand
|
|
644
|
+
raw_argv = sys.argv[1:]
|
|
645
|
+
if (
|
|
646
|
+
raw_argv
|
|
647
|
+
and not raw_argv[0].startswith("-")
|
|
648
|
+
and raw_argv[0].lower().endswith((".jac", ".jir", ".py"))
|
|
649
|
+
):
|
|
650
|
+
sys.argv = [sys.argv[0], "run"] + raw_argv
|
|
665
651
|
args = parser.parse_args()
|
|
666
652
|
cmd_registry.args = args
|
|
667
653
|
|
|
654
|
+
# Apply global settings overrides from CLI flags before running commands
|
|
655
|
+
settings.load_command_line_arguments(args)
|
|
656
|
+
|
|
668
657
|
if args.version:
|
|
669
|
-
version =
|
|
658
|
+
version = pkg_version("jaclang")
|
|
670
659
|
print(f"Jac version {version}")
|
|
671
660
|
print("Jac path:", __file__)
|
|
672
661
|
return
|
|
673
662
|
|
|
663
|
+
if args.command is None:
|
|
664
|
+
parser.print_help()
|
|
665
|
+
return
|
|
666
|
+
|
|
674
667
|
command = cmd_registry.get(args.command)
|
|
675
|
-
if command:
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
668
|
+
if not command:
|
|
669
|
+
print(f"Unknown command: {args.command}", file=sys.stderr)
|
|
670
|
+
parser.print_help()
|
|
671
|
+
return
|
|
672
|
+
|
|
673
|
+
args_dict = vars(args)
|
|
674
|
+
args_dict.pop("command")
|
|
675
|
+
args_dict.pop("version", None)
|
|
676
|
+
|
|
677
|
+
# Only pass parameters that the target command accepts
|
|
678
|
+
allowed_params = set(command.sig.parameters.keys())
|
|
679
|
+
filtered_args = {k: v for k, v in args_dict.items() if k in allowed_params}
|
|
680
|
+
|
|
681
|
+
ret = command.call(**filtered_args)
|
|
682
|
+
if ret:
|
|
683
|
+
print(ret)
|
|
684
684
|
|
|
685
685
|
|
|
686
686
|
if __name__ == "__main__":
|
jaclang/cli/cmdreg.py
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import argparse
|
|
6
|
-
import cmd
|
|
7
6
|
import inspect
|
|
8
|
-
import pprint
|
|
9
7
|
import re
|
|
8
|
+
from dataclasses import fields as dataclass_fields
|
|
10
9
|
from typing import Callable, Dict, Optional
|
|
11
10
|
|
|
11
|
+
from jaclang.settings import Settings as JacSettings
|
|
12
|
+
|
|
12
13
|
|
|
13
14
|
class Command:
|
|
14
15
|
"""Represents a command in the command line interface."""
|
|
@@ -108,6 +109,47 @@ class CommandRegistry:
|
|
|
108
109
|
)
|
|
109
110
|
self.args = argparse.Namespace()
|
|
110
111
|
|
|
112
|
+
# Global settings overrides
|
|
113
|
+
settings_group = self.parser.add_argument_group(
|
|
114
|
+
"settings",
|
|
115
|
+
"Override Jac settings (from config/env). Provide only flags you want to change.",
|
|
116
|
+
)
|
|
117
|
+
for fld in dataclass_fields(JacSettings):
|
|
118
|
+
name = fld.name
|
|
119
|
+
opt = f"--{name.replace('_', '-')}"
|
|
120
|
+
if fld.type is bool:
|
|
121
|
+
# Tri-state: default None so unspecified won't override
|
|
122
|
+
settings_group.add_argument(
|
|
123
|
+
opt,
|
|
124
|
+
dest=name,
|
|
125
|
+
action="store_true",
|
|
126
|
+
default=None,
|
|
127
|
+
help=f"bool - Override setting '{name}' to true",
|
|
128
|
+
)
|
|
129
|
+
settings_group.add_argument(
|
|
130
|
+
f"--no-{name.replace('_', '-')}",
|
|
131
|
+
dest=name,
|
|
132
|
+
action="store_false",
|
|
133
|
+
default=None,
|
|
134
|
+
help=f"bool - Override setting '{name}' to false",
|
|
135
|
+
)
|
|
136
|
+
elif fld.type is int:
|
|
137
|
+
settings_group.add_argument(
|
|
138
|
+
opt,
|
|
139
|
+
dest=name,
|
|
140
|
+
type=int,
|
|
141
|
+
default=None,
|
|
142
|
+
help=f"int - Override setting '{name}'",
|
|
143
|
+
)
|
|
144
|
+
else:
|
|
145
|
+
settings_group.add_argument(
|
|
146
|
+
opt,
|
|
147
|
+
dest=name,
|
|
148
|
+
type=str,
|
|
149
|
+
default=None,
|
|
150
|
+
help=f"str - Override setting '{name}'",
|
|
151
|
+
)
|
|
152
|
+
|
|
111
153
|
def register(self, func: Callable) -> Callable:
|
|
112
154
|
"""Register a command in the registry."""
|
|
113
155
|
name = func.__name__
|
|
@@ -241,141 +283,4 @@ class CommandRegistry:
|
|
|
241
283
|
cmd_registry = CommandRegistry()
|
|
242
284
|
|
|
243
285
|
|
|
244
|
-
|
|
245
|
-
"""Command shell for the command line interface."""
|
|
246
|
-
|
|
247
|
-
intro = "Welcome to the Jac CLI!"
|
|
248
|
-
prompt = "jac> "
|
|
249
|
-
cmd_reg: CommandRegistry
|
|
250
|
-
|
|
251
|
-
def __init__(self, cmd_reg: CommandRegistry) -> None:
|
|
252
|
-
"""Initialize a CommandShell instance."""
|
|
253
|
-
self.cmd_reg = cmd_reg
|
|
254
|
-
super().__init__()
|
|
255
|
-
|
|
256
|
-
def do_exit(self, arg: list) -> bool:
|
|
257
|
-
"""Exit the command shell."""
|
|
258
|
-
return True
|
|
259
|
-
|
|
260
|
-
def default(self, line: str) -> None:
|
|
261
|
-
"""Process the command line input."""
|
|
262
|
-
args = vars(self.cmd_reg.parser.parse_args(line.split()))
|
|
263
|
-
command = self.cmd_reg.get(args["command"])
|
|
264
|
-
if command:
|
|
265
|
-
args.pop("command")
|
|
266
|
-
ret = command.call(**args)
|
|
267
|
-
if ret:
|
|
268
|
-
ret_str = pprint.pformat(ret, indent=2)
|
|
269
|
-
self.stdout.write(f"{ret_str}\n")
|
|
270
|
-
|
|
271
|
-
def do_help(self, arg: str) -> None:
|
|
272
|
-
"""Jac CLI help implementation."""
|
|
273
|
-
|
|
274
|
-
def get_info(name: str, doc: str, args: dict[str, inspect.Parameter]) -> None:
|
|
275
|
-
"""Format and display detailed command information."""
|
|
276
|
-
# Format the command header
|
|
277
|
-
self.stdout.write(f"\n{'=' * 80}\n")
|
|
278
|
-
self.stdout.write(f"COMMAND: {name}\n")
|
|
279
|
-
self.stdout.write(f"{'=' * 80}\n\n")
|
|
280
|
-
|
|
281
|
-
# Format the command description
|
|
282
|
-
doc_lines = doc.strip().split("\n")
|
|
283
|
-
for line in doc_lines:
|
|
284
|
-
self.stdout.write(f"{line}\n")
|
|
285
|
-
|
|
286
|
-
# Format the command arguments
|
|
287
|
-
if args:
|
|
288
|
-
self.stdout.write("\nARGUMENTS:\n")
|
|
289
|
-
for param_name, param in args.items():
|
|
290
|
-
# Get parameter type
|
|
291
|
-
type_name = (
|
|
292
|
-
param.annotation.__name__
|
|
293
|
-
if hasattr(param.annotation, "__name__")
|
|
294
|
-
else str(param.annotation)
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
# Format default value if present
|
|
298
|
-
default_str = ""
|
|
299
|
-
if param.default is not param.empty:
|
|
300
|
-
default_str = f" (default: {param.default})"
|
|
301
|
-
|
|
302
|
-
# Format required/optional status
|
|
303
|
-
req_str = (
|
|
304
|
-
" [required]"
|
|
305
|
-
if param.default is param.empty and param_name != "args"
|
|
306
|
-
else " [optional]"
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
self.stdout.write(
|
|
310
|
-
f" {param_name}: {type_name}{default_str}{req_str}\n"
|
|
311
|
-
)
|
|
312
|
-
else:
|
|
313
|
-
self.stdout.write("\nNo arguments\n")
|
|
314
|
-
|
|
315
|
-
# Format usage examples
|
|
316
|
-
command_parser = self.cmd_reg.sub_parsers.choices[name]
|
|
317
|
-
self.stdout.write(f"\nUSAGE:\n {command_parser.format_usage()[7:]}\n")
|
|
318
|
-
|
|
319
|
-
# Extract and format examples from docstring if present
|
|
320
|
-
if "Examples:" in doc:
|
|
321
|
-
examples_section = doc.split("Examples:")[1].strip()
|
|
322
|
-
example_lines = examples_section.split("\n")
|
|
323
|
-
self.stdout.write("\nEXAMPLES:\n")
|
|
324
|
-
for example in example_lines:
|
|
325
|
-
if example.strip():
|
|
326
|
-
self.stdout.write(f" {example.strip()}\n")
|
|
327
|
-
|
|
328
|
-
self.stdout.write("\n")
|
|
329
|
-
|
|
330
|
-
if arg == "all":
|
|
331
|
-
# Display all commands with their details
|
|
332
|
-
command_details = self.cmd_reg.get_all_commands()
|
|
333
|
-
for name, (doc, args) in sorted(command_details.items()):
|
|
334
|
-
get_info(name, doc, args)
|
|
335
|
-
|
|
336
|
-
elif arg:
|
|
337
|
-
# Display help for a specific command
|
|
338
|
-
command = self.cmd_reg.get(arg)
|
|
339
|
-
if command:
|
|
340
|
-
doc = command.func.__doc__ or "No help available."
|
|
341
|
-
args = command.sig.parameters
|
|
342
|
-
get_info(arg, doc, args)
|
|
343
|
-
else:
|
|
344
|
-
self.stdout.write(f"\nUnknown command: '{arg}'\n")
|
|
345
|
-
self.stdout.write("Type 'help' to see available commands.\n")
|
|
346
|
-
else:
|
|
347
|
-
# Display general help information
|
|
348
|
-
self.stdout.write("\n")
|
|
349
|
-
self.stdout.write("JAC PROGRAMMING LANGUAGE COMMAND LINE INTERFACE\n")
|
|
350
|
-
self.stdout.write("=" * 50 + "\n\n")
|
|
351
|
-
|
|
352
|
-
self.stdout.write("AVAILABLE COMMANDS:\n")
|
|
353
|
-
|
|
354
|
-
# Get all command names and sort them alphabetically
|
|
355
|
-
command_names = sorted(self.cmd_reg.registry.keys())
|
|
356
|
-
|
|
357
|
-
# Get brief descriptions for each command
|
|
358
|
-
command_descriptions: dict[str, str] = {}
|
|
359
|
-
for name in command_names:
|
|
360
|
-
command = self.cmd_reg.get(name)
|
|
361
|
-
if command and command.func.__doc__:
|
|
362
|
-
# Extract the first line of the docstring as a brief description
|
|
363
|
-
brief = command.func.__doc__.split("\n")[0].strip()
|
|
364
|
-
command_descriptions[name] = brief
|
|
365
|
-
else:
|
|
366
|
-
command_descriptions[name] = "No description available"
|
|
367
|
-
|
|
368
|
-
# Display commands with their brief descriptions
|
|
369
|
-
for name in command_names:
|
|
370
|
-
self.stdout.write(
|
|
371
|
-
f" {name.ljust(15)} - {command_descriptions[name]}\n"
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
self.stdout.write("\nFor detailed information on a specific command:\n")
|
|
375
|
-
self.stdout.write(" help <command>\n")
|
|
376
|
-
|
|
377
|
-
self.stdout.write("\nTo see detailed information for all commands:\n")
|
|
378
|
-
self.stdout.write(" help all\n")
|
|
379
|
-
|
|
380
|
-
self.stdout.write("\nTo exit the Jac CLI:\n")
|
|
381
|
-
self.stdout.write(" exit\n\n")
|
|
286
|
+
# Shell mode removed; interactive cmd-based shell is no longer supported.
|
jaclang/compiler/constant.py
CHANGED
jaclang/compiler/jac.lark
CHANGED
|
@@ -70,6 +70,8 @@ func_decl: (LPAREN func_decl_params? RPAREN) (RETURN_HINT expression)?
|
|
|
70
70
|
|
|
71
71
|
func_decl_params: (param_var COMMA)* param_var COMMA?
|
|
72
72
|
param_var: (STAR_POW | STAR_MUL)? named_ref type_tag (EQ expression)?
|
|
73
|
+
| DIV
|
|
74
|
+
| STAR_MUL
|
|
73
75
|
|
|
74
76
|
// [Heading]: Implementations.
|
|
75
77
|
impl_def: decorators? KW_IMPL dotted_name impl_spec? impl_tail
|
|
@@ -113,7 +115,6 @@ statement: import_stmt
|
|
|
113
115
|
| (yield_expr | KW_YIELD) SEMI
|
|
114
116
|
| raise_stmt SEMI
|
|
115
117
|
| assert_stmt SEMI
|
|
116
|
-
| check_stmt SEMI
|
|
117
118
|
| assignment SEMI
|
|
118
119
|
| delete_stmt SEMI
|
|
119
120
|
| report_stmt SEMI
|
|
@@ -209,9 +210,6 @@ raise_stmt: KW_RAISE (expression (KW_FROM expression)?)?
|
|
|
209
210
|
// [Heading]: Assert statements.
|
|
210
211
|
assert_stmt: KW_ASSERT expression (COMMA expression)?
|
|
211
212
|
|
|
212
|
-
// [Heading]: Check statements.
|
|
213
|
-
check_stmt: KW_CHECK expression
|
|
214
|
-
|
|
215
213
|
// [Heading]: Delete statements.
|
|
216
214
|
delete_stmt: KW_DELETE expression
|
|
217
215
|
|
|
@@ -402,7 +400,7 @@ kw_expr_list: (kw_expr_list COMMA)? kw_expr
|
|
|
402
400
|
kw_expr: named_ref EQ expression | STAR_POW expression
|
|
403
401
|
|
|
404
402
|
// [Heading]: Object-Spatial References.
|
|
405
|
-
edge_ref_chain: LSQUARE (KW_NODE| KW_EDGE)? expression? (edge_op_ref (filter_compr | expression)?)+ RSQUARE
|
|
403
|
+
edge_ref_chain: LSQUARE KW_ASYNC? (KW_NODE| KW_EDGE)? expression? (edge_op_ref (filter_compr | expression)?)+ RSQUARE
|
|
406
404
|
edge_op_ref: edge_any | edge_from | edge_to
|
|
407
405
|
edge_to: ARROW_R | ARROW_R_P1 typed_filter_compare_list ARROW_R_P2
|
|
408
406
|
edge_from: ARROW_L | ARROW_L_P1 typed_filter_compare_list ARROW_L_P2
|
|
@@ -523,7 +521,6 @@ KW_TEST: "test"
|
|
|
523
521
|
KW_IMPL: "impl"
|
|
524
522
|
KW_SEM: "sem"
|
|
525
523
|
KW_ASSERT: "assert"
|
|
526
|
-
KW_CHECK: "check"
|
|
527
524
|
KW_IF: "if"
|
|
528
525
|
KW_ELIF: "elif"
|
|
529
526
|
KW_ELSE: "else"
|