/** Produce a new lr_item_core that results from shifting the dot one * position to the right. */ public lr_item_core shift_core() throws internal_error { if (dot_at_end()) throw new internal_error( "Attempt to shift past end of an lr_item_core"); return new lr_item_core(_the_production, _dot_pos+1); }
/** Equality comparison. */ public boolean equals(lr_item_core other) {return core_equals(other);}
/** Equality comparison -- here we only require the cores to be equal since * we need to do sets of items based only on core equality (ignoring * lookahead sets). */ public boolean equals(lalr_item other) { if (other == null) return false; return super.equals(other); }
System.err.println(red_itm.to_simple_string()); if (itm != red_itm && !itm.dot_at_end()) shift_sym = itm.symbol_after_dot(); if (!shift_sym.is_non_term() && shift_sym.index() == conflict_sym) System.err.println(" and " + itm.to_simple_string());
/** Determine if we have a dot before a non terminal, and if so which one * (return null or the non terminal). */ public non_terminal dot_before_nt() { symbol sym; /* get the symbol after the dot */ sym = symbol_after_dot(); /* if it exists and is a non terminal, return it */ if (sym != null && sym.is_non_term()) return (non_terminal)sym; else return null; }
/** 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; }
/** Convert to a string */ public String toString() { /* can't throw here since super class doesn't, so we crash instead */ try { return to_simple_string(); } catch(internal_error e) { e.crash(); return null; } }
/** Return a hash code -- here we only hash the core since we only test core * matching in LALR items. */ public int hashCode() { return super.hashCode(); }
/** 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; } /*-----------------------------------------------------------*/
System.err.println(itm1.to_simple_string()); System.err.print (" and "); System.err.println(itm2.to_simple_string()); System.err.print(" under symbols: {" ); for (int t = 0; t < terminal.number(); t++) if (itm1.the_production().index() < itm2.the_production().index()) System.err.println("the first production.\n"); else
if (itm.dot_at_end()) act = new reduce_action(itm.the_production()); if (itm.the_production().index() < ((reduce_action)other_act).reduce_with().index()) if(fix_with_precedence(itm.the_production(), t, our_act_row, act)) { term = null;
if (itm.dot_at_end()) if (compare.dot_at_end())
/** Determine if we have a dot before a non terminal, and if so which one * (return null or the non terminal). */ public non_terminal dot_before_nt() { symbol sym; /* get the symbol after the dot */ sym = symbol_after_dot(); /* if it exists and is a non terminal, return it */ if (sym != null && sym.is_non_term()) return (non_terminal)sym; else return null; }
if (dot_at_end()) return true; for (int pos = dot_pos() + 1; pos < the_production().rhs_length(); pos++) part = the_production().rhs(pos);
/** Convert to a string */ public String toString() { /* can't throw here since super class doesn't, so we crash instead */ try { return to_simple_string(); } catch(internal_error e) { e.crash(); return null; } }
/** Return a hash code -- here we only hash the core since we only test core * matching in LALR items. */ public int hashCode() { return super.hashCode(); }
/** 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 a new lr_item_core that results from shifting the dot one * position to the right. */ public lr_item_core shift_core() throws internal_error { if (dot_at_end()) throw new internal_error( "Attempt to shift past end of an lr_item_core"); return new lr_item_core(_the_production, _dot_pos+1); }
/** Generic equality comparison. */ public boolean equals(Object other) { if (!(other instanceof lr_item_core)) return false; else return equals((lr_item_core)other); }
/** Determine if we have a dot before a non terminal, and if so which one * (return null or the non terminal). */ public non_terminal dot_before_nt() { symbol sym; /* get the symbol after the dot */ sym = symbol_after_dot(); /* if it exists and is a non terminal, return it */ if (sym != null && sym.is_non_term()) return (non_terminal)sym; else return null; }