Commit 3e9e12df authored by Sebastian Pretscher's avatar Sebastian Pretscher

Some adaptions

parent 2949f6fd
......@@ -5,21 +5,21 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/CupAntBasedBuilder.launch</value>
<value>&lt;project&gt;/.externalToolBuilders/New_Builder.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
......
......@@ -20,7 +20,7 @@ public class ConflictResolutionManager {
private CupContext lalrContext;
private lalr_state.lalr_state_shared sharedState;
private final List<Conflict> allInterestingConflicts;
private final List<Conflict> allConflicts;
private final HashMap<Integer, lalr_state> stateHashMap;
private final Stack<DFSNode> searchStack;
......@@ -32,7 +32,7 @@ public class ConflictResolutionManager {
}
public ConflictResolutionManager(CupContext lalrContext, boolean useDijkstra) {
allInterestingConflicts = new LinkedList<Conflict>();
allConflicts = new LinkedList<Conflict>();
stateHashMap = new HashMap<Integer, lalr_state>();
searchStack = new Stack<DFSNode>();
visitedStates = new HashSet<lalr_state>();
......@@ -50,7 +50,7 @@ public class ConflictResolutionManager {
}
this.lalrContext = lalrContext;
allInterestingConflicts.clear();
allConflicts.clear();
stateHashMap.clear();
searchStack.clear();
visitedStates.clear();
......@@ -59,10 +59,7 @@ public class ConflictResolutionManager {
sharedState = lalr_state.getShared(lalrContext);
for (Conflict conf : lalrContext.getConflictManager().getConflicts()) {
if (conf instanceof ShiftReduceConflict
|| conf instanceof ReduceReduceConflict) {
allInterestingConflicts.add(conf);
}
allConflicts.add(conf);
}
Enumeration allEnum = sharedState.all();
......@@ -83,8 +80,8 @@ public class ConflictResolutionManager {
this.useDijkstar = useDijkstar;
}
public List<Conflict> getAllInterstingConflicts() {
return allInterestingConflicts;
public List<Conflict> getAllConflicts() {
return allConflicts;
}
private HashMap<Integer, DijkstraNode> dijkstraSearch() {
......@@ -216,29 +213,34 @@ public class ConflictResolutionManager {
CupConflictState oldConflictState = null;
DFSNode oldDFSNode = null;
int counter = 0;
DFSNode actualNode = searchStack.pop();
while (actualNode != null) {
if (oldConflictState == null) {
oldConflictState = new CupConflictState(
actualNode.getState(), null);
if(oldConflictState==null) {
oldConflictState = new CupConflictState(actualNode.state, null);
oldDFSNode = actualNode;
resultList.add(oldConflictState);
actualNode = searchStack.pop();
if(!searchStack.isEmpty()) {
actualNode = searchStack.pop();
} else {
actualNode = null;
}
continue;
}
CupConflictState predecessor = new CupConflictState(
actualNode.getState(),
oldDFSNode.getPredTransition());
predecessor.setSuccessor(oldConflictState);
oldConflictState = predecessor;
CupConflictState newConflictState = new CupConflictState(actualNode.getState(), oldDFSNode.getPredTransition());
newConflictState.setSuccessor(oldConflictState);
resultList.add(newConflictState);
oldConflictState = newConflictState;
oldDFSNode = actualNode;
if(!searchStack.isEmpty()) {
actualNode = searchStack.pop();
} else {
actualNode = null;
}
}
Collections.reverse(resultList);
return resultList;
} else {
return null;
......
......@@ -325,7 +325,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
conflictResulutionManager.setLaLrContext(lalrContext);
// TODO: This should only contain tainted states!!
List<Conflict> allInterstingConflicts = conflictResulutionManager
.getAllInterstingConflicts();
.getAllConflicts();
List<String> stateNames = new ArrayList<String>();
for (Conflict conf : allInterstingConflicts) {
lalr_state state = conf.getState();
......
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