Skip to content

Commit

Permalink
Added check for 'regular' ambiguities when allowAmbiguities=false but…
Browse files Browse the repository at this point in the history
… allowRecovery=true
  • Loading branch information
PieterOlivier committed Nov 11, 2024
1 parent e1a9cd9 commit ae9aa76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/org/rascalmpl/library/util/ErrorRecovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,8 @@ private void collectAmbErrors(ITree amb, IListWriter errors, Set<IConstructor> p
collectErrors((ITree) alt, errors, processedTrees);
}
}

public void checkForRegularAmbiguities(IConstructor parseForest) {
disambiguate(parseForest, false, new HashMap<>());
}

Check warning on line 223 in src/org/rascalmpl/library/util/ErrorRecovery.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/library/util/ErrorRecovery.java#L222-L223

Added lines #L222 - L223 were not covered by tests
}
10 changes: 9 additions & 1 deletion src/org/rascalmpl/values/RascalFunctionValueFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,15 @@ private ITree parseObject(String methodName, ISourceLocation location, char[] in
if (allowRecovery) {
recoverer = new ToTokenRecoverer(uri, parserInstance, new StackNodeIdDispenser(parserInstance));
}
return (ITree) parserInstance.parse(methodName, uri, input, exec, new DefaultNodeFlattener<>(), new UPTRNodeFactory(allowRecovery || allowAmbiguity), recoverer, debugListener);
ITree parseForest = (ITree) parserInstance.parse(methodName, uri, input, exec, new DefaultNodeFlattener<>(), new UPTRNodeFactory(allowRecovery || allowAmbiguity), recoverer, debugListener);

if (!allowAmbiguity && allowRecovery) {
// Check for 'regular' (non-error) ambiguities
RascalValueFactory valueFactory = (RascalValueFactory) ValueFactoryFactory.getValueFactory();
new ErrorRecovery(valueFactory).checkForRegularAmbiguities(parseForest);

Check warning on line 591 in src/org/rascalmpl/values/RascalFunctionValueFactory.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/values/RascalFunctionValueFactory.java#L591

Added line #L591 was not covered by tests
}

return parseForest;
}
}

Expand Down

0 comments on commit ae9aa76

Please sign in to comment.