I have a python library that builds special iterators (behavior tree) from nested function calls . Although the API has pretty good and easy syntax (due to the fact that it is python), it really can use declarative DSL.
Here is a rough sketch of what I am guessing:
DSL (using YAML):
tree: - sequence: - do_action1 - do_action2 - select: - do_action3 - sequence: - do_action4 - do_action5 - do_action6
will result in the following nested function calls:
visit( sequence( do_action1(), do_action2(), select( do_action3(), sequence( do_action4(), do_action5(), ), do_action6(), ) ) )
I'm having trouble visualizing how to do this. Since DSL should represent a tree, a simple depth intersection seems appropriate. But in order to build nested function calls, I have to somehow turn this inside out. This is probably due to something clever with an intermediate stack or some, but I cannot fully understand it. What is the correct way to perform this conversion?
source share