private IToken MatchString()
{
//{setText(getText().substring(1, getText().length()-1));}
bool sawEscape = false;
StringBuilder buf = new StringBuilder();
buf.Append(c);
Consume();
while (c != '"')
{
if (c == '\\')
{
sawEscape = true;
Consume();
switch (c)
{
case 'n':
buf.Append('\n');
break;
case 'r':
buf.Append('\r');
break;
case 't':
buf.Append('\t');
break;
default:
buf.Append(c);
break;
}
Consume();
continue;
}
buf.Append(c);
Consume();
if (c == EOF)
{
RecognitionException re = new MismatchedTokenException((int)'"', input);
re.Line = input.Line;
re.CharPositionInLine = input.CharPositionInLine;
errMgr.LexerError(input.SourceName, "EOF in string", templateToken, re);
break;
}
}
buf.Append(c);
Consume();
if (sawEscape)
return NewToken(STRING, buf.ToString());
else
return NewToken(STRING);
}