String.cjs 559 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const string = require('../../utils/string.cjs');
  3. const types = require('../../tokenizer/types.cjs');
  4. const name = 'String';
  5. const structure = {
  6. value: String
  7. };
  8. function parse() {
  9. return {
  10. type: 'String',
  11. loc: this.getLocation(this.tokenStart, this.tokenEnd),
  12. value: string.decode(this.consume(types.String))
  13. };
  14. }
  15. function generate(node) {
  16. this.token(types.String, string.encode(node.value));
  17. }
  18. exports.generate = generate;
  19. exports.name = name;
  20. exports.parse = parse;
  21. exports.structure = structure;