/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>Remove all embedded actions from a production by factoring them /// out into individual action production using new non terminals. /// if the original production was: <pre> /// A ::= B {action1} C {action2} D /// </pre> /// then it will be factored into: <pre> /// A ::= B NT$1 C NT$2 D /// NT$1 ::= {action1} /// NT$2 ::= {action2} /// </pre> /// where NT$1 and NT$2 are new system created non terminals. /// </summary> /* the declarations added to the parent production are also passed along, * as they should be perfectly valid in this code string, since it * was originally a code string in the parent, not on its own. * frank 6/20/96 */ protected internal virtual void remove_embedded_actions() { non_terminal new_nt; production new_prod; System.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); } } }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>Remove all embedded actions from a production by factoring them /// out into individual action production using new non terminals. /// if the original production was: <pre> /// A ::= B {action1} C {action2} D /// </pre> /// then it will be factored into: <pre> /// A ::= B NT$1 C NT$2 D /// NT$1 ::= {action1} /// NT$2 ::= {action2} /// </pre> /// where NT$1 and NT$2 are new system created non terminals. /// </summary> /* the declarations added to the parent production are also passed along, as they should be perfectly valid in this code string, since it was originally a code string in the parent, not on its own. frank 6/20/96 */ protected internal virtual void remove_embedded_actions() { non_terminal new_nt; production new_prod; System.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); } }