String source = (String) document.getContent();
camodel_return info = null;
CaruleLexer lexer;
// try to parse text to record of model information rules, states and so on
CommonTokenStream tokenStream =
new CommonTokenStream(lexer =
new CaruleLexer(new ANTLRStringStream(source)));
CaruleParser parser = new CaruleParser(tokenStream);
try {
info = parser.camodel();
} catch (RecognitionException e) {
info = new camodel_return();
}
// merge lexer problems with parser problems
List<CAProblemToken> problems =
new ArrayList<>(info.problems);
for (CAProblemToken t : lexer.getProblemTokens()) {
problems.add(t);
}
Collections.sort(problems);
info.problems = problems;