Java Map Print printTokenStream(CommonTokenStream tokens, Map tokenToName)

Here you can find the source of printTokenStream(CommonTokenStream tokens, Map tokenToName)

Description

print Token Stream

License

Open Source License

Declaration

static void printTokenStream(CommonTokenStream tokens, Map tokenToName) 

Method Source Code


//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
    }
}

Related

  1. printMapStrings(Map> map, String mapDescription)
  2. printMapToString(Map map)
  3. printNERScore(Map scores)
  4. printOptions(Map options)
  5. printStringMap(Map hsMap, String sDel)
  6. printVarTable(HashMap map)