jaclang 0.5.6__py3-none-any.whl → 0.5.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 (51) hide show
  1. jaclang/__init__.py +6 -1
  2. jaclang/cli/cli.py +63 -20
  3. jaclang/cli/cmdreg.py +42 -12
  4. jaclang/compiler/__init__.py +6 -3
  5. jaclang/compiler/__jac_gen__/jac_parser.py +2 -2
  6. jaclang/compiler/absyntree.py +1740 -61
  7. jaclang/compiler/codeloc.py +7 -0
  8. jaclang/compiler/compile.py +4 -5
  9. jaclang/compiler/constant.py +52 -6
  10. jaclang/compiler/parser.py +220 -129
  11. jaclang/compiler/passes/main/def_impl_match_pass.py +19 -3
  12. jaclang/compiler/passes/main/def_use_pass.py +1 -1
  13. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +357 -0
  14. jaclang/compiler/passes/main/import_pass.py +7 -3
  15. jaclang/compiler/passes/main/pyast_gen_pass.py +333 -93
  16. jaclang/compiler/passes/main/pyast_load_pass.py +1779 -206
  17. jaclang/compiler/passes/main/pyout_pass.py +2 -2
  18. jaclang/compiler/passes/main/schedules.py +2 -1
  19. jaclang/compiler/passes/main/sym_tab_build_pass.py +20 -28
  20. jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +4 -4
  21. jaclang/compiler/passes/main/tests/test_pyast_build_pass.py +14 -5
  22. jaclang/compiler/passes/main/tests/test_sym_tab_build_pass.py +8 -8
  23. jaclang/compiler/passes/main/tests/test_typeinfo_pass.py +7 -0
  24. jaclang/compiler/passes/main/type_check_pass.py +0 -1
  25. jaclang/compiler/passes/tool/jac_formatter_pass.py +8 -17
  26. jaclang/compiler/passes/tool/tests/test_unparse_validate.py +43 -0
  27. jaclang/compiler/passes/utils/mypy_ast_build.py +28 -14
  28. jaclang/compiler/symtable.py +23 -2
  29. jaclang/compiler/tests/test_parser.py +53 -0
  30. jaclang/compiler/workspace.py +52 -26
  31. jaclang/core/aott.py +68 -0
  32. jaclang/core/construct.py +58 -6
  33. jaclang/core/importer.py +9 -10
  34. jaclang/core/utils.py +65 -3
  35. jaclang/plugin/builtin.py +42 -0
  36. jaclang/plugin/default.py +163 -18
  37. jaclang/plugin/feature.py +38 -10
  38. jaclang/plugin/spec.py +33 -6
  39. jaclang/utils/helpers.py +25 -0
  40. jaclang/utils/lang_tools.py +4 -1
  41. jaclang/utils/test.py +1 -0
  42. jaclang/utils/tests/test_lang_tools.py +12 -15
  43. jaclang/utils/treeprinter.py +10 -2
  44. {jaclang-0.5.6.dist-info → jaclang-0.5.8.dist-info}/METADATA +1 -1
  45. {jaclang-0.5.6.dist-info → jaclang-0.5.8.dist-info}/RECORD +48 -46
  46. {jaclang-0.5.6.dist-info → jaclang-0.5.8.dist-info}/WHEEL +1 -1
  47. jaclang/compiler/tests/fixtures/__jac_gen__/__init__.py +0 -0
  48. jaclang/compiler/tests/fixtures/__jac_gen__/hello_world.py +0 -5
  49. jaclang/core/jacbuiltins.py +0 -10
  50. {jaclang-0.5.6.dist-info → jaclang-0.5.8.dist-info}/entry_points.txt +0 -0
  51. {jaclang-0.5.6.dist-info → jaclang-0.5.8.dist-info}/top_level.txt +0 -0
@@ -22,6 +22,13 @@ class CodeGenTarget:
22
22
  mypy_ast: list[MypyNode] = field(default_factory=lambda: [])
23
23
  py_bytecode: Optional[bytes] = None
24
24
 
25
+ def clean(self) -> None:
26
+ """Clean code generation target."""
27
+ self.py = ""
28
+ self.jac = ""
29
+ self.py_ast = []
30
+ self.mypy_ast = []
31
+
25
32
 
