Urara-Blog/node_modules/.pnpm-store/v3/files/da/8cb1dd27e791928ebfdb2fa698e7adb01f7bcb583beb06e3306beae3d0b45c6909addbbbbe078b929e143a26d7c17160a57afc654532096d6fea2b83d724c0
2022-08-14 01:14:53 +08:00

35 lines
685 B
Text

import {
Delim,
LeftSquareBracket,
RightSquareBracket
} from '../../tokenizer/index.js';
export const name = 'Brackets';
export const structure = {
children: [[]]
};
export function parse(readSequence, recognizer) {
const start = this.tokenStart;
let children = null;
this.eat(LeftSquareBracket);
children = readSequence.call(this, recognizer);
if (!this.eof) {
this.eat(RightSquareBracket);
}
return {
type: 'Brackets',
loc: this.getLocation(start, this.tokenStart),
children
};
}
export function generate(node) {
this.token(Delim, '[');
this.children(node);
this.token(Delim, ']');
}