use of org.drools.mvel.parser.MvelParser in project drools by kiegroup.
the class DrlxCompilerTest method testWhitespace.
@Test
public void testWhitespace() {
ParseStart<Expression> context = ParseStart.EXPRESSION;
MvelParser mvelParser = new MvelParser(new ParserConfiguration(), false);
ParseResult<Expression> result = mvelParser.parse(context, provider("1\n+1"));
assertEquals("1 + 1", result.getResult().get().toString());
}
use of org.drools.mvel.parser.MvelParser in project drools by kiegroup.
the class DrlxCompiler method toPackageDescr.
public PackageDescr toPackageDescr(Resource resource) throws IOException {
ParseStart<CompilationUnit> context = ParseStart.DRLX_COMPILATION_UNIT;
MvelParser mvelParser = new MvelParser(new ParserConfiguration(), false);
ParseResult<CompilationUnit> result = mvelParser.parse(context, provider(resource.getReader()));
if (result.isSuccessful()) {
DrlxVisitor drlxCompiler = new DrlxVisitor();
drlxCompiler.visit(result.getResult().get(), null);
PackageDescr pkg = drlxCompiler.getPackageDescr();
if (pkg == null) {
this.results.add(new ParserError(resource, "Parser returned a null Package", 0, 0));
return null;
} else {
pkg.setResource(resource);
return pkg;
}
} else {
for (Problem problem : result.getProblems()) {
TokenRange tokenRange = problem.getLocation().get();
Range range = tokenRange.getBegin().getRange().get();
int lineCount = range.getLineCount();
this.results.add(new ParserError(problem.getMessage(), lineCount, -1));
}
return null;
}
}
Aggregations