in src/scanner.ts [531:567]
private scanIdentifier(): RawToken {
let type: Token;
const start = this.index;
// Backslash (U+005C) starts an escaped character.
const id = (this.source.charCodeAt(start) === 0x5C) ? this.getComplexIdentifier() : this.getIdentifier();
// There is no keyword or literal with only one character.
// Thus, it must be an identifier.
if (id.length === 1) {
type = Token.Identifier;
} else if (this.isKeyword(id)) {
type = Token.Keyword;
} else if (id === 'null') {
type = Token.NullLiteral;
} else if (id === 'true' || id === 'false') {
type = Token.BooleanLiteral;
} else {
type = Token.Identifier;
}
if (type !== Token.Identifier && (start + id.length !== this.index)) {
const restore = this.index;
this.index = start;
this.tolerateUnexpectedToken(Messages.InvalidEscapedReservedWord);
this.index = restore;
}
return {
type: type,
value: id,
lineNumber: this.lineNumber,
lineStart: this.lineStart,
start: start,
end: this.index
};
}