Logo Search packages:      
Sourcecode: jasmin-sable version File versions  Download package

boolean java_cup::production::check_nullable (  )  throws internal_error [inline]

Check to see if the production (now) appears to be nullable. A production is nullable if its RHS could derive the empty string. This results when the RHS is empty or contains only non terminals which themselves are nullable.

Definition at line 584 of file production.java.

References java_cup::production_part::is_action(), java_cup::symbol::is_non_term(), nullable(), nullable_known(), rhs(), rhs_length(), and set_nullable().

Referenced by java_cup::non_terminal::compute_nullability().

    {
      production_part part;
      symbol          sym;
      int             pos;

      /* if we already know bail out early */
      if (nullable_known()) return nullable();

      /* if we have a zero size RHS we are directly nullable */
      if (rhs_length() == 0)
      {
        /* stash and return the result */
        return set_nullable(true);
      }

      /* otherwise we need to test all of our parts */
      for (pos=0; pos<rhs_length(); pos++)
      {
        part = rhs(pos);

        /* only look at non-actions */
        if (!part.is_action())
          {
            sym = ((symbol_part)part).the_symbol();

            /* if its a terminal we are definitely not nullable */
            if (!sym.is_non_term()) 
            return set_nullable(false);
            /* its a non-term, is it marked nullable */
            else if (!((non_terminal)sym).nullable())
            /* this one not (yet) nullable, so we aren't */
              return false;
          }
      }

      /* if we make it here all parts are nullable */
      return set_nullable(true);
    }


Generated by  Doxygen 1.6.0   Back to index