viperscape / lichen

Scripting DSL with Rust interpreter
Apache License 2.0
32 stars 4 forks source link

backwards next target #6

Closed viperscape closed 7 years ago

viperscape commented 7 years ago

A convenient target for next could be Back. Right now in lichen you can only move forward in nodes; but being able to back up a node would be great.

parent
    next:now child
;

child
    next:now back
;

This might be complex if a child node continues on to another node, perhaps a stack of parent nodes could be stored for backtracking.

viperscape commented 7 years ago

Instead of an explicit back target, when the node ends it could just head back to the previous node-- perhaps at the index of the source it was called from; this would be much more like Functions in other languages.

parent
    next:now child
    # child ends, parent continues here
;

child
    # heads back to parent
;
viperscape commented 7 years ago

To do this, we'll need to track not only what nodes we're visiting, but also their source position index. That way when we visit a previously visited node, we start from index 0 but when we backtrack down the stack of nodes we can also pick up where we left off. This would mean preserving nodes recursively.

viperscape commented 7 years ago

Need to also implement a Next:restart and optional target; resetting the position index of the node.

viperscape commented 7 years ago

Since we automatically revert back to previous node, a Next:halt or clear option should be available to immediately end all evaluation

viperscape commented 7 years ago

marked complete