Commit 132bec28 authored by Benedikt Engeser's avatar Benedikt Engeser

Merge branch 'master' of git@github.com:jroith/cup-eclipse.git

parents bf4fe419 2a33a226
package de.in.tum.www2.cup;
import java.util.List;
import de.in.tum.www2.cup.internal.lalr_item;
import de.in.tum.www2.cup.internal.lalr_state;
public class ReduceReduceConflict extends Conflict
{
private lalr_item conflict1;
private lalr_item conflict2;
public lalr_item getConflictItem1() {
return conflict1;
}
public lalr_item getConflictItem2() {
return conflict2;
}
public ReduceReduceConflict(lalr_state state) {
public ReduceReduceConflict(lalr_state state, lalr_item conflict1, lalr_item conflict2) {
super(state);
this.conflict1 = conflict1;
this.conflict2 = conflict2;
}
// state (index)
......
package de.in.tum.www2.cup;
import java.util.List;
import de.in.tum.www2.cup.internal.lalr_item;
import de.in.tum.www2.cup.internal.lalr_state;
public class ShiftReduceConflict extends Conflict
{
public ShiftReduceConflict(lalr_state state) {
private lalr_item conflict1;
private List<lalr_item> conflict2;
public lalr_item getConflictItem1() {
return conflict1;
}
public List<lalr_item> getConflictItems2() {
return conflict2;
}
public ShiftReduceConflict(lalr_state state, lalr_item conflict1, List<lalr_item> conflict2) {
super(state);
this.conflict1 = conflict1;
this.conflict2 = conflict2;
}
// state (index)
......
package de.in.tum.www2.cup.internal;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.List;
import java.util.Stack;
import de.in.tum.www2.cup.Conflict;
......@@ -839,7 +841,9 @@ public class lalr_state {
else
message+="the second production.\n";
Conflict conflict = new ReduceReduceConflict(this);
// TODO: add symbols!
// TODO: add resolved in favour of.
Conflict conflict = new ReduceReduceConflict(this, itm1, itm2);
ConflictManager cm = context.getConflictManager();
cm.addConflict(conflict);
......@@ -868,6 +872,8 @@ public class lalr_state {
String message = "*** Shift/Reduce conflict found in state #"+index()+"\n" +
" between " + red_itm.to_simple_string()+"\n";
List<lalr_item> conflictingItems = new ArrayList<lalr_item>();
/* find and report on all items that shift under our conflict symbol */
for (Enumeration itms = items().all(); itms.hasMoreElements(); )
{
......@@ -889,7 +895,7 @@ public class lalr_state {
message += " under symbol "+ shared.find(conflict_sym).name() + "\n"+
" Resolved in favor of shifting.\n";
Conflict conflict = new ShiftReduceConflict(this);
Conflict conflict = new ShiftReduceConflict(this, red_itm, conflictingItems);
ConflictManager cm = context.getConflictManager();
cm.addConflict(conflict);
......
......@@ -119,8 +119,8 @@ public class DocumentDidChangeJob extends Job {
errorReporter.pushToUIThread();
if (result != null) {
ParserResultJob resultModelJob = new ParserResultJob(result,
revNumber);
ParserResultJob resultModelJob = new ParserResultJob(
result, context, revNumber);
resultModelJob.setSystem(true);
resultModelJob.schedule();
try {
......@@ -196,10 +196,12 @@ public class DocumentDidChangeJob extends Job {
class ParserResultJob extends UIJob {
private ParserResult parserResult;
private CupContext context;
private long parserModelRevisionNumber;
public ParserResultJob(ParserResult result, long revisionNumber) {
public ParserResultJob(ParserResult result, CupContext context, long revisionNumber) {
super("Parser Result UI Job");
this.context = context;
this.parserResult = result;
this.parserModelRevisionNumber = revisionNumber;
}
......@@ -213,7 +215,7 @@ public class DocumentDidChangeJob extends Job {
.getEditorInput());
if (document != null) {
Model model = Model.getInstanceForDocument(document);
model.setASTModel(this.parserResult, revNumber);
model.setASTModel(this.parserResult, context, revNumber);
return Status.OK_STATUS;
}
}
......
......@@ -15,6 +15,7 @@ public class Model {
private static WeakHashMap<IDocument, Model> instances = new WeakHashMap<IDocument, Model> ();
private ParserResult astModel;
private CupContext astContext;
private long astModelRevisionNumber;
private LALRResult lalrModel;
......@@ -88,9 +89,10 @@ public class Model {
}
}
public void setASTModel(ParserResult result, long revisionNumber) {
public void setASTModel(ParserResult result, CupContext context, long revisionNumber) {
synchronized (parserModelLock) {
this.astModel = result;
this.astContext = context;
this.astModelRevisionNumber = revisionNumber;
for(Object observer : modelObservers) {
if(observer instanceof ICupParserASTChangeObserver) {
......@@ -105,7 +107,7 @@ public class Model {
this.astModelRevisionNumber = revisionNumber;
}
}
public long getAstModelRevisionNumber() {
return this.astModelRevisionNumber;
}
......@@ -115,6 +117,12 @@ public class Model {
return this.lalrModel;
}
}
public CupContext getAstModelContext() {
synchronized (parserModelLock) {
return this.astContext;
}
}
public void setLaLrResultModel(LALRResult result, long revisionNumber, CupContext lalrContext) {
synchronized (lalrModellock) {
......
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