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

terminal_set java_cup::production::check_first_set (  )  throws internal_error [inline]

Update (and return) the first set based on current NT firsts. This assumes that nullability has already been computed for all non terminals and productions.

Definition at line 638 of file production.java.

References _first_set, java_cup::terminal_set::add(), first_set(), java_cup::production_part::is_action(), java_cup::symbol::is_non_term(), nullable(), rhs(), and rhs_length().

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

    {
      int    part;
      symbol sym;

      /* walk down the right hand side till we get past all nullables */
      for (part=0; part<rhs_length(); part++)
      {
        /* only look at non-actions */
        if (!rhs(part).is_action())
          {
            sym = ((symbol_part)rhs(part)).the_symbol();

            /* is it a non-terminal?*/
            if (sym.is_non_term())
            {
              /* add in current firsts from that NT */
              _first_set.add(((non_terminal)sym).first_set());

              /* if its not nullable, we are done */
              if (!((non_terminal)sym).nullable())
                break;
            }
            else
            {
                /* its a terminal -- add that to the set */
              _first_set.add((terminal)sym);

              /* we are done */
              break;
            }
          }
      }

      /* return our updated first set */
      return first_set();
    }


Generated by  Doxygen 1.6.0   Back to index