Skip to content

Commit

Permalink
Added check before error node post-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterOlivier committed Oct 3, 2024
1 parent 76afc27 commit 409aa57
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/org/rascalmpl/parser/gtd/SGTDBF.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.concurrent.atomic.AtomicBoolean;

import org.rascalmpl.parser.gtd.debug.IDebugListener;
import org.rascalmpl.parser.gtd.exception.ParseError;
Expand Down Expand Up @@ -136,7 +135,7 @@ public abstract class SGTDBF<P, T, S> implements IGTD<P, T, S> {
private final DoubleStack<AbstractStackNode<P>, AbstractNode> filteredNodes;

// Error reporting guards
private boolean parseErrorOccured;
private boolean parseErrorEncountered;

// Error recovery
private IRecoverer<P> recoverer;
Expand Down Expand Up @@ -960,7 +959,7 @@ private boolean findFirstStacksToReduce() {
return findStacksToReduce();
}

parseErrorOccured = true;
parseErrorEncountered = true;
}

return false;
Expand Down Expand Up @@ -1018,14 +1017,14 @@ private boolean findStacksToReduce() {
return findStacksToReduce();
}

parseErrorOccured = true;
parseErrorEncountered = true;
}

return false;
}

public boolean parseErrorHasOccurred() {
return parseErrorOccured;
return parseErrorEncountered;
}

/**
Expand Down Expand Up @@ -1451,7 +1450,7 @@ protected AbstractNode parse(AbstractStackNode<P> startNode, URI inputURI, int[]

try {
// A parse error occured, and recovery failed as well
parseErrorOccured = true;
parseErrorEncountered = true;

int errorLocation = (location == Integer.MAX_VALUE ? 0 : location);
int line = positionStore.findLine(errorLocation);
Expand Down Expand Up @@ -1596,7 +1595,7 @@ protected T buildResult(AbstractNode result, INodeFlattener<T, S> converter,
actionExecutor.completed(rootEnvironment, (parseResult == null));
}
if (parseResult != null) {
if (recoverer != null) {
if (recoverer != null && parseErrorEncountered) {
parseResult = introduceErrorNodes(parseResult, nodeConstructorFactory);
}
return parseResult; // Success.
Expand Down

0 comments on commit 409aa57

Please sign in to comment.