Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 2 package java_cup; 3 4 import java.util.Enumeration ; 5 6 15 public class parse_reduce_table { 16 17 18 19 20 21 25 public parse_reduce_table() 26 { 27 28 _num_states = lalr_state.number(); 29 30 31 under_state = new parse_reduce_row[_num_states]; 32 for (int i=0; i<_num_states; i++) 33 under_state[i] = new parse_reduce_row(); 34 } 35 36 37 38 39 40 41 42 protected int _num_states; 43 44 45 public int num_states() {return _num_states;} 46 47 48 49 50 public parse_reduce_row[] under_state; 51 52 53 54 55 56 57 public String toString() 58 { 59 String result; 60 lalr_state goto_st; 61 int cnt; 62 63 result = "-------- REDUCE_TABLE --------\n"; 64 for (int row = 0; row < num_states(); row++) 65 { 66 result += "From state #" + row + "\n"; 67 cnt = 0; 68 for (int col = 0; col < parse_reduce_row.size(); col++) 69 { 70 71 goto_st = under_state[row].under_non_term[col]; 72 73 74 if (goto_st != null) 75 { 76 result += " [non term " + col + "->"; 77 result += "state " + goto_st.index() + "]"; 78 79 80 cnt++; 81 if (cnt == 3) 82 { 83 result += "\n"; 84 cnt = 0; 85 } 86 } 87 } 88 89 if (cnt != 0) result += "\n"; 90 } 91 result += "-----------------------------"; 92 93 return result; 94 } 95 96 97 98 } 99 100
| Popular Tags
|