Urara-Blog/node_modules/.pnpm-store/v3/files/e3/7de6092e2b5185b584735dbb54845f92763d6620385e7c3cc3769b9bbf29a80150d45b2eecd794c96dffe9a73743453f2d4152565243ea7fb6ab33fb11dcb7
2022-08-14 01:14:53 +08:00

34 lines
818 B
Text

var TYPE = require('../../tokenizer').TYPE;
var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
var RIGHTSQUAREBRACKET = TYPE.RightSquareBracket;
module.exports = {
name: 'Brackets',
structure: {
children: [[]]
},
parse: function(readSequence, recognizer) {
var start = this.scanner.tokenStart;
var children = null;
this.eat(LEFTSQUAREBRACKET);
children = readSequence.call(this, recognizer);
if (!this.scanner.eof) {
this.eat(RIGHTSQUAREBRACKET);
}
return {
type: 'Brackets',
loc: this.getLocation(start, this.scanner.tokenStart),
children: children
};
},
generate: function(node) {
this.chunk('[');
this.children(node);
this.chunk(']');
}
};