SupportsDeclaration.js 694 B

12345678910111213141516171819202122232425262728293031323334
  1. import {
  2. LeftParenthesis,
  3. RightParenthesis
  4. } from '../../tokenizer/index.js';
  5. export const name = 'SupportsDeclaration';
  6. export const structure = {
  7. declaration: 'Declaration'
  8. };
  9. export function parse() {
  10. const start = this.tokenStart;
  11. this.eat(LeftParenthesis);
  12. this.skipSC();
  13. const declaration = this.Declaration();
  14. if (!this.eof) {
  15. this.eat(RightParenthesis);
  16. }
  17. return {
  18. type: 'SupportsDeclaration',
  19. loc: this.getLocation(start, this.tokenStart),
  20. declaration
  21. };
  22. }
  23. export function generate(node) {
  24. this.token(LeftParenthesis, '(');
  25. this.node(node.declaration);
  26. this.token(RightParenthesis, ')');
  27. }