readEscapeSequence method
Implementation
int readEscapeSequence() {
final ch = _nextChar();
int hexValue;
switch (ch) {
case 110 /*n*/ :
return TokenChar.NEWLINE;
case 114 /*r*/ :
return TokenChar.RETURN;
case 102 /*f*/ :
return TokenChar.FF;
case 98 /*b*/ :
return TokenChar.BACKSPACE;
case 116 /*t*/ :
return TokenChar.TAB;
case 118 /*v*/ :
return TokenChar.FF;
case 120 /*x*/ :
hexValue = readHex(2);
break;
case 117 /*u*/ :
if (_maybeEatChar(TokenChar.LBRACE)) {
hexValue = readHex();
if (!_maybeEatChar(TokenChar.RBRACE)) {
return -1;
}
} else {
hexValue = readHex(4);
}
break;
default:
return ch;
}
if (hexValue == -1) return -1;
// According to the Unicode standard the high and low surrogate halves
// used by UTF-16 (U+D800 through U+DFFF) and values above U+10FFFF
// are not legal Unicode values.
if (hexValue < 0xD800 || hexValue > 0xDFFF && hexValue <= 0xFFFF) {
return hexValue;
} else if (hexValue <= 0x10FFFF) {
messages.error('unicode values greater than 2 bytes not implemented yet',
_file.span(_startIndex, _startIndex + 1));
return -1;
} else {
return -1;
}
}