"use strict"; const { NoMatch } = require("../symbols"); module.exports = function* either(instruction, state, context) { let { options } = instruction; for (let option of options) { let result = yield option; if (result === NoMatch) { // Restore index and try again with the next option state.currentIndex = context.startIndex; continue; } else { // Don't restore index; the match has been consumed return result; } } // None of the options matched return NoMatch; };