Esempio n. 1
0
 public List<String> getTokenTypes(LexerGrammar lg, ATN atn, CharStream input, boolean adaptive) {
   LexerATNSimulator interp = new LexerATNSimulator(atn);
   List<String> tokenTypes = new ArrayList<String>();
   int ttype;
   do {
     if (adaptive) ttype = interp.match(input, Lexer.DEFAULT_MODE);
     else ttype = interp.matchATN(input);
     if (ttype == Token.EOF) tokenTypes.add("EOF");
     else {
       tokenTypes.add(lg.typeToTokenList.get(ttype));
     }
   } while (ttype != Token.EOF);
   return tokenTypes;
 }
Esempio n. 2
0
 public List<Integer> getTokenTypes(String input, LexerATNSimulator lexerATN) {
   ANTLRStringStream in = new ANTLRStringStream(input);
   List<Integer> tokenTypes = new ArrayList<Integer>();
   int ttype = 0;
   do {
     ttype = lexerATN.matchATN(in);
     tokenTypes.add(ttype);
   } while (ttype != Token.EOF);
   return tokenTypes;
 }