Urara-Blog/node_modules/.pnpm-store/v3/files/9e/5df6ab69c40c1596ee2561cb0d2732c361b0c875e9d9d28b14775bb5b69af0353ae0410abd4142664a44337cb7844a1ffde4163b8b1df0ba4dc850dae84bce
2022-08-14 01:14:53 +08:00

34 lines
812 B
Text

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