Ejemplo n.º 1
0
        public static string ReadQuotedString(this ParserContext ctx)
        {
            ctx.ReadSymbol(SyslogChars.DQuote);
            string result = string.Empty;
            int    curr   = ctx.Position;

            while (true)
            {
                var next    = ctx.Text.IndexOfAny(SyslogChars.QuoteOrEscape, curr);
                var segment = ctx.Text.Substring(curr, next - curr);
                result += segment;
                switch (ctx.CharAt(next))
                {
                case SyslogChars.DQuote:
                    // we are done
                    ctx.Position = next + 1;     // after dquote
                    return(result);

                case SyslogChars.Escape:
                    // it is escape symbol, add next char to result, shift to next char and continue loop
                    result += ctx.CharAt(next + 1);
                    curr    = next + 2;
                    break;
                } //switch
            }     // loop
        }