/*-----------------------------------------------------------*/ /*--- Static Methods ----------------------------------------*/ /*-----------------------------------------------------------*/ /** Helper routine for debugging -- produces a dump of the given state * onto System.out. */ protected static void dump_state(lalr_state st) { lalr_item_set itms; lalr_item itm; production_part part; if (st == null) { Console.WriteLine("NULL lalr_state"); return; } Console.WriteLine("lalr_state [" + st.index() + "] {"); itms = st.items(); IEnumerator e = itms.all(); while (e.MoveNext()) { itm = (lalr_item)e.Current; Console.Write(" ["); Console.Write(itm.the_production().lhs().the_symbol().name()); Console.Write(" ::= "); for (int i = 0; i < itm.the_production().rhs_length(); i++) { if (i == itm.dot_pos()) { Console.Write("(*) "); } part = itm.the_production().rhs(i); if (part.is_action()) { Console.Write("{action} "); } else { Console.Write(((symbol_part)part).the_symbol().name() + " "); } } if (itm.dot_at_end()) { Console.Write("(*) "); } Console.WriteLine("]"); } Console.WriteLine("}"); }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /** Equality comparison. */ public bool Equals(lalr_state other) { /* we are equal if our item sets are equal */ return(other != null && items().Equals(other.items())); }
/*-----------------------------------------------------------*/ /*--- Static Methods ----------------------------------------*/ /*-----------------------------------------------------------*/ /** Helper routine for debugging -- produces a dump of the given state * onto System.out. */ protected static void dump_state(lalr_state st) { lalr_item_set itms; lalr_item itm; production_part part; if (st == null) { Console.WriteLine("NULL lalr_state"); return; } Console.WriteLine("lalr_state [" + st.index() + "] {"); itms = st.items(); IEnumerator e = itms.all(); while ( e.MoveNext() ) { itm = (lalr_item)e.Current; Console.Write(" ["); Console.Write(itm.the_production().lhs().the_symbol().name()); Console.Write(" ::= "); for (int i = 0; i<itm.the_production().rhs_length(); i++) { if (i == itm.dot_pos()) Console.Write("(*) "); part = itm.the_production().rhs(i); if (part.is_action()) Console.Write("{action} "); else Console.Write(((symbol_part)part).the_symbol().name() + " "); } if (itm.dot_at_end()) Console.Write("(*) "); Console.WriteLine("]"); } Console.WriteLine("}"); }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /** Equality comparison. */ public bool Equals(lalr_state other) { /* we are equal if our item sets are equal */ return other != null && items().Equals(other.items()); }