Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static ABNF_Concatenation Parse(System.IO.StringReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            // concatenation  =  repetition *(1*c-wsp repetition)
            // repetition     =  [repeat] element

            ABNF_Concatenation retVal = new ABNF_Concatenation();

            while (true)
            {
                ABNF_Repetition item = ABNF_Repetition.Parse(reader);
                if (item != null)
                {
                    retVal.m_pItems.Add(item);
                }
                // We reached end of string.
                else if (reader.Peek() == -1)
                {
                    break;
                }
                // We have next concatenation item.
                else if (reader.Peek() == ' ')
                {
                    reader.Read();
                }
                // We have unexpected value, probably concatenation ends.
                else
                {
                    break;
                }
            }

            return(retVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static ABNF_Alternation Parse(System.IO.StringReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            // alternation = concatenation *(*c-wsp "/" *c-wsp concatenation)

            ABNF_Alternation retVal = new ABNF_Alternation();

            while (true)
            {
                ABNF_Concatenation item = ABNF_Concatenation.Parse(reader);
                if (item != null)
                {
                    retVal.m_pItems.Add(item);
                }

                // We reached end of string.
                if (reader.Peek() == -1)
                {
                    break;
                }
                // We have next alternation item.
                else if (reader.Peek() == '/')
                {
                    reader.Read();
                }
                // We have unexpected value, probably alternation ends.
                else
                {
                    break;
                }
            }

            return(retVal);
        }