26
33
  class CodeLocInfo:
27
34
  """Code location info."""
@@ -8,20 +8,19 @@ from jaclang.compiler.passes import Pass
8
8
  from jaclang.compiler.passes.main import PyOutPass, pass_schedule
9
9
  from jaclang.compiler.passes.tool import JacFormatPass
10
10
  from jaclang.compiler.passes.tool.schedules import format_pass
11
- from jaclang.compiler.passes.transform import Alert
12
11
 
13
12
 
14
- def compile_jac(file_path: str) -> list[Alert]:
13
+ def compile_jac(file_path: str, cache_result: bool = False) -> Pass:
15
14
  """Start Compile for Jac file and return python code as string."""
16
15
  code = jac_file_to_pass(
17
16
  file_path=file_path,
18
17
  schedule=pass_schedule,
19
18
  )
20
- if isinstance(code.ir, ast.Module) and not code.errors_had:
19
+ if cache_result and isinstance(code.ir, ast.Module):
21
20
  print_pass = PyOutPass(input_ir=code.ir, prior=code)
21
+ return print_pass
22
22
  else:
23
- return code.errors_had
24
- return print_pass.errors_had
23
+ return code
25
24
 
26
25
 
27
26
  def jac_file_to_pass(
@@ -201,12 +201,12 @@ class Tokens(str, Enum):
201
201
  CARROW_R_P2 = "CARROW_R_P2"
202
202
  GLOBAL_OP = "GLOBAL_OP"
203
203
  NONLOCAL_OP = "NONLOCAL_OP"
204
- HERE_OP = "HERE_OP"
205
- SELF_OP = "SELF_OP"
206
- INIT_OP = "INIT_OP"
207
- POST_INIT_OP = "POST_INIT_OP"
208
- SUPER_OP = "SUPER_OP"
209
- ROOT_OP = "ROOT_OP"
204
+ KW_HERE = "KW_HERE"
205
+ KW_SELF = "KW_SELF"
206
+ KW_INIT = "KW_INIT"
207
+ KW_SUPER = "KW_SUPER"
208
+ KW_ROOT = "KW_ROOT"
209
+ KW_POST_INIT = "KW_POST_INIT"
210
210
  WALKER_OP = "WALKER_OP"
211
211
  NODE_OP = "NODE_OP"
212
212
  EDGE_OP = "EDGE_OP"
@@ -234,3 +234,49 @@ class Tokens(str, Enum):
234
234
  def __str__(self) -> str:
235
235
  """Return the string representation of the token."""
236
236
  return self.value
237
+
238
+
239
+ DELIM_MAP = {
240
+ Tokens.COMMA: ",",
241
+ Tokens.EQ: "=",
242
+ Tokens.DECOR_OP: "@",
243
+ Tokens.WS: "\n",
244
+ Tokens.SEMI: ";",
245
+ Tokens.COLON: ":",
246
+ Tokens.LBRACE: "{",
247
+ Tokens.RBRACE: "}",
248
+ Tokens.LSQUARE: "[",
249
+ Tokens.RSQUARE: "]",
250
+ Tokens.LPAREN: "(",
251
+ Tokens.RPAREN: ")",
252
+ Tokens.RETURN_HINT: "->",
253
+ Tokens.DOT: ".",
254
+ }
255
+
256
+ colors = [
257
+ "#FFE9E9",
258
+ "#F0FFF0",
259
+ "#F5E5FF",
260
+ "#FFFFE0",
261
+ "#D2FEFF ",
262
+ "#E8FFD7",
263
+ "#FFDEAD",
264
+ "#FFF0F5",
265
+ "#F5FFFA",
266
+ "#FFC0CB",
267
+ "#7FFFD4",
268
+ "#C0C0C0",
269
+ "#ADD8E6",
270
+ "#FFFAF0",
271
+ "#f4f3f7",
272
+ "#f5efff",
273
+ "#b5d7fd",
274
+ "#ffc0cb",
275
+ "#FFC0CB",
276
+ "#e1d4c0",
277
+ "#FCDFFF",
278
+ "#F0FFFF",
279
+ "#F0F8FF",
280
+ "#F8F8FF",
281
+ "#F0FFFF",
282
+ ]