Example #1
0
 @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;
 }
Example #2
0
 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;
 }
Example #3
0
 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;
 }
Example #4
0
 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));
 }
Example #5
0
 @Override
 public Token get(int i) {
   return new org.antlr.v4.runtime.CommonToken(types.get(i));
 }
Example #6
0
 @Override
 public int size() {
   return types.size();
 }