Urara-Blog/node_modules/.pnpm-store/v3/files/b6/cacfc2633b9b5572c283beefa94f5288481bfa296e5f14adfe3895d8585523647d3ab40c7e10c896e1fde0712b221b2265369835b36486f86ab42890f33bd4
2022-08-14 01:14:53 +08:00

43 lines
983 B
Text

import { WhiteSpace, Comment } from '../tokenizer/index.js';
export function readSequence(recognizer) {
const children = this.createList();
let space = false;
const context = {
recognizer
};
while (!this.eof) {
switch (this.tokenType) {
case Comment:
this.next();
continue;
case 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;
};