Here you can find the source of printTokenStream(CommonTokenStream tokens, Map tokenToName)
static void printTokenStream(CommonTokenStream tokens, Map tokenToName)
//package com.java2s; //License from project: Open Source License import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.Token; import org.antlr.runtime.TokenSource; import java.util.Map; public class Main { static void printTokenStream(CommonTokenStream tokens, Map tokenToName) { TokenSource source = tokens.getTokenSource(); Token curr;/* w w w . j av a2 s.c om*/ do { curr = source.nextToken(); System.out.println(curr.getText() + " [" + tokenToName.get(String.valueOf(curr.getType())) + "]"); } while (-1 != curr.getType()); // eof } }