Exemple #1
0
        private static string ReadLettersOrDigits(SourceQueue characters)
        {
            var buffer = new StringBuilder();

            while (characters.Any() && (char.IsLetterOrDigit(characters.Peek()) || (characters.Peek() == '_')))
            {
                buffer.Append(characters.Dequeue());
            }
            return(buffer.ToString());
        }
Exemple #2
0
        private static string ReadDigits(SourceQueue characters)
        {
            var buffer           = new StringBuilder();
            int separatorsBudget = 1;

            while (characters.Any() && (char.IsDigit(characters.Peek()) || ((separatorsBudget > 0) && (characters.Peek() == '.'))))
            {
                var c = characters.Dequeue();
                buffer.Append(c);
                if (c == '.')
                {
                    separatorsBudget -= 1;
                }
            }
            return(buffer.ToString());
        }