private void ScanMultiLineString(LineProgress p, bool isInterpolated, bool skipOnly = false) { while (!p.EndOfLine) { if (p.Char() == '"' && p.NextChar() == '"') // "" is allowed within multiline string { p.Advance(2); } else if (isInterpolated && p.Char() == '{' && p.NextChar() == '{') // escaped interpolation { p.Advance(2); } else if (isInterpolated && p.Char() == '{' && p.NextChar() != '{') // interpolation. { if (!skipOnly) { p.StartStringInterpolation(); } p.Advance(); ScanInterpolation(p, skipOnly); } else if (p.Char() == '"') // end of multi-line string { if (!skipOnly) { p.EndString(); } p.Advance(); return; } else { p.Advance(); } } if (!skipOnly) { // End of line. Emit as string, but remain in MultiLineString state p.EndString(p.State); } }
private void ScanString(LineProgress p, bool isInterpolated, bool skipOnly = false) { while (!p.EndOfLine) { if (p.Char() == '\\') // escaped character. Skip over it. { p.Advance(2); } else if (isInterpolated && p.Char() == '{' && p.NextChar() == '{') // escaped interpolation { p.Advance(2); } else if (isInterpolated && p.Char() == '{' && p.NextChar() != '{') // interpolation. { if (!skipOnly) { p.StartStringInterpolation(); } p.Advance(); ScanInterpolation(p, skipOnly); } else if (p.Char() == '"') // end of string. { if (!skipOnly) { p.EndString(); } p.Advance(); return; } else { p.Advance(); } } // End of line. String wasn't closed. Oh well. Revert to Default state. if (!skipOnly) { p.EndString(); } }