Commit 24da6c0e authored by Michael Schwarz's avatar Michael Schwarz 🤔
Browse files

fixed bug when no precedence for reduce is given

parent 2d58e6e1
...@@ -404,7 +404,7 @@ class ConflictPanel extends Composite { ...@@ -404,7 +404,7 @@ class ConflictPanel extends Composite {
resolutionOptions.setEnabled(true); resolutionOptions.setEnabled(true);
// Used assoc to sort out. Can't be changed anymore (unless this is the start) // Used assoc to sort out. Can't be changed anymore (unless this is the start)
if(srdetails.reduce.equals(srdetails.shift)){ if(srdetails.shiftAndReducePrecedenceFromSameTerminal()){
resolutionOptions.setEnabled(forceEnableDropdown); resolutionOptions.setEnabled(forceEnableDropdown);
} }
} }
...@@ -413,7 +413,7 @@ class ConflictPanel extends Composite { ...@@ -413,7 +413,7 @@ class ConflictPanel extends Composite {
resolutionOptions.setEnabled(true); resolutionOptions.setEnabled(true);
// Used assoc to sort out. Can't be changed anymore // Used assoc to sort out. Can't be changed anymore
if(srdetails.reduce.equals(srdetails.shift)){ if(srdetails.shiftAndReducePrecedenceFromSameTerminal()){
resolutionOptions.setEnabled(forceEnableDropdown); resolutionOptions.setEnabled(forceEnableDropdown);
} }
} }
...@@ -423,7 +423,7 @@ class ConflictPanel extends Composite { ...@@ -423,7 +423,7 @@ class ConflictPanel extends Composite {
resolutionOptions.setEnabled(true); resolutionOptions.setEnabled(true);
// Used assoc to sort out. Can't be changed anymore (unless this is the start) // Used assoc to sort out. Can't be changed anymore (unless this is the start)
if(srdetails.reduce.equals(srdetails.shift)){ if(srdetails.shiftAndReducePrecedenceFromSameTerminal()){
resolutionOptions.setEnabled(forceEnableDropdown); resolutionOptions.setEnabled(forceEnableDropdown);
} }
} }
......
...@@ -194,7 +194,6 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -194,7 +194,6 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
int size = conflicts.size(); int size = conflicts.size();
scrolled.setLayoutDeferred(true); scrolled.setLayoutDeferred(true);
matchPanelNumber(size);
// Do this first, otherwise the affects others is wrong because it operates on a subset of actual terminals // Do this first, otherwise the affects others is wrong because it operates on a subset of actual terminals
terminalsAffectConflicts = new HashMap<>(); terminalsAffectConflicts = new HashMap<>();
...@@ -202,7 +201,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -202,7 +201,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
Conflict conflict = conflicts.get(i); Conflict conflict = conflicts.get(i);
addToTerminalSet(crm,conflict); addToTerminalSet(crm,conflict);
} }
matchPanelNumber(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
Conflict conflict = conflicts.get(i); Conflict conflict = conflicts.get(i);
ConflictPanel panel = conflictPanels.get(i); ConflictPanel panel = conflictPanels.get(i);
......
...@@ -79,7 +79,7 @@ class PrecedenceToInsert { ...@@ -79,7 +79,7 @@ class PrecedenceToInsert {
* @return true iff conflict is resolved in favor of Shift * @return true iff conflict is resolved in favor of Shift
*/ */
public boolean isResolvedInFavorOfShift(ShiftReduceDetails srd){ public boolean isResolvedInFavorOfShift(ShiftReduceDetails srd){
if(!srd.shift.equals(srd.reduce)) if(!srd.shiftAndReducePrecedenceFromSameTerminal())
//TODO: Check if precedence set for terminal at all //TODO: Check if precedence set for terminal at all
return hasPrecedence(srd.shift,srd.reduce); return hasPrecedence(srd.shift,srd.reduce);
else else
...@@ -92,7 +92,7 @@ class PrecedenceToInsert { ...@@ -92,7 +92,7 @@ class PrecedenceToInsert {
* @return true iff conflict is resolved in favor of Reduce * @return true iff conflict is resolved in favor of Reduce
*/ */
public boolean isResolvedInFavorOfReduce(ShiftReduceDetails srd) { public boolean isResolvedInFavorOfReduce(ShiftReduceDetails srd) {
if(!srd.shift.equals(srd.reduce)) if(!srd.shiftAndReducePrecedenceFromSameTerminal())
//TODO: Check if precedence set for terminal at all //TODO: Check if precedence set for terminal at all
return hasPrecedence(srd.reduce,srd.shift); return hasPrecedence(srd.reduce,srd.shift);
else else
...@@ -106,7 +106,7 @@ class PrecedenceToInsert { ...@@ -106,7 +106,7 @@ class PrecedenceToInsert {
* @return true iff conflict is resolved as error * @return true iff conflict is resolved as error
*/ */
public boolean isResolvedAsError(ShiftReduceDetails srd) { public boolean isResolvedAsError(ShiftReduceDetails srd) {
if(!srd.reduce.equals(srd.shift)) if(!srd.shiftAndReducePrecedenceFromSameTerminal())
return false; return false;
else else
return precs.get(srd.shift) == Precedence.Type.NonAssoc; return precs.get(srd.shift) == Precedence.Type.NonAssoc;
......
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