function* iterateCharacterSequence(nodes) {
	/** @type {Character[]} */
	let seq = [];

	for (const node of nodes) {
		switch (node.type) {
			case "Character":
				seq.push(node);
				break;

			case "CharacterClassRange":
				seq.push(node.min);
				yield seq;
				seq = [node.max];
				break;

			case "CharacterSet":
			case "CharacterClass": // [[]] nesting character class
			case "ClassStringDisjunction": // \q{...}
			case "ExpressionCharacterClass": // [A--B]
				if (seq.length > 0) {
					yield seq;
					seq = [];
				}
				break;

			// no default
		}
	}

	if (seq.length > 0) {
		yield seq;
	}
}
Iterate character sequences of a given nodes.

CharacterClassRange syntax can steal a part of character sequence,
so this function reverts CharacterClassRange syntax and restore the sequence.
@param {CharacterClassElement[]} nodes The node list to iterate character sequences.
@returns {IterableIterator<Character[]>} The list of character sequences.