"use strict"; const { NotEnoughInput, NoMatch } = require("../symbols"); module.exports = function* characterRange(instruction, state) { let { start, end } = instruction; // FIXME: Unicode only! Need to check if we can assume that strings are always unicode, even when the source data was interpreted as another string encoding let codepoint = state.currentInput.codePointAt(state.currentIndex); // FIXME: Find a way to do this generically without breaking the EndOfInput operation if (state.currentIndex === state.currentInput.length) { return NotEnoughInput; } else if (codepoint >= start && codepoint <= end) { // TODO: Should we return the codepoint in string form here? That will be unnecessary work in most cases where `wholeMatch` will be used state.currentIndex += 1; return; } else { return NoMatch; } };