private ANTLRParser.ParseResult toAntlrTree(LessSource source) throws Less4jException {
ANTLRParser.ParseResult result;
try {
result = parser.parseStyleSheet(source.getContent(), source);
} catch (FileNotFound ex) {
throw new Less4jException(new GeneralProblem("The file " + source + " does not exists."), new CompilationResult(null));
} catch (CannotReadFile ex) {
throw new Less4jException(new GeneralProblem("Cannot read the file " + source + "."), new CompilationResult(null));
}
if (result.hasErrors()) {
CompilationResult compilationResult = new CompilationResult("Errors during parsing phase, partial result is not available.");
throw new Less4jException(result.getErrors(), compilationResult);
}
return result;
}