use of queryserver.parser.DSWrapperLexer in project java by wavefrontHQ.
the class AbstractIngesterFormatter method getQueue.
protected Queue<Token> getQueue(String input) {
DSWrapperLexer lexer = dsWrapperLexerThreadLocal.get();
lexer.setInputStream(new ANTLRInputStream(input));
CommonTokenStream commonTokenStream = new CommonTokenStream(lexer);
commonTokenStream.fill();
List<Token> tokens = commonTokenStream.getTokens();
if (tokens.isEmpty()) {
throw new RuntimeException("Could not parse: " + input);
}
// this is sensitive to the grammar in DSQuery.g4. We could just use the visitor but doing so
// means we need to be creating the AST and instead we could just use the lexer. in any case,
// we don't expect the graphite format to change anytime soon.
// filter all EOF tokens first.
Queue<Token> queue = tokens.stream().filter(t -> t.getType() != Lexer.EOF).collect(Collectors.toCollection(ArrayDeque::new));
return queue;
}
Aggregations