Commit 2949f6fd authored by Sebastian Pretscher's avatar Sebastian Pretscher

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

parents ccb3ac68 ec114a68
......@@ -10,6 +10,8 @@ public abstract class Conflict
public lalr_state getState() {
return state;
}
public abstract ConflictType getType();
public Conflict(lalr_state state) {
this.state = state;
......
package de.in.tum.www2.cup;
public enum ConflictType {
ShiftReduce,
ReduceReduce
}
......@@ -128,6 +128,26 @@ public class CupSymbol {
}
}
public static boolean isDelimiter(char c) {
switch (c) {
case ' ':
case '\t':
case '?':
case ';':
case ',':
case '*':
case '.':
case '|':
case '[':
case ']':
case ':':
case '<':
case '>':
return true;
}
return false;
}
public static String[] getKeywords() {
return keywordStrings;
}
......
......@@ -25,6 +25,11 @@ public class ReduceReduceConflict extends Conflict
return conflict2;
}
@Override
public ConflictType getType() {
return ConflictType.ReduceReduce;
}
public ReduceReduceConflict(lalr_state state, lalr_item conflict1, lalr_item conflict2, List<terminal> terminals) {
super(state);
this.conflict1 = conflict1;
......
......@@ -24,6 +24,11 @@ public class ShiftReduceConflict extends Conflict
return conflict2;
}
@Override
public ConflictType getType() {
return ConflictType.ShiftReduce;
}
public ShiftReduceConflict(lalr_state state, lalr_item conflict1, List<lalr_item> conflict2, terminal terminal) {
super(state);
this.conflict1 = conflict1;
......
......@@ -3,8 +3,10 @@ package de.tum.in.www2.cupplugin.editors;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import de.in.tum.www2.cup.ConflictType;
import de.in.tum.www2.cup.Position;
import de.in.tum.www2.cup.Range;
import de.tum.in.www2.cupplugin.PluginUtility;
public class Jumper {
......@@ -13,6 +15,14 @@ public class Jumper {
Jumper (MultiPageEditor mpe) {
this.mpe = mpe;
}
public void jumpToConflictGraphState(ConflictType conflictType, int index) {
PluginUtility.showMessage("Jumper: Jump to conflict graph state - not yet implemented!");
mpe.jumpTo(mpe.CONFLICT_GRAPH_PAGE_INDEX);
// TODO!
// mpe.getConflictGraphView().
}
public void jumpToEditorSelection(Range range) {
if (range == null)
......
......@@ -63,6 +63,10 @@ public class MultiPageEditor extends MultiPageEditorPart implements
return editor;
}
CupConflictGraphView getConflictGraphView() {
return conflictGraphView;
}
void createEditorPage(Jumper jumper) {
try {
editor = new CupTextEditor(jumper);
......
......@@ -24,6 +24,7 @@ import org.eclipse.ui.forms.widgets.TableWrapLayout;
import de.in.tum.www2.cup.Conflict;
import de.in.tum.www2.cup.ConflictManager;
import de.in.tum.www2.cup.ConflictType;
import de.in.tum.www2.cup.LALRResult;
import de.in.tum.www2.cup.Range;
import de.in.tum.www2.cup.ReduceReduceConflict;
......@@ -57,6 +58,11 @@ public class CupConflictsView implements ICupEditorPageVisibility,
class ConflictPanel extends Composite {
private static final int COLUMNS = 3;
private static final int HEADING_FONT_SIZE = 14;
private Conflict conflict;
private Label conflictTypeLabel;
private Link stateLabel;
private Label symbolLabel;
......@@ -83,34 +89,37 @@ public class CupConflictsView implements ICupEditorPageVisibility,
data.heightHint = 80;
setLayoutData(data);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 3;
layout.verticalSpacing = 8;
setLayout(layout);
GridLayout gl = new GridLayout();
gl.numColumns = COLUMNS;
gl.makeColumnsEqualWidth = false;
setLayout(gl);
this.conflictTypeLabel = new Label(this, SWT.NONE);
FontData[] fD = conflictTypeLabel.getFont().getFontData();
fD[0].setHeight(14);
fD[0].setHeight(HEADING_FONT_SIZE);
conflictTypeLabel.setFont( new Font(Display.getCurrent(),fD[0]));
this.symbolLabel = new Label(this, SWT.NONE);
this.stateLabel = new Link(this, SWT.NONE);
GridData td2 = new GridData(GridData.HORIZONTAL_ALIGN_END);
td2.grabExcessHorizontalSpace = true;
td2.widthHint = 60;
stateLabel.setLayoutData(td2);
stateLabel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PluginUtility.showMessage("Not yet implemented!");
if (conflict == null)
return;
jumper.jumpToConflictGraphState(conflict.getType(), Integer
.parseInt(e.text));
}
});
this.detailText = new Link(this, SWT.WRAP);
this.detailText.setBackground(new Color(Display.getCurrent(),
Colors.lightGray));
TableWrapData td = new TableWrapData();
td.colspan = 1;
detailText.setLayoutData(td);
Composite detailWrapper = makeDetailWrapper(COLUMNS);
this.detailText = new Link(detailWrapper, SWT.WRAP);
detailText.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
......@@ -121,6 +130,26 @@ public class CupConflictsView implements ICupEditorPageVisibility,
});
}
private Composite makeDetailWrapper(int columns) {
Composite detailWrapper = new Composite(this, SWT.WRAP);
detailWrapper.setBackground(new Color(Display.getCurrent(), Colors.red));
GridData detailTextData = new GridData();
detailTextData.grabExcessHorizontalSpace = true;
detailTextData.horizontalSpan = columns;
detailWrapper.setLayoutData(detailTextData);
TableWrapLayout layout = new TableWrapLayout();
layout.bottomMargin = 0;
layout.topMargin = 0;
layout.leftMargin = 0;
layout.rightMargin = 0;
layout.makeColumnsEqualWidth = false;
layout.numColumns = 1;
layout.verticalSpacing = 0;
detailWrapper.setLayout(layout);
return detailWrapper;
}
private void changeColors(Color background, Color foreground) {
setBackground(background);
detailText.setBackground(background);
......@@ -132,10 +161,13 @@ public class CupConflictsView implements ICupEditorPageVisibility,
}
public void update(Conflict conflict) {
this.conflict = conflict;
links.clear();
int linkCounter = 0;
stateLabel.setText("<a href=\"TODO\">State: " + conflict.getState().index() + "</a>");
int cindex = conflict.getState().index();
stateLabel.setText("<a href=\"" + cindex + "\">State: " + cindex + "</a>");
if (conflict instanceof ReduceReduceConflict) {
ReduceReduceConflict rrc = (ReduceReduceConflict) conflict;
......@@ -300,10 +332,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
conflictPanels.add(new ConflictPanel(list, SWT.NONE));
}
}
System.out
.println("conflictPanels size: " + this.conflictPanels.size());
System.out.println("conflictPanels size: " + this.conflictPanels.size());
}
private void refreshScrolledLayout() {
......
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