String.js 471 B

12345678910111213141516171819
  1. import { String as StringToken } from '../../tokenizer/index.js';
  2. import { decode, encode } from '../../utils/string.js';
  3. export const name = 'String';
  4. export const structure = {
  5. value: String
  6. };
  7. export function parse() {
  8. return {
  9. type: 'String',
  10. loc: this.getLocation(this.tokenStart, this.tokenEnd),
  11. value: decode(this.consume(StringToken))
  12. };
  13. }
  14. export function generate(node) {
  15. this.token(StringToken, encode(node.value));
  16. }