@Override public Token LT(int i) { CommonToken t; int rawIndex = p + i - 1; if (rawIndex >= types.size()) t = new CommonToken(Token.EOF); else t = new CommonToken(types.get(rawIndex)); t.setTokenIndex(rawIndex); return t; }
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; }
public SerializedATN(OutputModelFactory factory, ATN atn) { super(factory); IntegerList data = ATNSerializer.getSerialized(atn); serialized = new ArrayList<String>(data.size()); for (int c : data.toArray()) { String encoded = factory .getGenerator() .getTarget() .encodeIntAsCharEscape(c == -1 ? Character.MAX_VALUE : c); serialized.add(encoded); } // System.out.println(ATNSerializer.getDecoded(factory.getGrammar(), atn)); }
@Override public Token get(int i) { return new org.antlr.v4.runtime.CommonToken(types.get(i)); }
@Override public int size() { return types.size(); }