/** helper routine to clone a new production part adding a given label */ protected production_part add_lab(production_part part, String lab) throws internal_error { /* if there is no label, or this is an action, just return the original */ if (lab == null || part.is_action()) return part; /* otherwise build a new one with the given label attached */ return new symbol_part(((symbol_part)part).the_symbol(),lab); }
/** Generic equality comparison. */ public boolean equals(Object other) { if (!(other instanceof symbol_part)) return false; else return equals((symbol_part)other); }
if (part.label() != null) make_declaration(part.label(), part.the_symbol().stack_type(), rhs_len-pos-1);
/** Produce a hash code. */ public int hashCode() { return super.hashCode() ^ (the_symbol()==null ? 0 : the_symbol().hashCode()); }
/** 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. */ protected void remove_embedded_actions() throws internal_error { non_terminal new_nt; production new_prod; /* 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()) { /* create a new non terminal for the action production */ new_nt = non_terminal.create_new(); /* create a new production with just the action */ new_prod = new action_production(this, new_nt, null, 0, ((action_part)rhs(act_loc)).code_string()); /* replace the action with the generated non terminal */ _rhs[act_loc] = new symbol_part(new_nt); } }
/** Convert to a string. */ public String toString() { String result; /* catch any internal errors */ try { result = "production [" + index() + "]: "; result += ((lhs() != null) ? lhs().toString() : "$$NULL-LHS$$"); result += " :: = "; for (int i = 0; i<rhs_length(); i++) result += rhs(i) + " "; result += ";"; if (action() != null && action().code_string() != null) result += " {" + action().code_string() + "}"; if (nullable_known()) if (nullable()) result += "[NULLABLE]"; else result += "[NOT NULLABLE]"; } catch (internal_error e) { /* crash on internal error since we can't throw it from here (because superclass does not throw anything. */ e.crash(); result = null; } return result; }
/** Equality comparison. */ public boolean equals(symbol_part other) { return other != null && super.equals(other) && the_symbol().equals(other.the_symbol()); }
symbols.put((/*non_term_id*/(java_cup.runtime.str_token)CUP$stack.elementAt(CUP$top-0)).str_val, new symbol_part(this_nt)); new symbol_part(new terminal((/*term_id*/(java_cup.runtime.str_token)CUP$stack.elementAt(CUP$top-0)).str_val, multipart_name))); add_rhs_part(new symbol_part(start_nt)); add_rhs_part(new symbol_part(terminal.EOF)); emit.start_production = new production(non_terminal.START_nt, rhs_parts, rhs_pos); add_rhs_part(new symbol_part(start_nt)); add_rhs_part(new symbol_part(terminal.EOF)); emit.start_production = new production(non_terminal.START_nt, rhs_parts, rhs_pos); symbols.put("error", new symbol_part(terminal.error));
/** Convert to a string. */ public String toString() { String result; /* catch any internal errors */ try { result = "production [" + index() + "]: "; result += ((lhs() != null) ? lhs().toString() : "$$NULL-LHS$$"); result += " :: = "; for (int i = 0; i<rhs_length(); i++) result += rhs(i) + " "; result += ";"; if (action() != null && action().code_string() != null) result += " {" + action().code_string() + "}"; if (nullable_known()) if (nullable()) result += "[NULLABLE]"; else result += "[NOT NULLABLE]"; } catch (internal_error e) { /* crash on internal error since we can't throw it from here (because superclass does not throw anything. */ e.crash(); result = null; } return result; }
/** helper routine to clone a new production part adding a given label */ protected production_part add_lab(production_part part, String lab) throws internal_error { /* if there is no label, or this is an action, just return the original */ if (lab == null || part.is_action()) return part; /* otherwise build a new one with the given label attached */ return new symbol_part(((symbol_part)part).the_symbol(),lab); }
/** Produce a hash code. */ public int hashCode() { return super.hashCode() ^ (the_symbol()==null ? 0 : the_symbol().hashCode()); }
if (part.label() != null) make_declaration(part.label(), part.the_symbol().stack_type(), rhs_len-pos-1);
/** Generic equality comparison. */ public boolean equals(Object other) { if (!(other instanceof symbol_part)) return false; else return equals((symbol_part)other); }
_rhs[act_loc] = new symbol_part(new_nt);
/** Convert to a string. */ public String toString() { String result; /* catch any internal errors */ try { result = "production [" + index() + "]: "; result += ((lhs() != null) ? lhs().toString() : "$$NULL-LHS$$"); result += " :: = "; for (int i = 0; i<rhs_length(); i++) result += rhs(i) + " "; result += ";"; if (action() != null && action().code_string() != null) result += " {" + action().code_string() + "}"; if (nullable_known()) if (nullable()) result += "[NULLABLE]"; else result += "[NOT NULLABLE]"; } catch (internal_error e) { /* crash on internal error since we can't throw it from here (because superclass does not throw anything. */ e.crash(); result = null; } return result; }
/** helper routine to clone a new production part adding a given label */ protected production_part add_lab(production_part part, String lab) throws internal_error { /* if there is no label, or this is an action, just return the original */ if (lab == null || part.is_action()) return part; /* otherwise build a new one with the given label attached */ return new symbol_part(((symbol_part)part).the_symbol(),lab); }
/** Equality comparison. */ public boolean equals(symbol_part other) { return other != null && super.equals(other) && the_symbol().equals(other.the_symbol()); }
if (part.label() != null) make_declaration(part.label(), part.the_symbol().stack_type(), rhs_len-pos-1);
/** Generic equality comparison. */ public boolean equals(Object other) { if (!(other instanceof symbol_part)) return false; else return equals((symbol_part)other); }
_rhs[act_loc] = new symbol_part(new_nt);