public IntegerList getTokenTypesViaATN(String input, LexerATNSimulator lexerATN) { ANTLRInputStream in = new ANTLRInputStream(input); IntegerList tokenTypes = new IntegerList(); int ttype; do { ttype = lexerATN.match(in, Lexer.DEFAULT_MODE); tokenTypes.add(ttype); } while (ttype != Token.EOF); return tokenTypes; }
IntegerList getTypesFromString(Grammar g, String expecting) { IntegerList expectingTokenTypes = new IntegerList(); if (expecting != null && !expecting.trim().isEmpty()) { for (String tname : expecting.replace(" ", "").split(",")) { int ttype = g.getTokenType(tname); expectingTokenTypes.add(ttype); } } return expectingTokenTypes; }