You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
603 B
JavaScript
30 lines
603 B
JavaScript
"use strict";
|
|
|
|
const { NoMatch } = require("../symbols");
|
|
const coreOps = require("./index");
|
|
|
|
module.exports = function* zeroOrMore(instruction, state, context) {
|
|
let { rule } = instruction;
|
|
|
|
let matches = [];
|
|
|
|
while (true) {
|
|
let reachedEnd = yield coreOps.internalCall.endOfInput({ rule: rule }, state, context);
|
|
// yieldcore.Internal(endOfInput(instruction, state, context), "endOfInput");
|
|
|
|
if (reachedEnd === true) {
|
|
break;
|
|
} else {
|
|
let result = yield instruction.rule;
|
|
|
|
if (result === NoMatch) {
|
|
break;
|
|
} else {
|
|
matches.push(result);
|
|
}
|
|
}
|
|
}
|
|
|
|
return matches;
|
|
};
|