AtrulePrelude.cjs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. const types = require('../../tokenizer/types.cjs');
  3. const name = 'AtrulePrelude';
  4. const walkContext = 'atrulePrelude';
  5. const structure = {
  6. children: [[]]
  7. };
  8. function parse(name) {
  9. let children = null;
  10. if (name !== null) {
  11. name = name.toLowerCase();
  12. }
  13. this.skipSC();
  14. if (hasOwnProperty.call(this.atrule, name) &&
  15. typeof this.atrule[name].prelude === 'function') {
  16. // custom consumer
  17. children = this.atrule[name].prelude.call(this);
  18. } else {
  19. // default consumer
  20. children = this.readSequence(this.scope.AtrulePrelude);
  21. }
  22. this.skipSC();
  23. if (this.eof !== true &&
  24. this.tokenType !== types.LeftCurlyBracket &&
  25. this.tokenType !== types.Semicolon) {
  26. this.error('Semicolon or block is expected');
  27. }
  28. return {
  29. type: 'AtrulePrelude',
  30. loc: this.getLocationFromList(children),
  31. children
  32. };
  33. }
  34. function generate(node) {
  35. this.children(node);
  36. }
  37. exports.generate = generate;
  38. exports.name = name;
  39. exports.parse = parse;
  40. exports.structure = structure;
  41. exports.walkContext = walkContext;