List<Token<PyElementType>> (@NotNull String s) { final List<Token<PyElementType>> tokens = new ArrayList<>(); final _PyTypeLexer lexer = new _PyTypeLexer(new StringReader(s)); lexer.reset(s, 0, s.length(), lexer.yystate()); try { PyElementType type; while ((type = lexer.advance()) != null) { if (type == PyTypeTokenTypes.SPACE || type == PyTypeTokenTypes.MARKUP) { continue; } final TextRange range = TextRange.create(lexer.getTokenStart(), lexer.getTokenEnd()); final Token<PyElementType> token = new Token<>(type, lexer.yytext(), range); tokens.add(token); } } catch (IOException | Error e) { return Collections.emptyList(); } return tokens; }