finishIdentifier method
Implementation
Token finishIdentifier() {
// If we encounter an escape sequence, remember it so we can post-process
// to unescape.
var chars = <int>[];
// backup so we can start with the first character
var validateFrom = _index;
_index = _startIndex;
while (_index < _text.length) {
var ch = _text.codeUnitAt(_index);
// If the previous character was "\" we need to escape. T
// http://www.w3.org/TR/CSS21/syndata.html#characters
// if followed by hexadecimal digits, create the appropriate character.
// otherwise, include the character in the identifier and don't treat it
// specially.
if (ch == 92 /*\*/ && _inString) {
var startHex = ++_index;
eatHexDigits(startHex + 6);
if (_index != startHex) {
// Parse the hex digits and add that character.
chars.add(int.parse('0x${_text.substring(startHex, _index)}'));
if (_index == _text.length) break;
// if we stopped the hex because of a whitespace char, skip it
ch = _text.codeUnitAt(_index);
if (_index - startHex != 6 &&
(ch == TokenChar.SPACE ||
ch == TokenChar.TAB ||
ch == TokenChar.RETURN ||
ch == TokenChar.NEWLINE)) {
_index++;
}
} else {
// not a digit, just add the next character literally
if (_index == _text.length) break;
chars.add(_text.codeUnitAt(_index++));
}
} else if (_index < validateFrom ||
(inSelectorExpression
? TokenizerHelpers.isIdentifierPartExpr(ch)
: TokenizerHelpers.isIdentifierPart(ch))) {
chars.add(ch);
_index++;
} else {
// Not an identifier or escaped character.
break;
}
}
var span = _file.span(_startIndex, _index);
var text = String.fromCharCodes(chars);
return IdentifierToken(text, getIdentifierKind(), span);
}