1 8 9 package net.sourceforge.chaperon.build.conflict; 10 11 import net.sourceforge.chaperon.build.ItemSetCollection; 12 import net.sourceforge.chaperon.model.grammar.Grammar; 13 import net.sourceforge.chaperon.model.symbol.Terminal; 14 15 21 public class ReduceReduceConflict extends Conflict 22 { 23 private Grammar grammar; 24 private ItemSetCollection itemsets; 25 private int state; 26 private Terminal symbol; 27 private int firstproduction; 28 private int secondproduction; 29 30 40 public ReduceReduceConflict(Grammar grammar, ItemSetCollection itemsets, int state, 41 Terminal symbol, int firstproduction, int secondproduction) 42 { 43 this.grammar = grammar; 44 this.itemsets = itemsets; 45 this.state = state; 46 this.symbol = symbol; 47 this.firstproduction = firstproduction; 48 this.secondproduction = secondproduction; 49 } 50 51 56 public int getState() 57 { 58 return state; 59 } 60 61 66 public Terminal getSymbol() 67 { 68 return symbol; 69 } 70 71 76 public int getFirstProduction() 77 { 78 return firstproduction; 79 } 80 81 86 public int getSecondProduction() 87 { 88 return secondproduction; 89 } 90 91 96 public String toString() 97 { 98 StringBuffer buffer = new StringBuffer (); 99 100 buffer.append("Reduce/Reduce conflict in state "); 101 buffer.append(String.valueOf(state)); 102 buffer.append(" between"); 103 buffer.append(System.getProperty("line.separator")); 104 buffer.append(grammar.getProduction(firstproduction)); 105 buffer.append("[priority="); 106 buffer.append(String.valueOf(grammar.getPriority(grammar.getProduction(firstproduction)))); 107 buffer.append("]"); 108 buffer.append(System.getProperty("line.separator")); 109 buffer.append("and"); 110 buffer.append(System.getProperty("line.separator")); 111 buffer.append(grammar.getProduction(secondproduction)); 112 buffer.append("[priority="); 113 buffer.append(String.valueOf(grammar.getPriority(grammar.getProduction(firstproduction)))); 114 buffer.append("]"); 115 buffer.append(System.getProperty("line.separator")); 116 buffer.append("for symbol "); 117 buffer.append(symbol); 118 buffer.append("[priority="); 119 buffer.append(String.valueOf(grammar.getPriority(symbol))); 120 buffer.append(" associativity="); 121 buffer.append(String.valueOf(grammar.getAssociativity(symbol))); 122 buffer.append("]"); 123 124 return buffer.toString(); 125 } 126 } 127 | Popular Tags |