/// <summary>
        /// Кумуляция (сжатие).
        /// </summary>
        /// <param name="numbers"></param>
        /// <returns></returns>
        public static NumberRangeCollection Cumulate
        (
            List <NumberText> numbers
        )
        {
            NumberRangeCollection result
                = new NumberRangeCollection();

            if (numbers.Count != 0)
            {
                numbers.Sort();

                NumberText previous = numbers[0];
                NumberText last     = previous.Copy();
                for (int i = 1; i < numbers.Count; i++)
                {
                    NumberText current = numbers[i];
                    NumberText next    = last + 1;
                    if (current != next)
                    {
                        result.Add
                        (
                            new NumberRange
                            (
                                previous,
                                last
                            )
                        );
                        previous = current.Copy();
                    }
                    last = current;
                }
                result.Add
                (
                    new NumberRange
                    (
                        previous,
                        last
                    )
                );
            }

            return(result);
        }
        /// <summary>
        /// Разбор текстового представления.
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static NumberRangeCollection Parse
        (
            string text
        )
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException("text");
            }

            AntlrInputStream   stream = new AntlrInputStream(text);
            NumberRangesLexer  lexer  = new NumberRangesLexer(stream);
            CommonTokenStream  tokens = new CommonTokenStream(lexer);
            NumberRangesParser parser = new NumberRangesParser(tokens);

            NumberRangesParser.ProgramContext tree   = parser.program();
            NumberRangeCollection             result = new NumberRangeCollection(tree);

            return(result);
        }