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

49 lines
1.2 KiB
Text

var TYPE = require('../../tokenizer').TYPE;
var rawMode = require('./Raw').mode;
var WHITESPACE = TYPE.WhiteSpace;
var COMMENT = TYPE.Comment;
var SEMICOLON = TYPE.Semicolon;
function consumeRaw(startToken) {
return this.Raw(startToken, rawMode.semicolonIncluded, true);
}
module.exports = {
name: 'DeclarationList',
structure: {
children: [[
'Declaration'
]]
},
parse: function() {
var children = this.createList();
scan:
while (!this.scanner.eof) {
switch (this.scanner.tokenType) {
case WHITESPACE:
case COMMENT:
case SEMICOLON:
this.scanner.next();
break;
default:
children.push(this.parseWithFallback(this.Declaration, consumeRaw));
}
}
return {
type: 'DeclarationList',
loc: this.getLocationFromList(children),
children: children
};
},
generate: function(node) {
this.children(node, function(prev) {
if (prev.type === 'Declaration') {
this.chunk(';');
}
});
}
};