public void GetString(SdlStringVisitor visitor) { switch (this.TokenType) { default: throw new Exception($"This function only works on StringDoubleQuoted and StringBackQuoted, not {this.TokenType}"); case SdlTokenType.StringBackQuoted: visitor(this.ValueSpan); break; case SdlTokenType.StringDoubleQuoted: var pusher = new SdlStringPusher(this.ValueSpan); pusher.Visit(visitor); break; } }
public void Visit(SdlStringVisitor visitor) { if (visitor == null) { throw new ArgumentNullException(nameof(visitor)); } var start = 0; var cursor = 0; // Don't need to perform much validation here, as it should've been caught inside of SdlReader already. while (cursor < this._string.Length) { var ch = this._string[cursor]; if (ch == '\\') { visitor(this._string[start..cursor]);