Commit d1ca42bb authored by Sebastian Pretscher's avatar Sebastian Pretscher

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

parents ae73cb79 929d4615
......@@ -441,12 +441,12 @@ action_code_part ::=
int debug_id = get_new_debug_id();
// TODO: attach inner range! based on user_codexleft, user_codexright
parserResult.actionCode = new SpecialCodeBlock(
parserResult.appendActionCode (new SpecialCodeBlock(
debug_id,
SpecialCodeBlock.BlockType.Action,
user_code,
new Range(Position.fromLocation(actxleft),
Position.fromLocation(smixright)));
Position.fromLocation(smixright))));
}
:}
;
......@@ -463,12 +463,12 @@ parser_code_part ::=
else { /* save the user included code string */
context.parser_code = user_code;
int debug_id = get_new_debug_id();
parserResult.parserCode = new SpecialCodeBlock(
parserResult.appendParserCode (new SpecialCodeBlock(
debug_id,
SpecialCodeBlock.BlockType.Parser,
user_code,
new Range(Position.fromLocation(prsxleft),
Position.fromLocation(smixright)));
Position.fromLocation(smixright))));
}
:}
;
......@@ -484,12 +484,12 @@ init_code ::=
else {/* save the user code */
context.init_code = user_code;
int debug_id = get_new_debug_id();
parserResult.initCode = new SpecialCodeBlock(
parserResult.appendInitCode(new SpecialCodeBlock(
debug_id,
SpecialCodeBlock.BlockType.Init,
user_code,
new Range(Position.fromLocation(initxleft),
Position.fromLocation(smixright)));
Position.fromLocation(smixright))));
}
:}
;
......@@ -506,12 +506,12 @@ scan_code ::=
/* save the user code */
context.scan_code = user_code;
int debug_id = get_new_debug_id();
parserResult.scanCode = new SpecialCodeBlock(
parserResult.appendScanCode (new SpecialCodeBlock(
debug_id,
SpecialCodeBlock.BlockType.Scan,
user_code,
new Range(Position.fromLocation(scanxleft),
Position.fromLocation(smixright)));
Position.fromLocation(smixright))));
}
:}
......
......@@ -19,11 +19,48 @@ public class ParserResult extends AbstractNode {
public ClassName className;
// TODO: these must be ordered as they occur, using a list!!
public CodeBlock actionCode;
public CodeBlock parserCode;
public CodeBlock initCode;
public CodeBlock scanCode;
private CodeBlock actionCode;
private CodeBlock parserCode;
private CodeBlock initCode;
private CodeBlock scanCode;
public CodeBlock getActionCode() {
return actionCode;
}
public CodeBlock getParserCode() {
return parserCode;
}
public CodeBlock getInitCode() {
return initCode;
}
public CodeBlock getScanCode() {
return scanCode;
}
public void appendActionCode(SpecialCodeBlock scb) {
this.actionCode = scb;
specialCodeBlocks.add(scb);
}
public void appendParserCode(SpecialCodeBlock scb) {
this.parserCode = scb;
specialCodeBlocks.add(scb);
}
public void appendInitCode(SpecialCodeBlock scb) {
this.initCode = scb;
specialCodeBlocks.add(scb);
}
public void appendScanCode(SpecialCodeBlock scb) {
this.scanCode = scb;
specialCodeBlocks.add(scb);
}
private List<CodeBlock> specialCodeBlocks = new ArrayList<CodeBlock>();
public List<SymbolDeclaration> symbols = new ArrayList<SymbolDeclaration> ();
public List<Precedence> precedences = new ArrayList<Precedence> ();
......@@ -81,17 +118,8 @@ public class ParserResult extends AbstractNode {
if (className != null)
className.accept(visitor, childArg);
if (actionCode != null)
actionCode.accept(visitor, childArg);
if (parserCode != null)
parserCode.accept(visitor, childArg);
if (initCode != null)
initCode.accept(visitor, childArg);
if (scanCode != null)
scanCode.accept(visitor, childArg);
for (CodeBlock cb : specialCodeBlocks)
cb.accept(visitor, childArg);
if (symbols != null)
for (SymbolDeclaration s : symbols)
......
package de.in.tum.www2.cup.internal;
import de.in.tum.www2.cup.ast.AbstractNode;
import de.in.tum.www2.cup.ast.NonTerminal;
import de.in.tum.www2.cup.ast.Symbol;
/** This abstract class serves as the base class for grammar symbols (i.e.,
......
package de.tum.in.www2.cupplugin.editors;
import java.util.EnumSet;
import java.util.HashMap;
import org.eclipse.core.resources.IMarker;
......@@ -23,8 +24,17 @@ import org.eclipse.ui.ide.IDE;
import org.eclipse.zest.core.viewers.IZoomableWorkbenchPart;
import org.eclipse.zest.core.viewers.ZoomContributionViewItem;
import de.in.tum.www2.cup.ConflictManager;
import de.in.tum.www2.cup.LALRResult;
import de.in.tum.www2.cup.internal.parse_action_table;
import de.in.tum.www2.cup.internal.parse_reduce_table;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.controller.JobStatus;
import de.tum.in.www2.cupplugin.debug.Debugger;
import de.tum.in.www2.cupplugin.model.ICupParserLaLrChangeObserver;
import de.tum.in.www2.cupplugin.model.Model;
import de.tum.in.www2.cupplugin.views.CupActionTableView;
import de.tum.in.www2.cupplugin.views.CupConflictGraphView;
import de.tum.in.www2.cupplugin.views.CupConflictsView;
......@@ -32,8 +42,10 @@ import de.tum.in.www2.cupplugin.views.CupOverviewView;
import de.tum.in.www2.cupplugin.views.CupReduceGraphView;
import de.tum.in.www2.cupplugin.views.CupReduceTableView;
public class MultiPageEditor extends MultiPageEditorPart implements
IResourceChangeListener {
public class MultiPageEditor extends MultiPageEditorPart
implements IRegisterForControllerChanges,
ICupParserLaLrChangeObserver,
IResourceChangeListener {
private CupTextEditor editor;
private ZoomContributionViewItem graphReduceZoomContribution;
......@@ -49,10 +61,10 @@ public class MultiPageEditor extends MultiPageEditorPart implements
public final int OVERVIEW_PAGE_INDEX = 0;
public final int EDITOR_PAGE_INDEX = 1;
public final int CONFLICTS_PAGE_INDEX = 2;
public final int GRAPH_PAGE_INDEX = 3;
public final int ACTION_TABLE_PAGE_INDEX = 4;
public final int REDUCE_TABLE_PAGE_INDEX = 5;
public final int CONFLICT_GRAPH_PAGE_INDEX = 6;
public final int CONFLICT_GRAPH_PAGE_INDEX = 3;
public final int GRAPH_PAGE_INDEX = 4;
public final int ACTION_TABLE_PAGE_INDEX = 5;
public final int REDUCE_TABLE_PAGE_INDEX = 6;
private int previousPageIndex = EDITOR_PAGE_INDEX;
......@@ -70,7 +82,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
return conflictGraphView;
}
void setCounter(int pageIndex, int counter) {
private void setCounter(int pageIndex, int counter) {
boolean update = false;
if (counters.containsKey(pageIndex)) {
if (counters.get(pageIndex) == counter)
......@@ -84,7 +96,8 @@ public class MultiPageEditor extends MultiPageEditorPart implements
oldText = oldText.substring(0, index);
} else
oldText += " ";
setPageText(pageIndex, oldText + "(" + counter + ")");
String counterString = (counter == -1) ? "?" : "" + counter;
setPageText(pageIndex, oldText + "(" + counterString + ")");
}
void createEditorPage(Jumper jumper) {
......@@ -155,16 +168,21 @@ public class MultiPageEditor extends MultiPageEditorPart implements
addPage(CONFLICT_GRAPH_PAGE_INDEX, composite);
setPageText(CONFLICT_GRAPH_PAGE_INDEX, "Conflict Graph");
}
protected void createPages() {
Jumper jumper = new Jumper(this);
createEditorPage(jumper);
// only register after editor has been created.
Controller.getInstance(getEditor()).registerObserver(this);
Model.getInstanceForDocument(getEditor().getDocument()).registerModelObserver(this);
createOverviewPage(jumper);
createConflictsPage(jumper);
createConflictGraphPage(jumper);
createGraphPage(jumper);
createActionTablePage(jumper);
createReduceTablePage(jumper);
createConflictGraphPage(jumper);
setActivePage(previousPageIndex);
}
......@@ -324,4 +342,43 @@ public class MultiPageEditor extends MultiPageEditorPart implements
menu.remove(contItem);
//manager.remove(contItem);
}
@Override
public EnumSet<JobsToDo> getRequiredJobs() {
// We do only observe jobs, never request them!
return EnumSet.noneOf(JobsToDo.class);
}
@Override
public void jobStatusChanged(JobStatus status) {
if (status.getAffectedJob() == JobsToDo.buildTable) {
if (status.hasFailed()) {
setCounter(CONFLICTS_PAGE_INDEX, -1);
setCounter(GRAPH_PAGE_INDEX, -1);
// setCounter(ACTION_TABLE_PAGE_INDEX, -1);
// setCounter(REDUCE_TABLE_PAGE_INDEX, -1);
}
}
}
@Override
public void modelChanged(Model model) {
LALRResult result = model.getLaLrResult();
if (result == null)
return;
ConflictManager cm = result.getContext().getConflictManager();
setCounter(CONFLICTS_PAGE_INDEX, cm.getConflicts().size());
parse_action_table actionTable = result.getActionTable();
setCounter(GRAPH_PAGE_INDEX, actionTable.num_states());
/* parse_action_table actionTable = result.getActionTable();
if (actionTable != null)
setCounter(ACTION_TABLE_PAGE_INDEX, actionTable.num_states());
parse_reduce_table reduceTable = result.getReduceTable();
if (reduceTable != null)
setCounter(REDUCE_TABLE_PAGE_INDEX, reduceTable.num_states());
*/
}
}
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