private char ScanEscapedChar()
{
int escVal = 0;
bool requireFourDigits = false;
int savedStartPos = this.startPos;
int errorStartPos = this.endPos - 1;
char ch = this.GetChar(this.endPos++);
switch (ch)
{
default:
this.startPos = errorStartPos;
this.HandleError(Error.IllegalEscape);
this.startPos = savedStartPos;
if (ch == 'X') goto case 'x';
return (char)0;
// Single char escape sequences \b etc
case 'a': return (char)7;
case 'b': return (char)8;
case 't': return (char)9;
case 'n': return (char)10;
case 'v': return (char)11;
case 'f': return (char)12;
case 'r': return (char)13;
case '"': return '"';
case '\'': return '\'';
case '\\': return '\\';
case '0':
if (this.endPos >= this.maxPos) goto default;
return (char)0;
// unicode escape sequence \uHHHH
case 'u':
requireFourDigits = true;
goto case 'x';
// hexadecimal escape sequence \xH or \xHH or \xHHH or \xHHHH
case 'x':
for (int i = 0; i < 4; i++)
{
ch = this.GetChar(this.endPos++);
escVal <<= 4;
if (Scanner.IsHexDigit(ch))
escVal |= Scanner.GetHexValue(ch);
else
{
if (i == 0 || requireFourDigits)
{
this.startPos = errorStartPos;
this.HandleError(Error.IllegalEscape);
this.startPos = savedStartPos;
}
this.endPos--;
return (char)(escVal >> 4);
}
}
return (char)escVal;
}
}