jaclang 0.0.5__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.

Files changed (94) hide show
  1. jaclang/__init__.py +2 -1
  2. jaclang/cli/__jac_gen__/__init__.py +0 -0
  3. jaclang/cli/__jac_gen__/cli.py +175 -0
  4. jaclang/cli/__jac_gen__/cmds.py +132 -0
  5. jaclang/cli/cli.jac +2 -2
  6. jaclang/cli/cmds.jac +8 -2
  7. jaclang/cli/impl/__jac_gen__/__init__.py +0 -0
  8. jaclang/cli/impl/__jac_gen__/cli_impl.py +16 -0
  9. jaclang/cli/impl/__jac_gen__/cmds_impl.py +26 -0
  10. jaclang/cli/impl/cli_impl.jac +25 -8
  11. jaclang/cli/impl/cmds_impl.jac +35 -6
  12. jaclang/core/__jac_gen__/__init__.py +0 -0
  13. jaclang/core/__jac_gen__/primitives.py +567 -0
  14. jaclang/core/impl/__jac_gen__/__init__.py +0 -0
  15. jaclang/core/impl/__jac_gen__/arch_impl.py +24 -0
  16. jaclang/core/impl/__jac_gen__/element_impl.py +26 -0
  17. jaclang/core/impl/__jac_gen__/exec_ctx_impl.py +12 -0
  18. jaclang/core/impl/__jac_gen__/memory_impl.py +14 -0
  19. jaclang/core/impl/element_impl.jac +3 -3
  20. jaclang/core/impl/exec_ctx_impl.jac +3 -6
  21. jaclang/core/primitives.jac +4 -3
  22. jaclang/jac/absyntree.py +555 -180
  23. jaclang/jac/constant.py +6 -0
  24. jaclang/jac/importer.py +34 -56
  25. jaclang/jac/langserve.py +26 -0
  26. jaclang/jac/lexer.py +35 -3
  27. jaclang/jac/parser.py +146 -115
  28. jaclang/jac/passes/blue/__init__.py +8 -3
  29. jaclang/jac/passes/blue/ast_build_pass.py +454 -305
  30. jaclang/jac/passes/blue/blue_pygen_pass.py +112 -74
  31. jaclang/jac/passes/blue/decl_def_match_pass.py +49 -277
  32. jaclang/jac/passes/blue/import_pass.py +1 -1
  33. jaclang/jac/passes/blue/pyout_pass.py +74 -0
  34. jaclang/jac/passes/blue/semantic_check_pass.py +37 -0
  35. jaclang/jac/passes/blue/sym_tab_build_pass.py +1045 -0
  36. jaclang/jac/passes/blue/tests/test_ast_build_pass.py +2 -2
  37. jaclang/jac/passes/blue/tests/test_blue_pygen_pass.py +9 -28
  38. jaclang/jac/passes/blue/tests/test_decl_def_match_pass.py +13 -22
  39. jaclang/jac/passes/blue/tests/test_sym_tab_build_pass.py +22 -0
  40. jaclang/jac/passes/ir_pass.py +8 -6
  41. jaclang/jac/passes/purple/__jac_gen__/__init__.py +0 -0
  42. jaclang/jac/passes/purple/__jac_gen__/analyze_pass.py +37 -0
  43. jaclang/jac/passes/purple/__jac_gen__/purple_pygen_pass.py +305 -0
  44. jaclang/jac/passes/purple/impl/__jac_gen__/__init__.py +0 -0
  45. jaclang/jac/passes/purple/impl/__jac_gen__/purple_pygen_pass_impl.py +23 -0
  46. jaclang/jac/passes/purple/impl/purple_pygen_pass_impl.jac +2 -5
  47. jaclang/jac/symtable.py +154 -0
  48. jaclang/jac/tests/fixtures/__jac_gen__/__init__.py +0 -0
  49. jaclang/jac/tests/fixtures/__jac_gen__/hello_world.py +16 -0
  50. jaclang/jac/tests/fixtures/fam.jac +7 -8
  51. jaclang/jac/tests/fixtures/mod_doc_test.jac +1 -0
  52. jaclang/jac/tests/test_parser.py +8 -0
  53. jaclang/jac/transform.py +41 -14
  54. jaclang/jac/transpiler.py +18 -9
  55. jaclang/utils/fstring_parser.py +2 -2
  56. jaclang/utils/helpers.py +41 -0
  57. jaclang/utils/lang_tools.py +12 -2
  58. jaclang/utils/test.py +41 -0
  59. jaclang/vendor/__init__.py +1 -0
  60. jaclang/vendor/pygls/__init__.py +25 -0
  61. jaclang/vendor/pygls/capabilities.py +502 -0
  62. jaclang/vendor/pygls/client.py +176 -0
  63. jaclang/vendor/pygls/constants.py +26 -0
  64. jaclang/vendor/pygls/exceptions.py +220 -0
  65. jaclang/vendor/pygls/feature_manager.py +241 -0
  66. jaclang/vendor/pygls/lsp/__init__.py +139 -0
  67. jaclang/vendor/pygls/lsp/client.py +2224 -0
  68. jaclang/vendor/pygls/lsprotocol/__init__.py +2 -0
  69. jaclang/vendor/pygls/lsprotocol/_hooks.py +1233 -0
  70. jaclang/vendor/pygls/lsprotocol/converters.py +17 -0
  71. jaclang/vendor/pygls/lsprotocol/types.py +12820 -0
  72. jaclang/vendor/pygls/lsprotocol/validators.py +47 -0
  73. jaclang/vendor/pygls/progress.py +79 -0
  74. jaclang/vendor/pygls/protocol.py +1184 -0
  75. jaclang/vendor/pygls/server.py +620 -0
  76. jaclang/vendor/pygls/uris.py +184 -0
  77. jaclang/vendor/pygls/workspace/__init__.py +81 -0
  78. jaclang/vendor/pygls/workspace/position.py +204 -0
  79. jaclang/vendor/pygls/workspace/text_document.py +234 -0
  80. jaclang/vendor/pygls/workspace/workspace.py +311 -0
  81. {jaclang-0.0.5.dist-info → jaclang-0.0.8.dist-info}/METADATA +1 -1
  82. jaclang-0.0.8.dist-info/RECORD +118 -0
  83. jaclang/core/jaclang.jac +0 -62
  84. jaclang/jac/passes/blue/tests/test_type_analyze_pass.py +0 -53
  85. jaclang/jac/passes/blue/type_analyze_pass.py +0 -728
  86. jaclang/jac/sym_table.py +0 -127
  87. jaclang-0.0.5.dist-info/RECORD +0 -73
  88. /jaclang/{utils → vendor}/sly/__init__.py +0 -0
  89. /jaclang/{utils → vendor}/sly/docparse.py +0 -0
  90. /jaclang/{utils → vendor}/sly/lex.py +0 -0
  91. /jaclang/{utils → vendor}/sly/yacc.py +0 -0
  92. {jaclang-0.0.5.dist-info → jaclang-0.0.8.dist-info}/WHEEL +0 -0
  93. {jaclang-0.0.5.dist-info → jaclang-0.0.8.dist-info}/entry_points.txt +0 -0
  94. {jaclang-0.0.5.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))