/** Add a singleton item, merging lookahead sets if the item is already * part of the set. returns the element of the set that was added or * merged into. * @param itm the item being added. */ public lalr_item add(lalr_item itm) throws internal_error { lalr_item other; not_null(itm); /* see if an item with a matching core is already there */ other = (lalr_item)_all.get(itm); /* if so, merge this lookahead into the original and leave it */ if (other != null) { other.lookahead().add(itm.lookahead()); return other; } /* otherwise we just go in the set */ else { /* invalidate cached hashcode */ hashcode_cache = null; _all.put(itm,itm); return itm; } }
/** Add a singleton item, merging lookahead sets if the item is already * part of the set. returns the element of the set that was added or * merged into. * @param itm the item being added. */ public lalr_item add(lalr_item itm) throws internal_error { lalr_item other; not_null(itm); /* see if an item with a matching core is already there */ other = (lalr_item)_all.get(itm); /* if so, merge this lookahead into the original and leave it */ if (other != null) { other.lookahead().add(itm.lookahead()); return other; } /* otherwise we just go in the set */ else { /* invalidate cached hashcode */ hashcode_cache = null; _all.put(itm,itm); return itm; } }
/** Add a singleton item, merging lookahead sets if the item is already * part of the set. returns the element of the set that was added or * merged into. * @param itm the item being added. */ public lalr_item add(lalr_item itm) throws internal_error { lalr_item other; not_null(itm); /* see if an item with a matching core is already there */ other = (lalr_item)_all.get(itm); /* if so, merge this lookahead into the original and leave it */ if (other != null) { other.lookahead().add(itm.lookahead()); return other; } /* otherwise we just go in the set */ else { /* invalidate cached hashcode */ hashcode_cache = null; _all.put(itm,itm); return itm; } }
/** Add a singleton item, merging lookahead sets if the item is already * part of the set. returns the element of the set that was added or * merged into. * @param itm the item being added. */ public lalr_item add(lalr_item itm) throws internal_error { lalr_item other; not_null(itm); /* see if an item with a matching core is already there */ other = (lalr_item)_all.get(itm); /* if so, merge this lookahead into the original and leave it */ if (other != null) { other.lookahead().add(itm.lookahead()); return other; } /* otherwise we just go in the set */ else { /* invalidate cached hashcode */ hashcode_cache = null; _all.put(itm,itm); return itm; } }
/** Add a singleton item, merging lookahead sets if the item is already * part of the set. returns the element of the set that was added or * merged into. * @param itm the item being added. */ public lalr_item add(lalr_item itm) throws internal_error { lalr_item other; not_null(itm); /* see if an item with a matching core is already there */ other = (lalr_item)_all.get(itm); /* if so, merge this lookahead into the original and leave it */ if (other != null) { other.lookahead().add(itm.lookahead()); return other; } /* otherwise we just go in the set */ else { /* invalidate cached hashcode */ hashcode_cache = null; _all.put(itm,itm); return itm; } };
/** Add a singleton item, merging lookahead sets if the item is already * part of the set. returns the element of the set that was added or * merged into. * @param itm the item being added. */ public lalr_item add(lalr_item itm) throws internal_error { lalr_item other; not_null(itm); /* see if an item with a matching core is already there */ other = (lalr_item)_all.get(itm); /* if so, merge this lookahead into the original and leave it */ if (other != null) { other.lookahead().add(itm.lookahead()); return other; } /* otherwise we just go in the set */ else { /* invalidate cached hashcode */ hashcode_cache = null; _all.put(itm,itm); return itm; } }
/** Propagate incoming lookaheads through this item to others need to * be changed. * @params incoming symbols to potentially be added to lookahead of this item. */ public void propagate_lookaheads(terminal_set incoming) throws internal_error { boolean change = false; /* if we don't need to propagate, then bail out now */ if (!needs_propagation && (incoming == null || incoming.empty())) return; /* if we have null incoming, treat as an empty set */ if (incoming != null) { /* add the incoming to the lookahead of this item */ change = lookahead().add(incoming); } /* if we changed or need it anyway, propagate across our links */ if (change || needs_propagation) { /* don't need to propagate again */ needs_propagation = false; /* propagate our lookahead into each item we are linked to */ for (int i = 0; i < propagate_items().size(); i++) ((lalr_item)propagate_items().elementAt(i)) .propagate_lookaheads(lookahead()); } }
/** Propagate incoming lookaheads through this item to others need to * be changed. * @params incoming symbols to potentially be added to lookahead of this item. */ public void propagate_lookaheads(terminal_set incoming) throws internal_error { boolean change = false; /* if we don't need to propagate, then bail out now */ if (!needs_propagation && (incoming == null || incoming.empty())) return; /* if we have null incoming, treat as an empty set */ if (incoming != null) { /* add the incoming to the lookahead of this item */ change = lookahead().add(incoming); } /* if we changed or need it anyway, propagate across our links */ if (change || needs_propagation) { /* don't need to propagate again */ needs_propagation = false; /* propagate our lookahead into each item we are linked to */ for (int i = 0; i < propagate_items().size(); i++) ((lalr_item)propagate_items().elementAt(i)) .propagate_lookaheads(lookahead()); } }
/** Propagate incoming lookaheads through this item to others need to * be changed. * @params incoming symbols to potentially be added to lookahead of this item. */ public void propagate_lookaheads(terminal_set incoming) throws internal_error { boolean change = false; /* if we don't need to propagate, then bail out now */ if (!needs_propagation && (incoming == null || incoming.empty())) return; /* if we have null incoming, treat as an empty set */ if (incoming != null) { /* add the incoming to the lookahead of this item */ change = lookahead().add(incoming); } /* if we changed or need it anyway, propagate across our links */ if (change || needs_propagation) { /* don't need to propagate again */ needs_propagation = false; /* propagate our lookahead into each item we are linked to */ for (int i = 0; i < propagate_items().size(); i++) ((lalr_item)propagate_items().elementAt(i)) .propagate_lookaheads(lookahead()); } }
/** Propagate incoming lookaheads through this item to others need to * be changed. * @params incoming symbols to potentially be added to lookahead of this item. */ public void propagate_lookaheads(terminal_set incoming) throws internal_error { boolean change = false; /* if we don't need to propagate, then bail out now */ if (!needs_propagation && (incoming == null || incoming.empty())) return; /* if we have null incoming, treat as an empty set */ if (incoming != null) { /* add the incoming to the lookahead of this item */ change = lookahead().add(incoming); } /* if we changed or need it anyway, propagate across our links */ if (change || needs_propagation) { /* don't need to propagate again */ needs_propagation = false; /* propagate our lookahead into each item we are linked to */ for (int i = 0; i < propagate_items().size(); i++) ((lalr_item)propagate_items().elementAt(i)) .propagate_lookaheads(lookahead()); } }
/** Propagate incoming lookaheads through this item to others need to * be changed. * @params incoming symbols to potentially be added to lookahead of this item. */ public void propagate_lookaheads(terminal_set incoming) throws internal_error { boolean change = false; /* if we don't need to propagate, then bail out now */ if (!needs_propagation && (incoming == null || incoming.empty())) return; /* if we have null incoming, treat as an empty set */ if (incoming != null) { /* add the incoming to the lookahead of this item */ change = lookahead().add(incoming); } /* if we changed or need it anyway, propagate across our links */ if (change || needs_propagation) { /* don't need to propagate again */ needs_propagation = false; /* propagate our lookahead into each item we are linked to */ for (int i = 0; i < propagate_items().size(); i++) ((lalr_item)propagate_items().elementAt(i)) .propagate_lookaheads(lookahead()); } }
/** Convert to string. */ public String toString() { String result = ""; // additional output for debugging: // result += "(" + obj_hash() + ")"; result += "["; result += super.toString(); result += ", "; if (lookahead() != null) { result += "{"; for (int t = 0; t < terminal.number(); t++) if (lookahead().contains(t)) result += terminal.find(t).name() + " "; result += "}"; } else result += "NULL LOOKAHEAD!!"; result += "]"; // additional output for debugging: // result += " -> "; // for (int i = 0; i<propagate_items().size(); i++) // result+=((lalr_item)(propagate_items().elementAt(i))).obj_hash()+" "; // // if (needs_propagation) result += " NP"; return result; } /*-----------------------------------------------------------*/
/** Convert to string. */ public String toString() { String result = ""; // additional output for debugging: // result += "(" + obj_hash() + ")"; result += "["; result += super.toString(); result += ", "; if (lookahead() != null) { result += "{"; for (int t = 0; t < terminal.number(); t++) if (lookahead().contains(t)) result += terminal.find(t).name() + " "; result += "}"; } else result += "NULL LOOKAHEAD!!"; result += "]"; // additional output for debugging: // result += " -> "; // for (int i = 0; i<propagate_items().size(); i++) // result+=((lalr_item)(propagate_items().elementAt(i))).obj_hash()+" "; // // if (needs_propagation) result += " NP"; return result; } /*-----------------------------------------------------------*/
/** Produce the new lalr_item that results from shifting the dot one position * to the right. */ public lalr_item shift() throws internal_error { lalr_item result; /* can't shift if we have dot already at the end */ if (dot_at_end()) throw new internal_error("Attempt to shift past end of an lalr_item"); /* create the new item w/ the dot shifted by one */ result = new lalr_item(the_production(), dot_pos()+1, new terminal_set(lookahead())); /* change in our lookahead needs to be propagated to this item */ add_propagate(result); return result; }
/** Produce the new lalr_item that results from shifting the dot one position * to the right. */ public lalr_item shift() throws internal_error { lalr_item result; /* can't shift if we have dot already at the end */ if (dot_at_end()) throw new internal_error("Attempt to shift past end of an lalr_item"); /* create the new item w/ the dot shifted by one */ result = new lalr_item(the_production(), dot_pos()+1, new terminal_set(lookahead())); /* change in our lookahead needs to be propagated to this item */ add_propagate(result); return result; }
/** Produce the new lalr_item that results from shifting the dot one position * to the right. */ public lalr_item shift() throws internal_error { lalr_item result; /* can't shift if we have dot already at the end */ if (dot_at_end()) throw new internal_error("Attempt to shift past end of an lalr_item"); /* create the new item w/ the dot shifted by one */ result = new lalr_item(the_production(), dot_pos()+1, new terminal_set(lookahead())); /* change in our lookahead needs to be propagated to this item */ add_propagate(result); return result; }
/** Produce the new lalr_item that results from shifting the dot one position * to the right. */ public lalr_item shift() throws internal_error { lalr_item result; /* can't shift if we have dot already at the end */ if (dot_at_end()) throw new internal_error("Attempt to shift past end of an lalr_item"); /* create the new item w/ the dot shifted by one */ result = new lalr_item(the_production(), dot_pos()+1, new terminal_set(lookahead())); /* change in our lookahead needs to be propagated to this item */ add_propagate(result); return result; }
/** Produce the new lalr_item that results from shifting the dot one position * to the right. */ public lalr_item shift() throws internal_error { lalr_item result; /* can't shift if we have dot already at the end */ if (dot_at_end()) throw new internal_error("Attempt to shift past end of an lalr_item"); /* create the new item w/ the dot shifted by one */ result = new lalr_item(the_production(), dot_pos()+1, new terminal_set(lookahead())); /* change in our lookahead needs to be propagated to this item */ add_propagate(result); return result; }
/** Produce the new lalr_item that results from shifting the dot one position * to the right. */ public lalr_item shift() throws internal_error { lalr_item result; /* can't shift if we have dot already at the end */ if (dot_at_end()) throw new internal_error("Attempt to shift past end of an lalr_item"); /* create the new item w/ the dot shifted by one */ result = new lalr_item(the_production(), dot_pos()+1, new terminal_set(lookahead())); /* change in our lookahead needs to be propagated to this item */ add_propagate(result); return result; }
/** Produce the new lalr_item that results from shifting the dot one position * to the right. */ public lalr_item shift() throws internal_error { lalr_item result; /* can't shift if we have dot already at the end */ if (dot_at_end()) throw new internal_error("Attempt to shift past end of an lalr_item"); /* create the new item w/ the dot shifted by one */ result = new lalr_item(the_production(), dot_pos()+1, new terminal_set(lookahead())); /* change in our lookahead needs to be propagated to this item */ add_propagate(result); return result; }