private Token NextString()
{
StringBuilder sb = new StringBuilder();
char? nch;
char lastChar = (char)0;
nch = this.NextChar();
while ((nch.HasValue && nch.Value != StringChar) || lastChar == '\\')
{
char ch = nch.Value;
if (lastChar == '\\')
{
switch (ch)
{
case 't':
sb.Length--;
sb.Append('\t');
break;
case 'a':
sb.Length--;
sb.Append('\a');
break;
case 'b':
sb.Length--;
sb.Append('\b');
break;
case 'e':
sb.Length--;
sb.Append((char)27);
break;
case 'f':
sb.Length--;
sb.Append('\f');
break;
case 'n':
sb.Length--;
sb.Append('\n');
break;
case 'r':
sb.Length--;
sb.Append('\r');
break;
case 'v':
sb.Length--;
sb.Append('\v');
break;
case '\\':
break;
default:
sb.Length--;
sb.Append(ch);
break;
}
lastChar = (char)0;
}
else
{
sb.Append(ch);
lastChar = ch;
}
nch = this.NextChar();
}
Token token = new Token();
token.Value = sb.ToString();
token.TokenType = TokenType.String;
return token;
}