Selector.js 667 B

12345678910111213141516171819202122232425262728293031
  1. export const name = 'Selector';
  2. export const structure = {
  3. children: [[
  4. 'TypeSelector',
  5. 'IdSelector',
  6. 'ClassSelector',
  7. 'AttributeSelector',
  8. 'PseudoClassSelector',
  9. 'PseudoElementSelector',
  10. 'Combinator'
  11. ]]
  12. };
  13. export function parse() {
  14. const children = this.readSequence(this.scope.Selector);
  15. // nothing were consumed
  16. if (this.getFirstListNode(children) === null) {
  17. this.error('Selector is expected');
  18. }
  19. return {
  20. type: 'Selector',
  21. loc: this.getLocationFromList(children),
  22. children
  23. };
  24. }
  25. export function generate(node) {
  26. this.children(node);
  27. }