Brackets.cjs 752 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. const types = require('../../tokenizer/types.cjs');
  3. const name = 'Brackets';
  4. const structure = {
  5. children: [[]]
  6. };
  7. function parse(readSequence, recognizer) {
  8. const start = this.tokenStart;
  9. let children = null;
  10. this.eat(types.LeftSquareBracket);
  11. children = readSequence.call(this, recognizer);
  12. if (!this.eof) {
  13. this.eat(types.RightSquareBracket);
  14. }
  15. return {
  16. type: 'Brackets',
  17. loc: this.getLocation(start, this.tokenStart),
  18. children
  19. };
  20. }
  21. function generate(node) {
  22. this.token(types.Delim, '[');
  23. this.children(node);
  24. this.token(types.Delim, ']');
  25. }
  26. exports.generate = generate;
  27. exports.name = name;
  28. exports.parse = parse;
  29. exports.structure = structure;