Skip to content

Implement Yarn Spinner 3 Virtual Machine and Parser - #284

Draft
LittleFinix wants to merge 15 commits into
YarnSpinnerTool:mainfrom
LittleFinix:main
Draft

Implement Yarn Spinner 3 Virtual Machine and Parser#284
LittleFinix wants to merge 15 commits into
YarnSpinnerTool:mainfrom
LittleFinix:main

Conversation

@LittleFinix

Copy link
Copy Markdown

This PR kicks of the implementation of Yarn Spinner 3 based on the commits from #278 and #281. The parser and VM have been adapted to the upstream versions using the provided antlr and protobuf files.

The bulk of this PR is adapting to the new protobuf structures. Instructions are now encoded using a oneof member in the instruction message instead of using protobuf's enum type, which meshes better with rusts variant enums. Labels have been removed, instead instructions now directly refer to the destination address inside the node. The new NodeBuilder type and emit! macro simplify the updated code generator visitor.

Adapting the VM to the new instruction format was pretty straight forward.

With the addition of the detour command the VM now needs to manage a call-stack in order to deal with returns. The call-stack is implemented as a stack of VM states.

Not all features from Yarn Spinner 3 are implemented yet. Also someone with more experience in rust than me should probably look this over.

Features

  • <<detour>> & <<return>>: Call-into and return-from a node.
  • <<once>> & line conditions: Lines that are only shown once or when specific conditions are met.
  • line groups
  • saliency candidates / node groups
  • smart variables
  • enums

fwilliams42 and others added 15 commits June 2, 2026 13:33
…are now in the generated lexer, and fix the one regression found from the new dep compared to previous in get_hashable_interval.
Also regenerate generated files in `core/src/generated`.

This does not (yet) change the code generator nor the logic inside of run_instruction in the vm.
The NodeBuilder further abstracts the emitter process. It specifically allows setting the destination fields of jump and jump-like instructions, which is required for the Yarnspinner 3 system.
# Conflicts:
#	crates/compiler/src/listeners/compiler_listener.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants