private void ScanJSXWord() { var ch = _text[_pos]; while (IdentifierHelper.IsIdentifierChar(ch, false) || ch == '-') { ch = _text[++_pos]; } this.FinishToken(TokenType.JSXName); }
protected string ScanEscapedWord() { _containsEsc = false; var astral = _ecmaVersion >= 6; var chunkStart = _pos; var first = true; var word = new StringBuilder(); while (_pos < _text.Length) { var ch = _text[_pos]; if (IdentifierHelper.IsIdentifierChar(ch, astral)) { _pos += ch <= 0xffff ? 1 : 2; } else if (ch == '\\') { _containsEsc = true; word.Append(new string(_text, chunkStart, _pos)); var escStart = _pos; if (_text[++_pos] != 'u') { this.Raise("Expecting Unicode escape sequence \\uXXXX"); } var esc = this.ScanCodePoint(); var valid = first ? IdentifierHelper.IsIdentifierStart((char)esc, astral) : IdentifierHelper.IsIdentifierChar((char)esc, astral); if (!valid) { this.Raise("Invalid Unicode escape"); } word.Append(this.CodePointToString(esc)); chunkStart = _pos; } else { break; } } return(word.Append(new string(_text, chunkStart, _pos - chunkStart)).ToString()); }