Selector.cjs 759 B

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