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 ShiftReduceConflict extends Conflict 22 { 23 private Grammar grammar; 24 private ItemSetCollection itemsets; 25 private int state; 26 private Terminal symbol; 27 private int production; 28 29 38 public ShiftReduceConflict(Grammar grammar, ItemSetCollection itemsets, int state, 39 Terminal symbol, int production) 40 { 41 this.grammar = grammar; 42 this.itemsets = itemsets; 43 this.state = state; 44 this.symbol = symbol; 45 this.production = production; 46 } 47 48 53 public int getState() 54 { 55 return state; 56 } 57 58 63 public Terminal getSymbol() 64 { 65 return symbol; 66 } 67 68 73 public int getProduction() 74 { 75 return production; 76 } 77 78 83 public String toString() 84 { 85 StringBuffer buffer = new StringBuffer (); 86 87 buffer.append("Shift/Reduce conflict in state "); 88 buffer.append(String.valueOf(state)); 89 buffer.append(" at"); 90 buffer.append(System.getProperty("line.separator")); 91 buffer.append(grammar.getProduction(production)); 92 buffer.append("[priority="); 93 buffer.append(String.valueOf(grammar.getPriority(grammar.getProduction(production)))); 94 buffer.append(" associativity="); 95 buffer.append(String.valueOf(grammar.getAssociativity(grammar.getProduction(production)))); 96 buffer.append("]"); 97 buffer.append(System.getProperty("line.separator")); 98 buffer.append("and symbol "); 99 buffer.append(symbol); 100 buffer.append("[priority="); 101 buffer.append(String.valueOf(grammar.getPriority(symbol))); 102 buffer.append(" associativity="); 103 buffer.append(String.valueOf(grammar.getAssociativity(symbol))); 104 buffer.append("]"); 105 106 return buffer.toString(); 107 } 108 } 109 | Popular Tags |