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

void java_cup::production::remove_embedded_actions (  )  throws internal_error [inline, protected]

Remove all embedded actions from a production by factoring them out into individual action production using new non terminals. if the original production was:

    A ::= B {action1} C {action2} D 
then it will be factored into:
    A ::= B NT$1 C NT$2 D
    NT$1 ::= {action1}
    NT$2 ::= {action2}
where NT$1 and NT$2 are new system created non terminals.

Definition at line 548 of file production.java.

References _rhs, java_cup::non_terminal::create_new(), declare_labels(), java_cup::production_part::is_action(), java_cup::non_terminal::is_embedded_action, rhs(), and rhs_length().

Referenced by production().

      non_terminal new_nt;
      production   new_prod;
      String declare_str;
      /* walk over the production and process each action */
      for (int act_loc = 0; act_loc < rhs_length(); act_loc++)
      if (rhs(act_loc).is_action())
          declare_str = declare_labels(
                  _rhs, act_loc, "");
          /* create a new non terminal for the action production */
          new_nt = non_terminal.create_new();
          new_nt.is_embedded_action = true; /* 24-Mar-1998, CSA */

          /* create a new production with just the action */
          new_prod = new action_production(this, new_nt, null, 0, 
            declare_str + ((action_part)rhs(act_loc)).code_string());

          /* replace the action with the generated non terminal */
          _rhs[act_loc] = new symbol_part(new_nt);

Generated by  Doxygen 1.6.0   Back to index