/**
* Report WATER + INSERT errors from parse tree
*/
private static List<Error> gatherNonFatalErrors(IStrategoTerm top) {
List<Error> errors = new ArrayList<Error>();
ITokenizer tokenizer = getTokenizer(top);
if (tokenizer == null)
return errors;
for (int i = 0, max = tokenizer.getTokenCount(); i < max; i++) {
IToken token = tokenizer.getTokenAt(i);
String error = token.getError();
if (error != null) {
if (error == ITokenizer.ERROR_SKIPPED_REGION) {
i = findRightMostWithSameError(token, null);
reportSkippedRegion(token, tokenizer.getTokenAt(i), errors);
} else if (error.startsWith(ITokenizer.ERROR_WARNING_PREFIX)) {
i = findRightMostWithSameError(token, null);
reportWarningAtTokens(token, tokenizer.getTokenAt(i), error, errors);
} else if (error.startsWith(ITokenizer.ERROR_WATER_PREFIX)) {
i = findRightMostWithSameError(token, ITokenizer.ERROR_WATER_PREFIX);
reportErrorAtTokens(token, tokenizer.getTokenAt(i), error, errors);
} else {
i = findRightMostWithSameError(token, null);
// UNDONE: won't work for multi-token errors (as seen in SugarJ)
reportErrorAtTokens(token, tokenizer.getTokenAt(i), error, errors);
}
}
}
gatherAmbiguities(top, errors);