-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12a6aea
commit 003972d
Showing
2 changed files
with
24 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
import:py from jaclang.runtimelib.machine {JacMachine} | ||
import:jac from bar {Item} | ||
|
||
node test_node { | ||
has value:int; | ||
} | ||
|
||
walker test_walker { | ||
can visit_nodes with `root entry { | ||
visit [-->](`?test_node); | ||
visit [-->]; | ||
} | ||
} | ||
|
||
walker child_walker :test_walker: {} | ||
|
||
node test_node { | ||
has value:int; | ||
|
||
can print_value with test_walker entry { | ||
print("Value:", f'{self.value}'); | ||
can print_value with test_node | Item entry { | ||
print("Value:", f'{here.value}'); | ||
} | ||
} | ||
|
||
walker child_walker :test_walker: {} | ||
|
||
with entry { | ||
for value in range(1, 4) { | ||
root ++> test_node(value=value); | ||
root ++> Item(value=value); | ||
} | ||
node_obj = JacMachine.get().spawn_node('test_node', {'value': 0}); | ||
walker_obj = JacMachine.get().spawn_walker('child_walker'); | ||
node_obj = JacMachine.get().spawn_node(node_name='test_node', attributes={'value': 0}, module_name='__main__'); | ||
walker_obj = JacMachine.get().spawn_walker(walker_name='child_walker', module_name='__main__'); | ||
external_node = JacMachine.get().spawn_node(node_name='Item', attributes={'value': 0}, module_name='bar'); | ||
root ++> external_node; | ||
root ++> node_obj; | ||
print("Spawned Node:", node_obj); | ||
print("Spawned Walker:", walker_obj); | ||
print("Spawned External node:", external_node); | ||
root spawn walker_obj; | ||
} |