jaclang 0.0.6__py3-none-any.whl → 0.0.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/__init__.py +2 -1
- jaclang/cli/__jac_gen__/__init__.py +0 -0
- jaclang/cli/__jac_gen__/cli.py +175 -0
- jaclang/cli/__jac_gen__/cmds.py +132 -0
- jaclang/cli/cmds.jac +3 -0
- jaclang/cli/impl/__jac_gen__/__init__.py +0 -0
- jaclang/cli/impl/__jac_gen__/cli_impl.py +16 -0
- jaclang/cli/impl/__jac_gen__/cmds_impl.py +26 -0
- jaclang/cli/impl/cmds_impl.jac +17 -3
- jaclang/core/__jac_gen__/__init__.py +0 -0
- jaclang/core/__jac_gen__/primitives.py +567 -0
- jaclang/core/impl/__jac_gen__/__init__.py +0 -0
- jaclang/core/impl/__jac_gen__/arch_impl.py +24 -0
- jaclang/core/impl/__jac_gen__/element_impl.py +26 -0
- jaclang/core/impl/__jac_gen__/exec_ctx_impl.py +12 -0
- jaclang/core/impl/__jac_gen__/memory_impl.py +14 -0
- jaclang/core/impl/element_impl.jac +2 -2
- jaclang/core/primitives.jac +1 -0
- jaclang/jac/absyntree.py +65 -42
- jaclang/jac/constant.py +4 -0
- jaclang/jac/importer.py +18 -60
- jaclang/jac/langserve.py +26 -0
- jaclang/jac/lexer.py +9 -1
- jaclang/jac/parser.py +135 -123
- jaclang/jac/passes/blue/ast_build_pass.py +410 -353
- jaclang/jac/passes/blue/blue_pygen_pass.py +15 -0
- jaclang/jac/passes/blue/decl_def_match_pass.py +33 -21
- jaclang/jac/passes/blue/import_pass.py +1 -1
- jaclang/jac/passes/blue/pyout_pass.py +47 -12
- jaclang/jac/passes/blue/sym_tab_build_pass.py +38 -127
- jaclang/jac/passes/blue/tests/test_ast_build_pass.py +2 -2
- jaclang/jac/passes/blue/tests/test_blue_pygen_pass.py +9 -30
- jaclang/jac/passes/blue/tests/test_decl_def_match_pass.py +13 -13
- jaclang/jac/passes/blue/tests/test_sym_tab_build_pass.py +6 -4
- jaclang/jac/passes/ir_pass.py +1 -1
- jaclang/jac/passes/purple/__jac_gen__/__init__.py +0 -0
- jaclang/jac/passes/purple/__jac_gen__/analyze_pass.py +37 -0
- jaclang/jac/passes/purple/__jac_gen__/purple_pygen_pass.py +305 -0
- jaclang/jac/passes/purple/impl/__jac_gen__/__init__.py +0 -0
- jaclang/jac/passes/purple/impl/__jac_gen__/purple_pygen_pass_impl.py +23 -0
- jaclang/jac/symtable.py +12 -4
- jaclang/jac/tests/fixtures/__jac_gen__/__init__.py +0 -0
- jaclang/jac/tests/fixtures/__jac_gen__/hello_world.py +16 -0
- jaclang/jac/tests/fixtures/fam.jac +7 -8
- jaclang/jac/transform.py +4 -3
- jaclang/jac/transpiler.py +13 -9
- jaclang/utils/fstring_parser.py +2 -2
- jaclang/utils/helpers.py +41 -0
- jaclang/utils/test.py +30 -0
- jaclang/vendor/__init__.py +1 -0
- jaclang/vendor/pygls/__init__.py +25 -0
- jaclang/vendor/pygls/capabilities.py +502 -0
- jaclang/vendor/pygls/client.py +176 -0
- jaclang/vendor/pygls/constants.py +26 -0
- jaclang/vendor/pygls/exceptions.py +220 -0
- jaclang/vendor/pygls/feature_manager.py +241 -0
- jaclang/vendor/pygls/lsp/__init__.py +139 -0
- jaclang/vendor/pygls/lsp/client.py +2224 -0
- jaclang/vendor/pygls/lsprotocol/__init__.py +2 -0
- jaclang/vendor/pygls/lsprotocol/_hooks.py +1233 -0
- jaclang/vendor/pygls/lsprotocol/converters.py +17 -0
- jaclang/vendor/pygls/lsprotocol/types.py +12820 -0
- jaclang/vendor/pygls/lsprotocol/validators.py +47 -0
- jaclang/vendor/pygls/progress.py +79 -0
- jaclang/vendor/pygls/protocol.py +1184 -0
- jaclang/vendor/pygls/server.py +620 -0
- jaclang/vendor/pygls/uris.py +184 -0
- jaclang/vendor/pygls/workspace/__init__.py +81 -0
- jaclang/vendor/pygls/workspace/position.py +204 -0
- jaclang/vendor/pygls/workspace/text_document.py +234 -0
- jaclang/vendor/pygls/workspace/workspace.py +311 -0
- {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/METADATA +1 -1
- jaclang-0.0.8.dist-info/RECORD +118 -0
- jaclang/core/jaclang.jac +0 -62
- jaclang-0.0.6.dist-info/RECORD +0 -76
- /jaclang/{utils → vendor}/sly/__init__.py +0 -0
- /jaclang/{utils → vendor}/sly/docparse.py +0 -0
- /jaclang/{utils → vendor}/sly/lex.py +0 -0
- /jaclang/{utils → vendor}/sly/yacc.py +0 -0
- {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/WHEEL +0 -0
- {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/entry_points.txt +0 -0
- {jaclang-0.0.6.dist-info → jaclang-0.0.8.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
import attrs
|
|
9
|
+
|
|
10
|
+
INTEGER_MIN_VALUE = -(2**31)
|
|
11
|
+
INTEGER_MAX_VALUE = 2**31 - 1
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def integer_validator(
|
|
15
|
+
instance: Any,
|
|
16
|
+
attribute: "attrs.Attribute[int]",
|
|
17
|
+
value: Any,
|
|
18
|
+
) -> bool:
|
|
19
|
+
"""Validates that integer value belongs in the range expected by LSP."""
|
|
20
|
+
if not isinstance(value, int) or not (
|
|
21
|
+
INTEGER_MIN_VALUE <= value <= INTEGER_MAX_VALUE
|
|
22
|
+
):
|
|
23
|
+
name = attribute.name if hasattr(attribute, "name") else str(attribute)
|
|
24
|
+
raise ValueError(
|
|
25
|
+
f"{instance.__class__.__qualname__}.{name} should be in range [{INTEGER_MIN_VALUE}:{INTEGER_MAX_VALUE}], but was {value}."
|
|
26
|
+
)
|
|
27
|
+
return True
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
UINTEGER_MIN_VALUE = 0
|
|
31
|
+
UINTEGER_MAX_VALUE = 2**31 - 1
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def uinteger_validator(
|
|
35
|
+
instance: Any,
|
|
36
|
+
attribute: "attrs.Attribute[int]",
|
|
37
|
+
value: Any,
|
|
38
|
+
) -> bool:
|
|
39
|
+
"""Validates that unsigned integer value belongs in the range expected by LSP."""
|
|
40
|
+
if not isinstance(value, int) or not (
|
|
41
|
+
UINTEGER_MIN_VALUE <= value <= UINTEGER_MAX_VALUE
|
|
42
|
+
):
|
|
43
|
+
name = attribute.name if hasattr(attribute, "name") else str(attribute)
|
|
44
|
+
raise ValueError(
|
|
45
|
+
f"{instance.__class__.__qualname__}.{name} should be in range [{UINTEGER_MIN_VALUE}:{UINTEGER_MAX_VALUE}], but was {value}."
|
|
46
|
+
)
|
|
47
|
+
return True
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from concurrent.futures import Future
|
|
3
|
+
from typing import Dict
|
|
4
|
+
|
|
5
|
+
from jaclang.vendor.pygls.lsprotocol.types import (
|
|
6
|
+
PROGRESS,
|
|
7
|
+
WINDOW_WORK_DONE_PROGRESS_CREATE,
|
|
8
|
+
ProgressParams,
|
|
9
|
+
ProgressToken,
|
|
10
|
+
WorkDoneProgressBegin,
|
|
11
|
+
WorkDoneProgressEnd,
|
|
12
|
+
WorkDoneProgressReport,
|
|
13
|
+
WorkDoneProgressCreateParams,
|
|
14
|
+
)
|
|
15
|
+
from jaclang.vendor.pygls.protocol import LanguageServerProtocol
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Progress:
|
|
19
|
+
"""A class for working with client's progress bar.
|
|
20
|
+
|
|
21
|
+
Attributes:
|
|
22
|
+
_lsp(LanguageServerProtocol): Language server protocol instance
|
|
23
|
+
tokens(dict): Holds futures for work done progress tokens that are
|
|
24
|
+
already registered. These futures will be cancelled if the client
|
|
25
|
+
sends a cancel work done process notification.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, lsp: LanguageServerProtocol) -> None:
|
|
29
|
+
self._lsp = lsp
|
|
30
|
+
|
|
31
|
+
self.tokens: Dict[ProgressToken, Future] = {}
|
|
32
|
+
|
|
33
|
+
def _check_token_registered(self, token: ProgressToken) -> None:
|
|
34
|
+
if token in self.tokens:
|
|
35
|
+
raise Exception("Token is already registered!")
|
|
36
|
+
|
|
37
|
+
def _register_token(self, token: ProgressToken) -> None:
|
|
38
|
+
self.tokens[token] = Future()
|
|
39
|
+
|
|
40
|
+
def create(self, token: ProgressToken, callback=None) -> Future:
|
|
41
|
+
"""Create a server initiated work done progress."""
|
|
42
|
+
self._check_token_registered(token)
|
|
43
|
+
|
|
44
|
+
def on_created(*args, **kwargs):
|
|
45
|
+
self._register_token(token)
|
|
46
|
+
if callback is not None:
|
|
47
|
+
callback(*args, **kwargs)
|
|
48
|
+
|
|
49
|
+
return self._lsp.send_request(
|
|
50
|
+
WINDOW_WORK_DONE_PROGRESS_CREATE,
|
|
51
|
+
WorkDoneProgressCreateParams(token=token),
|
|
52
|
+
on_created,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
async def create_async(self, token: ProgressToken) -> asyncio.Future:
|
|
56
|
+
"""Create a server initiated work done progress."""
|
|
57
|
+
self._check_token_registered(token)
|
|
58
|
+
|
|
59
|
+
result = await self._lsp.send_request_async(
|
|
60
|
+
WINDOW_WORK_DONE_PROGRESS_CREATE,
|
|
61
|
+
WorkDoneProgressCreateParams(token=token),
|
|
62
|
+
)
|
|
63
|
+
self._register_token(token)
|
|
64
|
+
return result
|
|
65
|
+
|
|
66
|
+
def begin(self, token: ProgressToken, value: WorkDoneProgressBegin) -> None:
|
|
67
|
+
"""Notify beginning of work."""
|
|
68
|
+
# Register cancellation future for the case of client initiated progress
|
|
69
|
+
self.tokens.setdefault(token, Future())
|
|
70
|
+
|
|
71
|
+
return self._lsp.notify(PROGRESS, ProgressParams(token=token, value=value))
|
|
72
|
+
|
|
73
|
+
def report(self, token: ProgressToken, value: WorkDoneProgressReport) -> None:
|
|
74
|
+
"""Notify progress of work."""
|
|
75
|
+
self._lsp.notify(PROGRESS, ProgressParams(token=token, value=value))
|
|
76
|
+
|
|
77
|
+
def end(self, token: ProgressToken, value: WorkDoneProgressEnd) -> None:
|
|
78
|
+
"""Notify end of work."""
|
|
79
|
+
self._lsp.notify(PROGRESS, ProgressParams(token=token, value=value))
|