Commit cd73cf64 authored by Michael Schwarz's avatar Michael Schwarz 🤔
Browse files

Non-Assoc now is a choice for SR conflicts w/ same terminal too

parent fb7becf8
...@@ -219,15 +219,13 @@ class ConflictPanel extends Composite { ...@@ -219,15 +219,13 @@ class ConflictPanel extends Composite {
int cindex = state.index(); int cindex = state.index();
stateLabel.setText("<a href=\"" + cindex + "\">State: " + cindex + "</a>"); stateLabel.setText("<a href=\"" + cindex + "\">State: " + cindex + "</a>");
if (conflict instanceof ReduceReduceConflict) { if (conflict instanceof ReduceReduceConflict) {
ReduceReduceConflict rrc = (ReduceReduceConflict) conflict;
srdetails = null; srdetails = null;
ReduceReduceConflict rrc = (ReduceReduceConflict) conflict;
changeColors(backgroundColorReduceReduce, foregroundColorReduceReduce); changeColors(backgroundColorReduceReduce, foregroundColorReduceReduce);
conflictTypeLabel.setText("Reduce-Reduce conflict"); conflictTypeLabel.setText("Reduce-Reduce conflict");
resolutionOptions.setVisible(false);
resolutionButton.setVisible(false);
detailText.setText(makeReduceReduceDetailText(rrc,linkCounter));
StringBuilder symbolsBuilder = new StringBuilder(); StringBuilder symbolsBuilder = new StringBuilder();
symbolsBuilder.append("Under symbols: "); symbolsBuilder.append("Under symbols: ");
...@@ -240,7 +238,10 @@ class ConflictPanel extends Composite { ...@@ -240,7 +238,10 @@ class ConflictPanel extends Composite {
} }
symbolLabel.setText(symbolsBuilder.toString()); symbolLabel.setText(symbolsBuilder.toString());
detailText.setText(makeReduceReduceDetailText(rrc,linkCounter));
resolutionOptions.setVisible(false);
resolutionButton.setVisible(false);
resolutionOptions.removeAll(); resolutionOptions.removeAll();
} else if (conflict instanceof ShiftReduceConflict) { } else if (conflict instanceof ShiftReduceConflict) {
...@@ -355,10 +356,12 @@ class ConflictPanel extends Composite { ...@@ -355,10 +356,12 @@ class ConflictPanel extends Composite {
if(!srdetails.shiftAffectsOthers){ if(!srdetails.shiftAffectsOthers){
resolutionOptions.add("Shift (make " + srdetails.shift.name() +" right associative)"); resolutionOptions.add("Shift (make " + srdetails.shift.name() +" right associative)");
resolutionOptions.add("Reduce (make " + srdetails.shift.name() +" left associative)"); resolutionOptions.add("Reduce (make " + srdetails.shift.name() +" left associative)");
resolutionOptions.add("Report error (make " + srdetails.shift.name() +" non-associative)");
} }
else { else {
resolutionOptions.add("Affects others: Shift (make " + srdetails.shift.name() +" right associative)"); resolutionOptions.add("Affects others: Shift (make " + srdetails.shift.name() +" right associative)");
resolutionOptions.add("Affects others: Reduce (make " + srdetails.shift.name() +" left associative)"); resolutionOptions.add("Affects others: Reduce (make " + srdetails.shift.name() +" left associative)");
resolutionOptions.add("Affects others: Report error (make " + srdetails.shift.name() +" non-associative)");
} }
} }
...@@ -415,8 +418,13 @@ class ConflictPanel extends Composite { ...@@ -415,8 +418,13 @@ class ConflictPanel extends Composite {
} }
if(pti.isResolvedAsError(srdetails)){ if(pti.isResolvedAsError(srdetails)){
//TODO resolutionOptions.select(3);
throw new IllegalStateException("Nope"); resolutionOptions.setEnabled(true);
// Used assoc to sort out. Can't be changed anymore (unless this is the start)
if(srdetails.reduce.equals(srdetails.shift)){
resolutionOptions.setEnabled(forceEnableDropdown);
}
} }
resolutionButton.setEnabled(false); resolutionButton.setEnabled(false);
...@@ -515,20 +523,18 @@ class ConflictPanel extends Composite { ...@@ -515,20 +523,18 @@ class ConflictPanel extends Composite {
else { else {
// Checking this is sufficient since the terminals are identical // Checking this is sufficient since the terminals are identical
if(srdetails.shiftAffectsOthers){ if(srdetails.shiftAffectsOthers){
if(resolutionOptions.getSelectionIndex() == 1) { //Shift cupConflictsView.beginConnectedResolution();
forceEnableDropdown = true; forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Right);
}
else if (resolutionOptions.getSelectionIndex() == 2) { // Reduce
forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Left);
}
} }
else {
if(resolutionOptions.getSelectionIndex() == 1) // Shift if(resolutionOptions.getSelectionIndex() == 1) { // Shift
cupConflictsView.insertPrecedence(srdetails.shift,Precedence.Type.Right); cupConflictsView.insertPrecedence(srdetails.shift,Precedence.Type.Right);
else if (resolutionOptions.getSelectionIndex() == 2) // Reduce }
cupConflictsView.insertPrecedence(srdetails.shift,Precedence.Type.Left); else if (resolutionOptions.getSelectionIndex() == 2) { // Reduce
cupConflictsView.insertPrecedence(srdetails.shift,Precedence.Type.Left);
}
else if (resolutionOptions.getSelectionIndex() == 3) { // Non-Assoc
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.NonAssoc);
} }
} }
} }
...@@ -554,10 +560,14 @@ class ConflictPanel extends Composite { ...@@ -554,10 +560,14 @@ class ConflictPanel extends Composite {
forceEnableDropdown = true; forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Right); cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Right);
} }
else if (resolutionOptions.getSelectionIndex() == 2) { // Reduce else if(resolutionOptions.getSelectionIndex() == 2) { // Reduce
forceEnableDropdown = true; forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Left); cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Left);
} }
else if(resolutionOptions.getSelectionIndex() == 3) { // Non-Assoc
forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.NonAssoc);
}
} }
else { else {
if((resolutionOptions.getSelectionIndex() == 1 && cupConflictsView.currentPrecs.isResolvedInFavorOfShift(srdetails)) if((resolutionOptions.getSelectionIndex() == 1 && cupConflictsView.currentPrecs.isResolvedInFavorOfShift(srdetails))
......
...@@ -406,6 +406,10 @@ class PrecedenceToInsert { ...@@ -406,6 +406,10 @@ class PrecedenceToInsert {
*/ */
public void setAssoc(terminal t,Precedence.Type p){ public void setAssoc(terminal t,Precedence.Type p){
precs.put(t, p); precs.put(t, p);
if(!edges.containsKey(t)){
edges.put(t, new HashSet<>());
}
} }
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment