readKeyWord()

in packages/path/src/tokenizer.ts [196:236]


  readKeyWord() {
    let startPos = this.state.pos,
      string = ''
    while (true) {
      const code = this.getCode()
      const prevCode = this.getCode(this.state.pos - 1)
      if (this.input.length === this.state.pos) {
        string = slice(this.input, startPos, this.state.pos + 1)
        break
      }
      if (!isRewordCode(code) || prevCode === 92) {
        if (
          code === 32 ||
          code === 160 ||
          code === 10 ||
          code === 8232 ||
          code === 8233
        ) {
          string = slice(this.input, startPos, this.state.pos)
          break
        }
        if (code === 13 && this.input.charCodeAt(this.state.pos + 1) === 10) {
          string = slice(this.input, startPos, this.state.pos)
          break
        }
        if (
          (code > 8 && code < 14) ||
          (code >= 5760 && nonASCIIWhitespace.test(String.fromCharCode(code)))
        ) {
          string = slice(this.input, startPos, this.state.pos)
          break
        }
        this.state.pos++
      } else {
        string = slice(this.input, startPos, this.state.pos)
        break
      }
    }

    this.finishToken(nameTok, string)
  }