Urara-Blog/node_modules/.pnpm-store/v3/files/8e/37167cfae20fb9106e680703e644b99d563cd0f44ba14a080b5310ca33a4cabf5fc034bcbbe0ffc59864e4d49800f80a22ad7b5501bd8308432044ca77e593
2022-08-14 01:14:53 +08:00

47 lines
1 KiB
Text

'use strict';
const types = require('../tokenizer/types.cjs');
function readSequence(recognizer) {
const children = this.createList();
let space = false;
const context = {
recognizer
};
while (!this.eof) {
switch (this.tokenType) {
case types.Comment:
this.next();
continue;
case types.WhiteSpace:
space = true;
this.next();
continue;
}
let child = recognizer.getNode.call(this, context);
if (child === undefined) {
break;
}
if (space) {
if (recognizer.onWhiteSpace) {
recognizer.onWhiteSpace.call(this, child, children, context);
}
space = false;
}
children.push(child);
}
if (space && recognizer.onWhiteSpace) {
recognizer.onWhiteSpace.call(this, null, children, context);
}
return children;
}
exports.readSequence = readSequence;