예제 #1
0
        /// <summary>
        ///     A CSStreamReader extension method that reads a tag.
        /// </summary>
        /// <param name="stream">  The stream to act on. </param>
        /// <param name="content"> The content. </param>
        /// <exception cref="CSReaderException">
        ///     Thrown when a Create struct Reader error condition
        ///     occurs.
        /// </exception>
        internal static void ReadTag(this CSStreamReader stream, string content)
        {
            while (stream.ReadChar(out char c))
            {
                switch (c)
                {
                case '[':
                {
                    stream.ReadTagInner(content);
                    return;
                }

                case '/':
                    throw new CSReaderException($"ERROR: INVALID TAG! -> invalid char '{c}'!");

                case '\n':
                case '\r':
                case '\t':
                case ' ':
                    break;

                default:
                    Console.WriteLine(
                        $"WARNING: invalid char '{c}' found near line {stream.Line} -> index {stream.Index}!");
                    break;
                }
            }
            throw new CSReaderException($"ERROR: NO TAG FOUND -> '{content}'");
        }