Exemplo n.º 1
0
        /// <summary>
        /// Consume the characters of the next token and append them to the string builder.
        /// </summary>
        public void GetToken(StringBuilder bldr)
        {
            int ichDst = bldr.Length;

            // Skip spaces, comments, etc.
            SkipWhiteSpace();

            while (!_curs.Eof)
            {
                char ch = _curs.ChCur;
                switch (ch)
                {
                case '{':
                    if (bldr.Length == ichDst)
                    {
                        GatherCurlyGroup(bldr);
                    }
                    return;

                case '}':
                    if (bldr.Length == ichDst)
                    {
                        bldr.Append(ch);
                        _curs.ChNext();
                        // Naked } is an error.
                        _error = true;
                    }
                    return;

                case '=':
                    if (bldr.Length == ichDst)
                    {
                        bldr.Append(ch);
                        _curs.ChNext();
                    }
                    return;

                case '\\':
                    if (_escapes)
                    {
                        GatherSlash(bldr, true);
                        continue;
                    }
                    break;

                case '"':
                    GatherString(bldr, true);
                    continue;

                case '#':
                    // Since we skipped comments, we should only get here if we've collected something.
                    Contracts.Assert(bldr.Length > ichDst);
                    return;

                default:
                    if (char.IsWhiteSpace(ch))
                    {
                        return;
                    }
                    break;
                }

                bldr.Append(ch);
                _curs.ChNext();
            }
        }