"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function tokenize(source, regexps) {
    var tokens = [];
    var chunk = source;
    var total = chunk.length;
    var iterations = 0;
    while (chunk.length > 0) {
        for (var i = 0; i < regexps.length; i++) {
            var regexp = regexps[i];
            var match = regexp.re.exec(chunk);
            if (match) {
                var value = match[0];
                tokens.push({ value: value, type: regexp.type });
                chunk = chunk.slice(match[0].length, chunk.length);
                break;
            }
        }
        if (iterations++ > total) {
            throw new Error('Unable to tokenize expression');
        }
    }
    return tokens;
}
exports.default = tokenize;
//# sourceMappingURL=tokenize.js.map