Commit c073bc48 authored by Johannes Roith's avatar Johannes Roith

Don't runt ables if parse error occurred.

parent a15e9155
......@@ -8,17 +8,20 @@ public class ErrorManager
{
private IErrorReporter er;
private int error_count;
private int parser_error_count;
private int scanner_error_count;
private int lalr_error_count;
public boolean hasScanErrors (){
throw new RuntimeException("TODO: implement!");
return scanner_error_count != 0;
}
public boolean hasParseErrors (){
throw new RuntimeException("TODO: implement!");
return parser_error_count != 0;
}
public boolean hasLALRErrors (){
throw new RuntimeException("TODO: implement!");
return lalr_error_count != 0;
}
public boolean hasErrors (){
......@@ -104,6 +107,13 @@ public class ErrorManager
public void Error(ErrorSource source, String msg, Position start, Position end) {
er.report(ErrorType.Error, source, null, msg, start, end);
error_count++;
switch (source) {
case Parser: parser_error_count++; break;
case Scanner: scanner_error_count++; break;
case LALR: lalr_error_count++; break;
default: break;
}
}
}
......@@ -109,25 +109,24 @@ public class DocumentDidChangeJob extends Job {
IFile file = ((FileEditorInput) myEditor.getEditorInput()).getFile();
CupEditorErrorReporter errorReporter = new CupEditorErrorReporter(file);
CupParser parser = null;
if (jobs.contains(JobsToDo.parseCode)) {
InputStream in = new ByteArrayInputStream(codeText.getBytes());
CupParser p = new CupParser(errorReporter, in);
parser = new CupParser(errorReporter, in);
result = null;
context = null;
try {
result = p.parse();
context = p.getContext();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
result = parser.parse();
} catch (Exception e1) {
e1.printStackTrace();
}
context = parser.getContext();
errorReporter.pushToUIThread();
if (result != null) {
// System.out.println(result.toString());
ParserResultJob resultModelJob = new ParserResultJob(result,
revNumber);
resultModelJob.setSystem(true);
......@@ -135,33 +134,28 @@ public class DocumentDidChangeJob extends Job {
try {
resultModelJob.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
return Status.CANCEL_STATUS;
}
}
if (jobs.contains(JobsToDo.buildTable)) {
lalrResult = null;
try {
// if (!p.hasParseErrors()) {
lalrResult = LALRResult.Compute(context,
context.start_production);
// }
if (parser != null && !parser.hasParseErrors()) {
lalrResult = LALRResult.Compute(context,
context.start_production);
} else {
System.out.println("LALRResult.Compute was not called, " +
"because the parser has reported errors.");
}
} catch (internal_error e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// errorReporter.pushToUIThread();
if (lalrResult != null) {
LaLrResultJob resultLaLrModelJob = new LaLrResultJob(myEditor,
lalrResult, revNumber, context);
......@@ -180,13 +174,11 @@ public class DocumentDidChangeJob extends Job {
errorReporter.pushToUIThread();
System.out.println(jobs);
documentEvents.clear();
jobs.clear();
// nichts mehr ändern ab hier
iAmCurrentlyRunning = false;
CallbackJob cb = new CallbackJob(myEditor);
cb.setSystem(true);
......@@ -238,70 +230,6 @@ public class DocumentDidChangeJob extends Job {
}
}
class LocationPatchJob extends UIJob {
private List<DocumentEvent> documentEvents;
// TODO: can we be sure that we are the only one accessing the documentEvents list?
public LocationPatchJob(List<DocumentEvent> documentEvents) {
super("Location Patch Job");
this.documentEvents = new ArrayList<DocumentEvent> (documentEvents);
}
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
/*
System.out.println("RUNNING LocationPatchJob: ");
// TODO: combine consecutive 1-character insert events.
for (DocumentEvent event : documentEvents) {
System.out.println("PROCESSING DocumentEvent: ");
System.out.println(" Offset: " + event.getOffset());
System.out.println(" Replaced: " + event.getLength());
System.out.println(" New: " + event.getText().length());
IDocument document = event.getDocument();
try {
int offset = event.getOffset();
int startLineNumber = document.getLineOfOffset(offset);
// TODO: wrong! must take removed text into account.
int startColumn = offset - document.getLineOffset(event.getText().length());
Position start = new Position(startLineNumber+1, startColumn+1, offset+1);
// updating the offsets is easy
// how do we update the lines correctly?
// how do we find out how many lines have been removed?
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// event.getDocument().
}
// TODO: location Patch verifizieren
Position oldRemovedFrom = null;
int oldRemovedLength = 0;
int newLength = 0;
LocationPatchVisitor visitor = new LocationPatchVisitor(
oldRemovedFrom, oldRemovedLength, newLength);
if (result != null)
result.accept(visitor, null);
else {
System.out.println("ERROR: Can't run LocationPatchVisitor!");
}
*/
return Status.OK_STATUS;
}
}
class SetupJob extends UIJob {
......
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