Esempio n. 1
0
        //*
        // * Returns a string representation of a production pattern.
        // *
        // * @param prod the production pattern
        // *
        // * @return a detailed string representation of the pattern
        //

        private string ToString(ProductionPattern prod)
        {
            StringBuilder buffer = new StringBuilder();
            StringBuilder indent = new StringBuilder();
            LookAheadSet  @set   = default(LookAheadSet);
            int           i      = 0;

            buffer.Append(prod.Name);
            buffer.Append(" (");
            buffer.Append(prod.Id);
            buffer.Append(") ");
            for (i = 0; i <= buffer.Length - 1; i++)
            {
                indent.Append(" ");
            }
            buffer.Append("= ");
            indent.Append("| ");
            for (i = 0; i <= prod.Count - 1; i++)
            {
                if (i > 0)
                {
                    buffer.Append(indent);
                }
                buffer.Append(ToString(prod[i]));
                buffer.Append("" + Convert.ToChar(10) + "");
            }
            for (i = 0; i <= prod.Count - 1; i++)
            {
                @set = prod[i].LookAhead;
                if (@set.GetMaxLength() > 1)
                {
                    buffer.Append("Using ");
                    buffer.Append(@set.GetMaxLength());
                    buffer.Append(" token look-ahead for alternative ");
                    buffer.Append(i + 1);
                    buffer.Append(": ");
                    buffer.Append(@set.ToString(m_tokenizer));
                    buffer.Append("" + Convert.ToChar(10) + "");
                }
            }
            return(buffer.ToString());
        }