private void ScanVerbatimString(bool stopAtEndOfLine)
{
char ch;
int start = this.endPos;
this.unescapedString = null;
StringBuilder unescapedSB = null;
for (; ; )
{
ch = this.GetChar(this.endPos++);
if (ch == '"')
{
ch = this.GetChar(this.endPos);
if (ch != '"') break; //Reached the end of the string
this.endPos++;
if (unescapedSB == null) unescapedSB = new StringBuilder(128);
// start points to the first position that has not been written to the StringBuilder.
// The first time we get in here that position is the beginning of the string, after that
// it is the character immediately following the "" pair
int len = this.endPos - start;
if (len > 0) // append all the non escaped chars to the string builder
if (this.sourceString != null)
unescapedSB.Append(this.sourceString, start, len);
else
unescapedSB.Append(this.sourceText.Substring(start, len));
start = this.endPos;
}
else if (this.IsLineTerminator(ch, 1))
{
ch = this.GetChar(++this.endPos);
if (stopAtEndOfLine)
{
this.stillInsideMultiLineToken = true;
return;
}
}
else if (ch == (char)0 && this.endPos >= this.maxPos)
{
//Reached EOF
this.endPos--;
this.HandleError(Error.NewlineInConst);
break;
}
}
// update this.unescapedString using the StringBuilder
if (unescapedSB != null)
{
int len = this.endPos - start - 1;
if (len > 0)
{
// append all the non escape chars to the string builder
if (this.sourceString != null)
unescapedSB.Append(this.sourceString, start, len);
else
unescapedSB.Append(this.sourceText.Substring(start, len));
}
this.unescapedString = unescapedSB.ToString();
}
else
{
if (this.endPos <= this.startPos + 3)
this.unescapedString = "";
else
this.unescapedString = this.Substring(this.startPos + 2, this.endPos - this.startPos - 3);
}
}