Urara-Blog/node_modules/.pnpm-store/v3/files/72/072430b76cd06ed71a87e6ad5cb793b00e7b3bb58c98b4af0c7a80ed73ae5e3c46f75fe6d18e2631d4cf58e4e9e7e7912864aaa6f1d634113a8151e4496893
2022-08-14 01:14:53 +08:00

49 lines
1,003 B
Text

import {
WhiteSpace,
Comment,
Semicolon
} from '../../tokenizer/index.js';
function consumeRaw(startToken) {
return this.Raw(startToken, this.consumeUntilSemicolonIncluded, true);
}
export const name = 'DeclarationList';
export const structure = {
children: [[
'Declaration'
]]
};
export function parse() {
const children = this.createList();
scan:
while (!this.eof) {
switch (this.tokenType) {
case WhiteSpace:
case Comment:
case Semicolon:
this.next();
break;
default:
children.push(this.parseWithFallback(this.Declaration, consumeRaw));
}
}
return {
type: 'DeclarationList',
loc: this.getLocationFromList(children),
children
};
}
export function generate(node) {
this.children(node, prev => {
if (prev.type === 'Declaration') {
this.token(Semicolon, ';');
}
});
}