Example #1
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /** Convert to a string (separated out from ToString() so we can call it
         *  from subclass that overrides ToString()).
         */
        public string to_simple_string()
        {
            string          result;
            production_part part;

            if (_the_production.lhs() != null &&
                _the_production.lhs().the_symbol() != null &&
                _the_production.lhs().the_symbol().name() != null)
            {
                result = _the_production.lhs().the_symbol().name();
            }
            else
            {
                result = "$$NULL$$";
            }

            result += " ::= ";

            for (int i = 0; i < _the_production.rhs_length(); i++)
            {
                /* do we need the dot before this one? */
                if (i == _dot_pos)
                {
                    result += "(*) ";
                }

                /* print the name of the part */
                if (_the_production.rhs(i) == null)
                {
                    result += "$$NULL$$ ";
                }
                else
                {
                    part = _the_production.rhs(i);
                    if (part == null)
                    {
                        result += "$$NULL$$ ";
                    }
                    else if (part.is_action())
                    {
                        result += "{ACTION} ";
                    }
                    else if (((symbol_part)part).the_symbol() != null &&
                             ((symbol_part)part).the_symbol().name() != null)
                    {
                        result += ((symbol_part)part).the_symbol().name() + " ";
                    }
                    else
                    {
                        result += "$$NULL$$ ";
                    }
                }
            }

            /* put the dot after if needed */
            if (_dot_pos == _the_production.rhs_length())
            {
                result += "(*) ";
            }

            return(result);
        }