Пример #1
0
        /*-----------------------------------------------------------*/
        /*--- Constructor(s) ----------------------------------------*/
        /*-----------------------------------------------------------*/

        /** Full constructor.
         * @param prod production this item uses.
         * @param pos  position of the "dot" within the item.
         */
        public lr_item_core(production prod, int pos)
        {
            production_part part;

            if (prod == null)
            {
                throw new internal_error(
                          "Attempt to create an lr_item_core with a null production");
            }

            _the_production = prod;

            if (pos < 0 || pos > _the_production.rhs_length())
            {
                throw new internal_error(
                          "Attempt to create an lr_item_core with a bad dot position");
            }

            _dot_pos = pos;

            /* compute and cache hash code now */
            _core_hash_cache = 13 * _the_production.GetHashCode() + pos;

            /* cache the symbol after the dot */
            if (_dot_pos < _the_production.rhs_length())
            {
                part = _the_production.rhs(_dot_pos);
                if (!part.is_action())
                {
                    _symbol_after_dot = ((symbol_part)part).the_symbol();
                }
            }
        }
Пример #2
0
  /*-----------------------------------------------------------*/
  /*--- Constructor(s) ----------------------------------------*/
  /*-----------------------------------------------------------*/

  /** Full constructor.
   * @param prod production this item uses.
   * @param pos  position of the "dot" within the item.
   */
  public lr_item_core(production prod, int pos)     {
      production_part part;

      if (prod == null)
	throw new internal_error(
	  "Attempt to create an lr_item_core with a null production");

      _the_production = prod;

      if (pos < 0 || pos > _the_production.rhs_length())
	throw new internal_error(
	  "Attempt to create an lr_item_core with a bad dot position");

      _dot_pos = pos;

      /* compute and cache hash code now */
      _core_hash_cache = 13*_the_production.GetHashCode() + pos;

      /* cache the symbol after the dot */
      if (_dot_pos < _the_production.rhs_length())
	{
	  part = _the_production.rhs(_dot_pos);
	  if (!part.is_action())
	    _symbol_after_dot = ((symbol_part)part).the_symbol();
	}
    } 
Пример #3
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /** Is the dot at the end of the production? */
        public bool dot_at_end()
        {
            return(_dot_pos >= _the_production.rhs_length());
        }