Commit cd73cf64 authored by Michael Schwarz's avatar Michael Schwarz

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

parent fb7becf8
......@@ -219,15 +219,13 @@ class ConflictPanel extends Composite {
int cindex = state.index();
stateLabel.setText("<a href=\"" + cindex + "\">State: " + cindex + "</a>");
if (conflict instanceof ReduceReduceConflict) {
if (conflict instanceof ReduceReduceConflict) {
ReduceReduceConflict rrc = (ReduceReduceConflict) conflict;
srdetails = null;
ReduceReduceConflict rrc = (ReduceReduceConflict) conflict;
changeColors(backgroundColorReduceReduce, foregroundColorReduceReduce);
conflictTypeLabel.setText("Reduce-Reduce conflict");
resolutionOptions.setVisible(false);
resolutionButton.setVisible(false);
detailText.setText(makeReduceReduceDetailText(rrc,linkCounter));
StringBuilder symbolsBuilder = new StringBuilder();
symbolsBuilder.append("Under symbols: ");
......@@ -240,7 +238,10 @@ class ConflictPanel extends Composite {
}
symbolLabel.setText(symbolsBuilder.toString());
detailText.setText(makeReduceReduceDetailText(rrc,linkCounter));
resolutionOptions.setVisible(false);
resolutionButton.setVisible(false);
resolutionOptions.removeAll();
} else if (conflict instanceof ShiftReduceConflict) {
......@@ -355,10 +356,12 @@ class ConflictPanel extends Composite {
if(!srdetails.shiftAffectsOthers){
resolutionOptions.add("Shift (make " + srdetails.shift.name() +" right associative)");
resolutionOptions.add("Reduce (make " + srdetails.shift.name() +" left associative)");
resolutionOptions.add("Report error (make " + srdetails.shift.name() +" non-associative)");
}
else {
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: Report error (make " + srdetails.shift.name() +" non-associative)");
}
}
......@@ -415,8 +418,13 @@ class ConflictPanel extends Composite {
}
if(pti.isResolvedAsError(srdetails)){
//TODO
throw new IllegalStateException("Nope");
resolutionOptions.select(3);
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);
......@@ -515,20 +523,18 @@ class ConflictPanel extends Composite {
else {
// Checking this is sufficient since the terminals are identical
if(srdetails.shiftAffectsOthers){
if(resolutionOptions.getSelectionIndex() == 1) { //Shift
forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Right);
}
else if (resolutionOptions.getSelectionIndex() == 2) { // Reduce
forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Left);
}
cupConflictsView.beginConnectedResolution();
forceEnableDropdown = true;
}
else {
if(resolutionOptions.getSelectionIndex() == 1) // Shift
cupConflictsView.insertPrecedence(srdetails.shift,Precedence.Type.Right);
else if (resolutionOptions.getSelectionIndex() == 2) // Reduce
cupConflictsView.insertPrecedence(srdetails.shift,Precedence.Type.Left);
if(resolutionOptions.getSelectionIndex() == 1) { // Shift
cupConflictsView.insertPrecedence(srdetails.shift,Precedence.Type.Right);
}
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 {
forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Right);
}
else if (resolutionOptions.getSelectionIndex() == 2) { // Reduce
else if(resolutionOptions.getSelectionIndex() == 2) { // Reduce
forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.Left);
}
else if(resolutionOptions.getSelectionIndex() == 3) { // Non-Assoc
forceEnableDropdown = true;
cupConflictsView.setTerminalAssoc(srdetails.shift,Precedence.Type.NonAssoc);
}
}
else {
if((resolutionOptions.getSelectionIndex() == 1 && cupConflictsView.currentPrecs.isResolvedInFavorOfShift(srdetails))
......
......@@ -406,6 +406,10 @@ class PrecedenceToInsert {
*/
public void setAssoc(terminal t,Precedence.Type p){
precs.put(t, p);
if(!edges.containsKey(t)){
edges.put(t, new HashSet<>());
}
}
/**
......
Markdown is supported
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