jaclang 0.8.0__py3-none-any.whl → 0.8.2__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 (124) hide show
  1. jaclang/__init__.py +6 -0
  2. jaclang/cli/cli.py +23 -50
  3. jaclang/compiler/codeinfo.py +0 -1
  4. jaclang/compiler/jac.lark +14 -22
  5. jaclang/compiler/larkparse/jac_parser.py +2 -2
  6. jaclang/compiler/parser.py +378 -531
  7. jaclang/compiler/passes/main/__init__.py +0 -14
  8. jaclang/compiler/passes/main/annex_pass.py +2 -8
  9. jaclang/compiler/passes/main/cfg_build_pass.py +39 -13
  10. jaclang/compiler/passes/main/def_impl_match_pass.py +14 -13
  11. jaclang/compiler/passes/main/def_use_pass.py +4 -7
  12. jaclang/compiler/passes/main/import_pass.py +6 -14
  13. jaclang/compiler/passes/main/inheritance_pass.py +2 -2
  14. jaclang/compiler/passes/main/pyast_gen_pass.py +428 -799
  15. jaclang/compiler/passes/main/pyast_load_pass.py +115 -311
  16. jaclang/compiler/passes/main/pyjac_ast_link_pass.py +8 -7
  17. jaclang/compiler/passes/main/sym_tab_build_pass.py +3 -3
  18. jaclang/compiler/passes/main/sym_tab_link_pass.py +6 -9
  19. jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/action/actions.jac +1 -5
  20. jaclang/compiler/passes/main/tests/fixtures/symtab_link_tests/main.jac +1 -8
  21. jaclang/compiler/passes/main/tests/test_cfg_build_pass.py +5 -9
  22. jaclang/compiler/passes/main/tests/test_decl_impl_match_pass.py +7 -8
  23. jaclang/compiler/passes/main/tests/test_import_pass.py +5 -18
  24. jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +2 -6
  25. jaclang/compiler/passes/main/tests/test_sub_node_pass.py +1 -3
  26. jaclang/compiler/passes/main/tests/test_sym_tab_link_pass.py +20 -17
  27. jaclang/compiler/passes/tool/doc_ir_gen_pass.py +425 -216
  28. jaclang/compiler/passes/tool/jac_formatter_pass.py +2 -0
  29. jaclang/compiler/passes/tool/tests/fixtures/archetype_frmt.jac +14 -0
  30. jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/triple_quoted_string.jac +5 -4
  31. jaclang/compiler/passes/tool/tests/fixtures/import_fmt.jac +6 -0
  32. jaclang/compiler/passes/tool/tests/fixtures/simple_walk_fmt.jac +3 -3
  33. jaclang/compiler/passes/tool/tests/fixtures/tagbreak.jac +9 -0
  34. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +18 -3
  35. jaclang/compiler/passes/tool/tests/test_unparse_validate.py +2 -2
  36. jaclang/compiler/program.py +22 -66
  37. jaclang/compiler/tests/fixtures/fam.jac +2 -2
  38. jaclang/compiler/tests/fixtures/pkg_import_lib/__init__.jac +1 -0
  39. jaclang/compiler/tests/fixtures/pkg_import_lib/sub/__init__.jac +1 -0
  40. jaclang/compiler/tests/fixtures/pkg_import_lib/sub/helper.jac +3 -0
  41. jaclang/compiler/tests/fixtures/pkg_import_lib/tools.jac +3 -0
  42. jaclang/compiler/tests/fixtures/pkg_import_lib_py/__init__.py +5 -0
  43. jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/__init__.py +3 -0
  44. jaclang/compiler/tests/fixtures/pkg_import_lib_py/sub/helper.jac +3 -0
  45. jaclang/compiler/tests/fixtures/pkg_import_lib_py/tools.jac +3 -0
  46. jaclang/compiler/tests/fixtures/pkg_import_main.jac +10 -0
  47. jaclang/compiler/tests/fixtures/pkg_import_main_py.jac +11 -0
  48. jaclang/compiler/tests/test_importer.py +30 -13
  49. jaclang/compiler/tests/test_parser.py +1 -0
  50. jaclang/compiler/unitree.py +488 -320
  51. jaclang/langserve/__init__.jac +1 -0
  52. jaclang/langserve/engine.jac +503 -0
  53. jaclang/langserve/sem_manager.jac +309 -0
  54. jaclang/langserve/server.jac +201 -0
  55. jaclang/langserve/tests/server_test/test_lang_serve.py +139 -48
  56. jaclang/langserve/tests/server_test/utils.py +35 -6
  57. jaclang/langserve/tests/session.jac +294 -0
  58. jaclang/langserve/tests/test_sem_tokens.py +2 -2
  59. jaclang/langserve/tests/test_server.py +8 -7
  60. jaclang/langserve/utils.jac +51 -30
  61. jaclang/runtimelib/archetype.py +128 -6
  62. jaclang/runtimelib/builtin.py +17 -14
  63. jaclang/runtimelib/importer.py +51 -76
  64. jaclang/runtimelib/machine.py +469 -305
  65. jaclang/runtimelib/meta_importer.py +86 -0
  66. jaclang/runtimelib/tests/fixtures/graph_purger.jac +24 -26
  67. jaclang/runtimelib/tests/fixtures/other_root_access.jac +25 -16
  68. jaclang/runtimelib/tests/fixtures/traversing_save.jac +7 -5
  69. jaclang/runtimelib/tests/test_jaseci.py +3 -1
  70. jaclang/runtimelib/utils.py +3 -3
  71. jaclang/tests/fixtures/arch_rel_import_creation.jac +23 -23
  72. jaclang/tests/fixtures/async_ability.jac +43 -10
  73. jaclang/tests/fixtures/async_function.jac +18 -0
  74. jaclang/tests/fixtures/async_walker.jac +17 -12
  75. jaclang/tests/fixtures/backward_edge_visit.jac +31 -0
  76. jaclang/tests/fixtures/builtin_printgraph.jac +85 -0
  77. jaclang/tests/fixtures/builtin_printgraph_json.jac +21 -0
  78. jaclang/tests/fixtures/builtin_printgraph_mermaid.jac +16 -0
  79. jaclang/tests/fixtures/chandra_bugs2.jac +20 -13
  80. jaclang/tests/fixtures/concurrency.jac +1 -1
  81. jaclang/tests/fixtures/create_dynamic_archetype.jac +25 -28
  82. jaclang/tests/fixtures/deep/deeper/deep_outer_import.jac +7 -4
  83. jaclang/tests/fixtures/deep/deeper/snd_lev.jac +2 -2
  84. jaclang/tests/fixtures/deep/deeper/snd_lev_dup.jac +6 -0
  85. jaclang/tests/fixtures/deep/one_lev.jac +2 -2
  86. jaclang/tests/fixtures/deep/one_lev_dup.jac +4 -3
  87. jaclang/tests/fixtures/dynamic_archetype.jac +19 -12
  88. jaclang/tests/fixtures/edge_ability.jac +49 -0
  89. jaclang/tests/fixtures/foo.jac +14 -22
  90. jaclang/tests/fixtures/guess_game.jac +1 -1
  91. jaclang/tests/fixtures/here_usage_error.jac +21 -0
  92. jaclang/tests/fixtures/here_visitor_usage.jac +21 -0
  93. jaclang/tests/fixtures/jac_from_py.py +1 -1
  94. jaclang/tests/fixtures/jp_importer.jac +6 -6
  95. jaclang/tests/fixtures/jp_importer_auto.jac +5 -3
  96. jaclang/tests/fixtures/node_del.jac +30 -36
  97. jaclang/tests/fixtures/unicode_strings.jac +24 -0
  98. jaclang/tests/fixtures/visit_traversal.jac +47 -0
  99. jaclang/tests/fixtures/walker_update.jac +5 -7
  100. jaclang/tests/test_cli.py +12 -7
  101. jaclang/tests/test_language.py +218 -145
  102. jaclang/tests/test_reference.py +9 -4
  103. jaclang/tests/test_typecheck.py +13 -26
  104. jaclang/utils/helpers.py +14 -6
  105. jaclang/utils/lang_tools.py +9 -8
  106. jaclang/utils/module_resolver.py +23 -0
  107. jaclang/utils/tests/test_lang_tools.py +2 -1
  108. jaclang/utils/treeprinter.py +3 -4
  109. {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/METADATA +4 -3
  110. {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/RECORD +112 -94
  111. {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/WHEEL +1 -1
  112. jaclang/compiler/passes/main/tests/fixtures/main_err.jac +0 -6
  113. jaclang/compiler/passes/main/tests/fixtures/second_err.jac +0 -4
  114. jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +0 -644
  115. jaclang/compiler/passes/tool/tests/test_doc_ir_gen_pass.py +0 -29
  116. jaclang/langserve/__init__.py +0 -1
  117. jaclang/langserve/engine.py +0 -553
  118. jaclang/langserve/sem_manager.py +0 -383
  119. jaclang/langserve/server.py +0 -167
  120. jaclang/langserve/tests/session.py +0 -255
  121. jaclang/tests/fixtures/builtin_dotgen.jac +0 -42
  122. jaclang/tests/fixtures/builtin_dotgen_json.jac +0 -21
  123. jaclang/tests/fixtures/deep/deeper/__init__.jac +0 -1
  124. {jaclang-0.8.0.dist-info → jaclang-0.8.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,21 @@
1
+ import json;
2
+
3
+
4
+ node N {
5
+ has val: int;
6
+ }
7
+
8
+
9
+ edge E {
10
+ has val: int = 0;
11
+ }
12
+
13
+
14
+ with entry {
15
+ end = root;
16
+ for i in range(0, 2) {
17
+ end +>: E : val=i :+> (end := [ N(val=i) for i in range(0, 2) ]);
18
+ }
19
+ data = printgraph(node=root, format="json");
20
+ print(data);
21
+ }
@@ -0,0 +1,16 @@
1
+ node N {
2
+ has val: int;
3
+ }
4
+
5
+ edge E {
6
+ has val: int = 0;
7
+ }
8
+
9
+ with entry {
10
+ end = root;
11
+ for i in range(0, 2) {
12
+ end +>: E : val=i :+> (end := [ N(val=i) for i in range(0, 2) ]);
13
+ }
14
+ data = printgraph(node=root, format="mermaid");
15
+ print(data);
16
+ }
@@ -1,27 +1,34 @@
1
1
  import re;
2
2
 
3
- glob a: int = 5;
3
+
4
+ glob a : int = 5;
5
+
4
6
 
5
7
  with entry {
6
- arguments = {x: None for x in re.findall(
7
- r'\{([A-Za-z0-9_]+)\}',
8
- "Apple {apple} pineapple {pineapple}"
9
- )};
10
- a: int = 5;
8
+ arguments = { x : None for x in re.findall(r'\{([A-Za-z0-9_]+)\}', "Apple {apple} pineapple {pineapple}") };
9
+ a : int = 5;
11
10
  if False {
12
- with open(f"Apple{apple}.txt") as f { # Fix syntax highlighting
13
-
14
- print(f.read());
11
+ with open(f"Apple{apple}.txt") as f {
12
+ # Fix syntax highlighting
13
+ print(
14
+ f.read()
15
+ );
15
16
  }
16
17
  }
17
18
  print(arguments);
18
- print("""This is a long
19
- line of code.""");
19
+ print(
20
+ """This is a long
21
+ line of code."""
22
+ );
20
23
  }
21
24
 
25
+
22
26
  with entry {
23
- a = {"a": "apple", "b": "ball", "c": "cat"};
24
- y = {**a, "d": "dog", "e": "elephant"};
27
+ a = {"a" : "apple" , "b" : "ball" , "c" : "cat" };
28
+ y = {** a , "d" : "dog" , "e" : "elephant" };
25
29
  print(y);
26
30
  }
31
+
32
+
27
33
  # Use before def error would be nice
34
+
@@ -6,7 +6,7 @@ node A {
6
6
  can do with entry {
7
7
  print("Started");
8
8
  sleep(2);
9
- print(here);
9
+ print(visitor);
10
10
 
11
11
  }
12
12
  }
@@ -1,35 +1,32 @@
1
- import from jaclang.runtimelib.machine { JacMachineInterface, JacMachine }
1
+ import from jaclang.runtimelib.machine { JacMachine }
2
2
  # Dynamically create a node archetype
3
- glob source_code = """
4
- node dynamic_node {
5
- has value:int;
6
- can print_value with entry {
7
- print("Dynamic Node Value:", f'{self.value}');
8
- }
9
- }
10
- """;
3
+ glob source_code =
4
+ """
5
+ node dynamic_node {
6
+ has value:int;
7
+ can print_value with entry {
8
+ print("Dynamic Node Value:", f'{self.value}');
9
+ }
10
+ }
11
+ """;
11
12
 
12
13
  # Create a new walker archetype dynamically
13
- glob walker_code = """
14
- walker dynamic_walker {
15
- can visit_nodes with entry {
16
- visit [-->];
17
- }
18
- }
19
- """;
14
+ glob walker_code =
15
+ """
16
+ walker dynamic_walker {
17
+ can visit_nodes with entry {
18
+ visit [-->];
19
+ }
20
+ }
21
+ """;
20
22
 
21
- with entry {
22
- node_arch = JacMachineInterface.create_archetype_from_source(JacMachineInterface.py_get_jac_machine(), source_code);
23
- walker_arch = JacMachineInterface.create_archetype_from_source(JacMachineInterface.py_get_jac_machine(), walker_code);
24
23
 
25
- node_obj = JacMachineInterface.spawn_node(JacMachineInterface.py_get_jac_machine(),
26
- 'dynamic_node',
27
- {'value': 99},
28
- node_arch.__name__
29
- );
30
- walker_obj = JacMachineInterface.spawn_walker(JacMachineInterface.py_get_jac_machine(),
31
- 'dynamic_walker',
32
- module_name=walker_arch.__name__
33
- );
24
+ with entry {
25
+ node_arch = JacMachine.create_archetype_from_source(source_code);
26
+ walker_arch = JacMachine.create_archetype_from_source(walker_code);
27
+ node_obj =
28
+ JacMachine.spawn_node('dynamic_node', {'value' : 99 } , node_arch.__name__);
29
+ walker_obj =
30
+ JacMachine.spawn_walker('dynamic_walker', module_name=walker_arch.__name__);
34
31
  node_obj spawn walker_obj;
35
32
  }
@@ -1,8 +1,11 @@
1
- import from ..one_lev_dup { olprint }
2
- import from ...needs_import_dup { my_print, pyfunc }
1
+ import from jaclang.tests.fixtures.deep.one_lev_dup { olprint }
2
+ import from jaclang.tests.fixtures.needs_import_dup { my_print , pyfunc }
3
+
3
4
 
4
5
  with entry {
5
6
  # print(olpyprint());
6
- print(olprint());
7
+ print(
8
+ olprint()
9
+ );
7
10
  print(my_print(pyfunc));
8
- }
11
+ }
@@ -1,6 +1,6 @@
1
1
  import from ..mycode { code }
2
2
 
3
- def slprint ->str {
3
+
4
+ def slprint-> str {
4
5
  return "sl" + code();
5
6
  }
6
-
@@ -0,0 +1,6 @@
1
+ import from jaclang.tests.fixtures.deep.mycode { code }
2
+
3
+
4
+ def slprint-> str {
5
+ return "sl" + code();
6
+ }
@@ -1,7 +1,7 @@
1
1
  import from .deeper { snd_lev }
2
2
 
3
3
 
4
- def olprint -> str {
4
+ def olprint-> str {
5
5
  # deeper.snd_lev.slprint(); FIXME:
6
- return "one level deeper" + snd_lev.slprint();
6
+ return "one level deeper" + snd_lev.slprint();
7
7
  }
@@ -1,5 +1,6 @@
1
- import from .deeper { snd_lev }
1
+ import from .deeper { snd_lev_dup }
2
2
 
3
- def olprint -> str {
4
- return "one level deeper" + snd_lev.slprint();
3
+
4
+ def olprint-> str {
5
+ return "one level deeper" + snd_lev_dup.slprint();
5
6
  }
@@ -1,30 +1,37 @@
1
- import from jaclang.runtimelib.machine {JacMachineInterface, JacMachine}
2
- import from bar {Item}
1
+ import from jaclang.runtimelib.machine { JacMachine }
2
+ import from bar { Item }
3
+
3
4
 
4
5
  node test_node {
5
- has value:int;
6
+ has value: int;
6
7
  }
7
8
 
9
+
8
10
  walker test_walker {
9
11
  can visit_nodes with `root entry {
10
12
  visit [-->];
11
13
  }
12
-
14
+
13
15
  can print_value with test_node | Item entry {
14
16
  print("Value:", f'{here.value}');
15
17
  }
16
18
  }
17
19
 
18
- walker child_walker(test_walker) {}
20
+
21
+ walker child_walker ( test_walker ) {}
22
+
19
23
 
20
24
  with entry {
21
- for value in range(1, 4) {
22
- root ++> test_node(value=value);
23
- root ++> Item(value=value);
24
- }
25
- node_obj = JacMachineInterface.spawn_node(JacMachineInterface.py_get_jac_machine(), node_name='test_node', attributes={'value': 0}, module_name='__main__');
26
- walker_obj = JacMachineInterface.spawn_walker(JacMachineInterface.py_get_jac_machine(), walker_name='child_walker', module_name='__main__');
27
- external_node = JacMachineInterface.spawn_node(JacMachineInterface.py_get_jac_machine(), node_name='Item', attributes={'value': 0}, module_name='bar');
25
+ for value in range(1, 4) { root ++> test_node(value=value); root ++> Item(value=value); }
26
+ node_obj = JacMachine.spawn_node(
27
+ node_name='test_node', attributes={'value' : 0 }, module_name='__main__'
28
+ );
29
+ walker_obj = JacMachine.spawn_walker(
30
+ walker_name='child_walker', module_name='__main__'
31
+ );
32
+ external_node = JacMachine.spawn_node(
33
+ node_name='Item', attributes={'value' : 0 }, module_name='bar'
34
+ );
28
35
  root ++> external_node;
29
36
  root ++> node_obj;
30
37
  print("Spawned Node:", node_obj);
@@ -0,0 +1,49 @@
1
+ node MyNode {
2
+ has val:int;
3
+
4
+ can ability1 with MyWalker entry {
5
+ print("MyWalker from node",visitor);
6
+ }
7
+
8
+ can ability2 with MyWalker exit {
9
+ print("MyWalker from node",visitor);
10
+ }
11
+ }
12
+
13
+ edge MyEdge {
14
+ has path:int;
15
+
16
+ can ability3 with MyWalker entry {
17
+ print("MyWalker from edge",visitor);
18
+ }
19
+
20
+ can ability4 with MyWalker exit {
21
+ print("MyWalker from edge",visitor);
22
+ }
23
+ }
24
+
25
+ walker MyWalker {
26
+ can ability5 with MyEdge entry {
27
+ print("MyEdge from walker",here);
28
+ }
29
+
30
+ can ability6 with MyEdge exit {
31
+ print("MyEdge from walker",here);
32
+ }
33
+
34
+ can ability7 with MyNode entry {
35
+ print("MyNode from walker",here);
36
+ visit [edge -->];
37
+ }
38
+
39
+ can ability8 with MyNode exit {
40
+ print("MyNode from walker",here);
41
+ visit [edge -->];
42
+ }
43
+ }
44
+
45
+ with entry {
46
+ e1 = MyEdge(1);
47
+ root +>:e1:+> MyNode(10) +>:MyEdge(2):+> MyNode(20);
48
+ MyWalker() spawn e1;
49
+ }
@@ -1,42 +1,34 @@
1
- import from jaclang.runtimelib.machine { JacMachineInterface, JacMachine }
2
- import from bar { bar_walk }
1
+ import from jaclang.runtimelib.machine { JacMachine }
2
+ import from bar { bar_walk }
3
3
  # Test runner to initialize the walker
4
-
5
- def test_run {
4
+ def test_run {
6
5
  # Print the loaded modules
7
- modules = JacMachineInterface.list_modules(JacMachineInterface.py_get_jac_machine());
6
+ modules = JacMachine.list_modules();
8
7
  "Loaded Modules:" |> print;
9
- for mod_name in modules {
10
- f"Module: {mod_name}" |> print;
11
- }
8
+ for mod_name in modules { f"Module: {mod_name}" |> print; }
12
9
  # Print walkers
13
- walkers = JacMachineInterface.list_walkers(JacMachineInterface.py_get_jac_machine(), mod_name);
10
+ walkers = JacMachine.list_walkers(mod_name);
14
11
  if walkers {
15
12
  f"Walkers in {mod_name}:" |> print;
16
- for walker in walkers {
17
- f" - Walker: {walker}" |> print;
18
- }
13
+ for walker in walkers { f" - Walker: {walker}" |> print; }
19
14
  }
20
15
  # Print nodes
21
- nodes = JacMachineInterface.list_nodes(JacMachineInterface.py_get_jac_machine(), mod_name);
16
+ nodes = JacMachine.list_nodes(mod_name);
22
17
  if nodes {
23
18
  f"Nodes in {mod_name}:" |> print;
24
- for node in nodes {
25
- f" - Node: {node}" |> print;
26
- }
19
+ for node in nodes { f" - Node: {node}" |> print; }
27
20
  }
28
21
  # Print edges
29
- edges = JacMachineInterface.list_edges(JacMachineInterface.py_get_jac_machine(), mod_name);
22
+ edges = JacMachine.list_edges(mod_name);
30
23
  if edges {
31
24
  f"Edges in {mod_name}:" |> print;
32
- for edge in edges {
33
- f" - Edge: {edge}" |> print;
34
- }
25
+ for edge in edges { f" - Edge: {edge}" |> print; }
35
26
  }
36
27
  root spawn bar_walk();
37
28
  }
38
- # Define the entry point to run the test
39
29
 
40
- with entry {
30
+
31
+ # Define the entry point to run the test
32
+ with entry {
41
33
  test_run();
42
34
  }
@@ -17,7 +17,7 @@ node turn {
17
17
 
18
18
  impl turn.check {
19
19
  guess = guesses.pop(0);
20
- guess |> here.process_guess;
20
+ guess |> visitor.process_guess;
21
21
  visit [-->];
22
22
  }
23
23
 
@@ -0,0 +1,21 @@
1
+ node MyNode{
2
+ has val:int;
3
+
4
+ can ability1 with MyWalker entry {
5
+ print("Visitor name is ",here.name);
6
+ }
7
+ }
8
+
9
+ walker MyWalker{
10
+ has name:str;
11
+
12
+ can ability2 with MyNode entry {
13
+ print("Here value is ",here.val);
14
+ }
15
+ }
16
+
17
+ with entry {
18
+ Node1 = MyNode(10);
19
+ Walker1 = MyWalker("Walker 1");
20
+ Walker1 spawn Node1;
21
+ }
@@ -0,0 +1,21 @@
1
+ node MyNode{
2
+ has val:int;
3
+
4
+ can ability1 with MyWalker entry {
5
+ print("Visitor name is ",visitor.name);
6
+ }
7
+ }
8
+
9
+ walker MyWalker{
10
+ has name:str;
11
+
12
+ can ability2 with MyNode entry {
13
+ print("Here value is ",here.val);
14
+ }
15
+ }
16
+
17
+ with entry {
18
+ Node1 = MyNode(10);
19
+ Walker1 = MyWalker("Walker 1");
20
+ Walker1 spawn Node1;
21
+ }
@@ -1,4 +1,4 @@
1
1
  from jaclang import JacMachine as Jac
2
2
 
3
- (mod,) = Jac.py_jac_import(target=".simple_walk", base_path=__file__)
3
+ (mod,) = Jac.jac_import(target=".simple_walk", base_path=__file__)
4
4
  mod.test_run()
@@ -1,16 +1,16 @@
1
- import from math { sin as s, cos, sqrt as sq }
1
+ import from math { sin as s , cos , sqrt as sq }
2
2
  include random;
3
- import from ..test_cli { JacCliTests as Jac }
3
+ import from jaclang.tests.test_cli { JacCliTests as Jac }
4
4
  import from deep.mycode { code as c }
5
- import hashcheck as h, assign_compr as a;
5
+ import hashcheck as h , assign_compr as a;
6
6
  import ignore;
7
7
  import from jacsamp { my_print as m }
8
8
 
9
9
 
10
- with entry{
11
- print(sq(4), s(30),cos(30));
10
+ with entry {
11
+ print(sq(4), s(30), cos(30));
12
12
  print(randint(1, 10));
13
13
  print(m("--->my_print<---"));
14
14
  print(h.a, a.mvar);
15
15
  print(c());
16
- }
16
+ }
@@ -1,14 +1,16 @@
1
- import from math { sin as s, cos, sqrt as sq }
1
+ import from math { sin as s , cos , sqrt as sq }
2
2
  include random;
3
- import from ..test_cli { JacCliTests as Jac }
3
+ import from jaclang.tests.test_cli { JacCliTests as Jac }
4
4
  import from deep.mycode { code as c }
5
- import hashcheck as h, assign_compr as a;
5
+ import hashcheck as h , assign_compr as a;
6
6
  import from jacsamp { my_print as m }
7
7
 
8
+
8
9
  with entry {
9
10
  print(sq(4), s(30), cos(30));
10
11
  print(randint(1, 10));
11
12
  print(m("--->my_print<---"));
12
13
  print(h.a, a.mvar);
13
14
  print(c());
15
+ print(Jac);
14
16
  }
@@ -2,48 +2,44 @@ node person {
2
2
  has age: int;
3
3
  }
4
4
 
5
- with entry {
6
- p1 = person(10); p5 = person(50);
7
- p2 = person(20); p6 = person(60);
8
- p3 = person(30); p7 = person(70);
9
- p4 = person(40); p8 = person(80);
10
5
 
11
- root ++> p1++> p2++> p3++> p4;
12
- root ++> p5++> p6++> p7++> p8;
6
+ with entry {
7
+ p1 = person(10);
8
+ p5 = person(50);
9
+ p2 = person(20);
10
+ p6 = person(60);
11
+ p3 = person(30);
12
+ p7 = person(70);
13
+ p4 = person(40);
14
+ p8 = person(80);
15
+ root ++> p1 ++> p2 ++> p3 ++> p4;
16
+ root ++> p5 ++> p6 ++> p7 ++> p8;
13
17
  p4 ++> p8;
14
-
15
18
  # # before deletion
16
- a = dotgen(root);
17
- assert a.count('label=""]') == 9;
18
- assert a.count('[label="person(') == 8;
19
-
19
+ a = printgraph(root);
20
+ assert a.count('label=""]') == 9 ;
21
+ assert a.count('[label="person(') == 8 ;
20
22
  # # delete p2
21
- del p2;
22
- b = dotgen(root);
23
- assert b.count('label="person') == 7;
24
- assert 'age=20' not in b;
25
-
23
+ del p2 ;
24
+ b = printgraph(root);
25
+ assert b.count('label="person') == 7 ;
26
+ assert 'age=20' not in b ;
26
27
  # doublecheck p3 also doesnot attach to it
27
- c = dotgen(p3);
28
- assert c.count('label="person') == 7;
29
- assert 'age=20' not in c;
30
-
31
-
28
+ c = printgraph(p3);
29
+ assert c.count('label="person') == 7 ;
30
+ assert 'age=20' not in c ;
32
31
  # # del multiple nodes
33
- del [p1, p4];
34
- d = dotgen(root);
35
- assert d.count('label="person') == 4;
36
- for i in [10, 20, 30, 40 ]{
37
- assert f'age={i}' not in d;
32
+ del [p1, p4] ;
33
+ d = printgraph(root);
34
+ assert d.count('label="person') == 4 ;
35
+ for i in [10, 20, 30, 40] {
36
+ assert f'age={i}' not in d ;
38
37
  }
39
-
40
-
41
- apple_list = [1, 2, 3, 4, 5,6,7,8,9,10];
42
- del apple_list[0];
38
+ apple_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
39
+ del apple_list[0] ;
43
40
  print('apple list after delete 0 :', apple_list);
44
- del [apple_list[6], apple_list[7]];
41
+ del [apple_list[6], apple_list[7]] ;
45
42
  print('apple list after delete 7, 8 :', apple_list);
46
-
47
43
  obj Inner {
48
44
  has c: list;
49
45
  has d: int;
@@ -52,9 +48,7 @@ with entry {
52
48
  has b: Inner;
53
49
  }
54
50
  a = Outer(b=Inner(c=[1, 2, 3], d=4));
55
-
56
51
  print('a.b before delete :', a.b);
57
- del a.b.c[1];
52
+ del a.b.c[1] ;
58
53
  print('a.b after delete :', a.b);
59
-
60
54
  }
@@ -0,0 +1,24 @@
1
+ with entry {
2
+ # unicode characters
3
+ items = [{"title":"1st", "due":True, "completed":True}, {"title":"2nd", "due":False, "completed":False}];
4
+ for (i, item) in enumerate(items) {
5
+ status = "✓" if item["completed"] else "○";
6
+ due = f" (due: {item['due']})" if item["due"] else "";
7
+ print(f"{i+1}. {status} {item['title']}{due}");
8
+ }
9
+
10
+ # unicode emojis and symbols
11
+ print("🌟 Star");
12
+
13
+ # unicode in triple quoted strings
14
+ multiline = """Multi-line with ✓ unicode and ○ symbols""";
15
+ print(multiline);
16
+
17
+ # unicode in raw strings
18
+ raw_unicode = r"Raw string with ✓ and ○";
19
+ print(raw_unicode);
20
+
21
+ # mixed unicode and escape sequences
22
+ mixed = "Tab ✓\nNewline ○";
23
+ print(mixed);
24
+ }
@@ -0,0 +1,47 @@
1
+ node MyNode {
2
+ has val:int;
3
+
4
+ can do with MyWalker entry {
5
+ print( visitor,"from node", self);
6
+ }
7
+ }
8
+
9
+ edge MyEdge {
10
+ has path:int;
11
+
12
+ can do with MyWalker entry {
13
+ print(visitor,"from edge",self);
14
+ }
15
+ }
16
+
17
+ walker MyWalker {
18
+ can does with MyNode entry {
19
+ if here.val == 20{
20
+ visit :0:[-->];
21
+ }
22
+ elif here.val == 30 {
23
+ visit :-1:[-->];
24
+ }
25
+ elif here.val == 40 {
26
+ visit :-8:[-->]; # test out of index
27
+ }
28
+ else {
29
+ visit [-->];
30
+ }
31
+
32
+ }
33
+ }
34
+
35
+ with entry {
36
+ n0 = MyNode(0);
37
+ n1 = MyNode(10);
38
+ n2 = MyNode(20);
39
+ n3 = MyNode(30);
40
+ n4 = MyNode(40);
41
+ root ++> n0 ++> n1;
42
+ n1 ++> [n2, n3, n4, MyNode(45)];
43
+ n2 ++> [MyNode(50), MyNode(60)];
44
+ n3 ++> MyNode(70);
45
+ n4 ++> MyNode(90);
46
+ MyWalker() spawn n0;
47
+ }
@@ -1,13 +1,11 @@
1
- import from bar { bar_walk }
2
- import from jaclang.runtimelib.machine { JacMachineInterface, JacMachine }
1
+ import from bar { bar_walk }
2
+ import from jaclang.runtimelib.machine { JacMachine }
3
3
  import os;
4
4
 
5
+
5
6
  def update_bar_walker {
6
7
  "Updating bar.jac with new behavior." |> print;
7
- (bar_walk_new, ) = JacMachineInterface.update_walker(JacMachineInterface.py_get_jac_machine(),
8
- "bar",
9
- items={'bar_walk': None}
10
- );
8
+ (bar_walk_new,) = JacMachine.update_walker("bar", items={'bar_walk' : None });
11
9
  "Running bar_walk after update..." |> print;
12
10
  root spawn bar_walk_new();
13
11
  print(f"bar_walk: {bar_walk_new.__dict__}");
@@ -16,4 +14,4 @@ def update_bar_walker {
16
14
 
17
15
  with entry {
18
16
  update_bar_walker();
19
- }
17
+ }