Skip to content

Commit

Permalink
Fixed recovery checking
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterOlivier committed Oct 3, 2024
1 parent 57862c6 commit 3572860
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/org/rascalmpl/parser/gtd/SGTDBF.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public abstract class SGTDBF<P, T, S> implements IGTD<P, T, S> {

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

// Error recovery
private IRecoverer<P> recoverer;
Expand Down Expand Up @@ -956,6 +957,7 @@ private boolean findFirstStacksToReduce() {
AbstractStackNode<P> recovered = recoveredNodes.getFirst(i);
queueMatchableNode(recovered, recovered.getLength(), recoveredNodes.getSecond(i));

Check warning on line 958 in src/org/rascalmpl/parser/gtd/SGTDBF.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/parser/gtd/SGTDBF.java#L958

Added line #L958 was not covered by tests
}
parseErrorRecovered = true;

Check warning on line 960 in src/org/rascalmpl/parser/gtd/SGTDBF.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/parser/gtd/SGTDBF.java#L960

Added line #L960 was not covered by tests
return findStacksToReduce();
}

Expand Down Expand Up @@ -1014,6 +1016,7 @@ private boolean findStacksToReduce() {
queueRecoveryNode(recovered, recovered.getStartLocation(), recovered.getLength(),
recoveredNodes.getSecond(i));
}
parseErrorRecovered = true;
return findStacksToReduce();
}

Expand Down Expand Up @@ -1595,7 +1598,7 @@ protected T buildResult(AbstractNode result, INodeFlattener<T, S> converter,
actionExecutor.completed(rootEnvironment, (parseResult == null));
}
if (parseResult != null) {
if (recoverer != null && parseErrorEncountered) {
if (recoverer != null && parseErrorRecovered) {
parseResult = introduceErrorNodes(parseResult, nodeConstructorFactory);
}
return parseResult; // Success.
Expand Down

0 comments on commit 3572860

Please sign in to comment.